-
Notifications
You must be signed in to change notification settings - Fork 12k
Angular5 build-optimizer generates bundles with "Please add a @NgModule annotation." errors #8594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via |
I'm having the same problem. package.json
{
"start:fail": "ng serve --prod --aot=false --build-optimizer=true ",
"build:fail": "ng build --prod --aot=false --build-optimizer=true "
} It works fine when you run (in this case the --aot is enabled) package.json
{
"start": "ng serve --prod --build-optimizer=true ",
"build": "ng build --prod --build-optimizer=true "
} |
Fixed by #8346. Build Optimizer is not compatible with JIT builds and we shouldn't allow it to be set, but there was a bug where that could happen. |
Sorry for jumping in, I just ran into this before I found this issue. But apparently, it is still possible to build and serve (JIT) with Versions
Repro steps
|
Thanks guys, it helped me. I had the same problem with the build-optmizer option. |
thanks @musicEnfanthen for the fix. |
Actually, this wasn't meant as a fix, rather as feedback that it is still possible to set build-optimizer flag with JIT builds without any error or warn message despite the fix in #8346. |
@musicEnfanthen that regression was reported in #11157 and fixed via #11657 |
@filipesilva I am facing same issue but we are not using angular-cli in our project to use given command Could you please tell me how to resolve this issue without angular-CLI. Is there any way to change buildOptimizer property.I am new to angular.Your help is highly appericiated |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
Or :
Observed behavior
The app served with "ng serve --prod --aot false" gives the following error in the browser console :
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
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 :
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 :
My best guess for now is that the build-optimizer only works with aot, because if when I tried the following command :
It tells me that I need the aot flag
Hope you can help,
Thanks
The text was updated successfully, but these errors were encountered: