Is it possible to do a production build without AOT and will it be possible using ionic-angular 4?

Is it possible to build a production release without using AOT (templates will be JIT compiled by the client as it was with Angular1)?
If yes, will it still be possible using ionic-angular 4, or will AOT be made mandatory for production builds?

Thank you in advance for any info!!!

I can’t answer your question unfortunately, but I’m really curious as to why you’d want to build without AOT?

AOT isn’t just one thing. You might want to check about the angular compiler flags available for tsconfig.json. There are a lot of them, and I don’t understand them well. But sure, you can turn a lot of things off.

I need mobile Apps to get HTML templates from server, so that I can modify them, without resubmitting to App stores, like I always did with Angular 1.
I tried simply using a remote (HTTP) URL for a Component “templateUrl” and it works with a dev build, but I imagine it will not, if AOT is used, will it?
Since --prod implies --aot I wonder if is it possible to configure a build with --prod but not --aot.
Also I think I read somewhere (couldn’t find it again) that with Ionic 4 AOT will be mandatory, but I’m not sure about that.

1 Like

ionic cordova build android --prod --ngc could work. I don’t know what ngc flag does but it has to do with the angular compiler.

Edit:
My fault, ngc flag activates aot compiling so you can build dev builds with aot.

You find the tags here, but its missing a description:

I looked into source code of ionic-app-scripts and it seems that --prod actually implies AOT.
At line 40 of https://github.com/ionic-team/ionic-app-scripts/blob/master/src/util/config.ts it reads:

// If context is prod then the following flags must be set to true
context.runAot = [
context.runAot,
context.isProd || hasArg(’–aot’),
].find(val => typeof val === ‘boolean’);

So, if I want to try disabling AOT for --prod, I have to use a modified version of ionic-app-scripts…
…don’t know… it may be a little too much, I’ll have to think about it…

I would use that too. My app creates documents based on html and custom commands from server side and I can’t do that with AOT. Instead I use a build --release command (I have no idea if that is a think even), but my package is not well optimized.

Hi Have you find the solution for this? I also want to implement the same in my ionic project …pls help

Didn’t have time to look into this matter ever since…
But I found out it should be feasible to load compiled modules from the server
(see: https://forum.ionicframework.com/t/loading-page-modules-or-at-least-templates-from-remote-server/119169/8)
but hadn’t worked on that anymore, too…

Hi,

          thq , I will check about this .

I also need do production build without aot by this issue, https://github.com/typeorm/ionic-example/issues/23. Is it possible for us to ask this new feature request for CLI?

Like export IONIC_AOT=false , is it possible to use Ionic Environment Variables instead of modifying ionic-app-scripts directly?

I might be a little bit late but you definetly can build without aot, just go in angular.json and at your

app -> architect -> build -> configurations -> production -> put aot to false.

the --prod flag is actually calling the production configuration from your angular app.