1

I want to compile my angular 2 projects with AOT.

ng build --prod --aot

gives this error;

ERROR in Unexpected value 'null' imported by the module 'AppModule in D:/Git/ng_v4_aot/src/app/app.module.ts'

Are there any initial configurations before compiling with AOT?

Rahi.Shah
  • 1,305
  • 11
  • 20
yashodha_h
  • 944
  • 3
  • 9
  • 23

1 Answers1

1

install npm install rollup rollup-plugin-node-resolve rollup-plugin-commonjs rollup-plugin-uglify --save-dev

  1. ng build // build with JIT
  2. ng build --prod --no-aot // build with JIT
  3. ng build --prod // build with AOT

Since @angular/cli@1.0.0-beta.28 they've made the AOT compilation the default for production builds.

Create a tsconfig-aot.json as descirbed in aot documentation

Run the following command:

  • "node_modules/.bin/ngc" -p tsconfig-aot.json (will build and output ngFactory files)
  • ng build --prod
macrog
  • 2,085
  • 1
  • 22
  • 30