Angular5 build-optimizer generates bundles with "Please add a @NgModule annotation." errors
See original GitHub issueVersions
Angular CLI: 1.5.0
Node: 8.1.3
OS: linux x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1
Repro steps
- ng build --prod --aot false Or :
- ng serve --prod --aot false
Observed behavior
The app served with “ng serve --prod --aot false” gives the following error in the browser console :
"Unexpected value 'e' imported by the module 'e'. Please add a @NgModule annotation."
Desired behavior
I expected no error as a simple ng serve serves the app with no error.
Mention any other details that might be useful (optional)
At first I encounter this problem after migrating from angular 4 to 5 and building my app with
ng build --prod --aot false
After deploying on a web server, I ended up with the error previously mentionned. I’ve done some digging, and I found out that it was the fault of the build-optimizer added with angular 5 (it is activated by default with the --prod flag) because if I deactivate it with the following command line, it works fine :
ng build --prod --aot false --build-optimizer false
I’ve run some more tests, and I also found out that serving the app this way gives me the same error on my browser console :
ng serve --prod --aot false
My best guess for now is that the build-optimizer only works with aot, because if when I tried the following command :
ng serve --build-optimizer true
It tells me that I need the aot flag
The `--build-optimizer` option cannot be used without `--aot`.
Hope you can help, Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
I’m having the same problem. This is the repository @filipesilva angualar-build-optimizer-true you can run: npm install && npm run build:fail && npm run start:fail
It works fine when you run (in this case the --aot is enabled) npm install && npm run build && npm run start
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.