AoT - Ahead-Of-Time

how can use AoT - Ahead-Of-Time build ionic ?
my ionic info

cli packages: (C:\Users\Admin\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 25.2.3
    Node              : v6.11.1
    npm               : 3.10.10
    OS                : Windows 10

Run ionic build or ionic cordova build or npm run ionic:build with --prod as param.

but main.ts
import { platformBrowserDynamic } from ‘@angular/platform-browser-dynamic’;

import { AppModule } from ‘./app/app.module’;

platformBrowserDynamic().bootstrapModule(AppModule);

this is JiT

1 Like

Adding --prod as param changes this. If you want to know the details, see here: https://github.com/ionic-team/ionic-app-scripts

1 Like

ionic cordova build doesn’t build AOT at all even with either --prod or --aot or both, at least that’s true in CLI v.3.9.2 (and it hasn’t been building AOT since most of version 3). I had to use npm run ionic:build --prod to get ngc running. Anyone on the same boat?

No, and I’m curious what you’re basing this on.

When I made that comment, it was based on the fact that our app sizes were exactly the same building it with or without the --prod flag, the log outputs build dev started..., instead of ngc started and none of the optimization/minification steps are present in the logs. The app’s startup time peaks at 2 minutes because the JIT complier is trying to compile all our components in app.module.ts (we have a large app with over 500+ components).

Although soon after I had posted that reply today, I revisited the issue and figured out the culprit: We are running our builds on a locally installed version of the ionic CLI (we have multiple ionic apps to support and one of them breaks building with anything above version 2.x.x). So when we run ionic cordova build ios | android --prod, we are actually running the ionic inside node_modules/.bin that ignores any --prod or --aot flags and build all the apps in dev mode. Installing the CLI globally solves that issue.

1 Like

Perhaps nvm or its windows equivalent might make dealing with this situation easier.

1 Like