-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Build produces CommonJS / AMD dependencies optimization bailouts warning #18020
Comments
Well next time I need to read the error message more carefully. It says that the So in case you are using For more info, see this SO answer: https://stackoverflow.com/a/62589268 |
Hi @json-derulo, The problem here is that You can read more about this here: https://angular.io/guide/build#configuring-commonjs-dependencies which also shows how to suppress the warning if you are not interesting in fixing it right away. |
Hi have same issue @json-derulo |
@stingers if possible replace the dependency with a library that itself is an ES module. |
@json-derulo thanks. but more about ' ...the dependency with a library that itself is an ES module.' |
I am having the same problem but with importing my own Angular component through TS aliases. I am trying to reproduce this is a separate new project but haven't figure out how just yet. The message is like this:
Any idea? |
@alejandrocoding this example is more explicite: |
Thanks @stingers for sharing ideas. I have feature modules and lazy loading modules in this project. I have double checked your suggestion but it seems to be only declared once within its own module, so it doesn't seem to be the problem. I have actually checked a few. I am getting tons of warning like this, so as part of my findings what I have figured out is that removing the TS Alias
And the warning goes away. I have done it for 3 different components and the 3 warnings disappeared. |
Guys I think you should open a new issue for this. That seems to be another problem... |
I thought it was ok to chat about it since the error is closed and I might get any related ideas but yeah, you are right, let's leave it here I won't open an issue until I can reproduce the error, otherwise, it will be more noise to the team with no value. Thanks! |
@alejandrocoding if you are on vscode use in setting.json |
When you use a dependency that is packaged with CommonJS, it can result in larger slower applications Starting with version 10, Angular now warns you when your build pulls in one of these bundles. If you’ve started seeing these warnings for your dependencies, let your dependency know that you’d prefer an ECMAScript module (ESM) bundle. Here is an official documentation - Configuring CommonJS dependencies Solution: edit angular.json & add those dependencies
|
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. |
🐞 bug report
Is this a regression?
Yes, it worked fine in Angular 9
Description
Since Angular 10, when having a library with an application in the same workspace, and in the library an ECMAScript module from lodash (and maybe other libraries?) is used, a build warning is produced when building the application using code from the library.
For example, this code in the library produces a warning:
The warning says something about CommonJS and AMD dependencies, but this is an ECMAScript module, so I don't really understand why the warning is thrown.
🔬 Minimal Reproduction
Demo project: https://github.com/json-derulo/angular-commonjs-warning
Check out the code and run
ng build
The code with the ECMAScript import is located in
projects/test-library/src/lib/test-library.service.ts
🔥 Exception or Error
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: