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.

1 Like

I solved this issue by removed context.isProd || from the file node_modules/@ionic/app-scripts/dist/util/config.js line:38

so the code will be like this :

context.runAot = [
   context.runAot,
   hasArg('--aot'),
].find(function (val) { return typeof val === 'boolean'; }); 

Thanks