-
Notifications
You must be signed in to change notification settings - Fork 12k
Angular 10. CommonJS or AMD dependencies can cause optimization bailouts #18025
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
Hi @alekcey0211, Your module entrypoint is |
I would reopen this. The current solution is very inconvenient! We're using lodash in our project and we use synthetic imports to have smaller bundles when importing lodash functions. So we use it like |
I'm getting this error when loading local Angular components in their respective modules through a global path like
Here's the full error for one of the modules:
I know the path should be relative here, but then the error message should reflect that (or another issue) and this error is a bit misleading. Edit: I looked into it a bit further, and not all components that are loaded this way are showing the warning. |
@BlindDespair, let's continue tracking this #18058 since it's has more details. |
Hi I dont understand the problem here at all. I get:
The lib it depends on is fine to be imported with any other project. Import is in file
|
Also most important: Why is this not on the Angular Upgrade GUIDE! ? Do we really have to sniff up the web ? |
WARNING in component.ts depends on 'socket.io-client'. CommonJS or AMD dependencies can |
@ahmadmu I have totally same behaviour. I do not really understand why this issue is closed. But that is so stupid because the warning is totally random and talks about other problem but not using aliases for imports for the same module Inside conversation module: Warning: That is so stupid... |
I have resolved this issue by adding it to the angular.json ->
allowedCommonJsDependencies.
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
*"allowedCommonJsDependencies" : [*
* "socket.io-client", //Warning related packages*
* "socket.io-parser",*
* "debug"*
* ], *
Thanks and Regards,
Gunaseelan S
…On Tue 14 Jul, 2020, 19:11 Evhenii Hudzenko, ***@***.***> wrote:
@ahmadmu <https://github.com/ahmadmu> I have totally same behaviour. I do
not really understand why this issue is closed. But that is so stupid
because the warning is totally random and talks about other problem but not
using aliases for imports for the same module
Inside conversation module:
import { ConversationComponent } from
***@***.***/features/apps/conversation/conversation.component';
Warning:
WARNING in .../src/app/features/apps/conversation/conversation.module.ts
depends on ***@***.***/features/apps/conversation/conversation.component'.
CommonJS or AMD dependencies can cause optimization bailouts.
That is so stupid...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#18025 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APDPFHDJ2SKMWQIFIAMGAETR3ROCFANCNFSM4OIJYY5Q>
.
|
Hi @alan-agius4 can you guide me to the issue that will solve our production issues since updating and following the guides broke many things. To be honest after this it's the first time I will say: I am not sure I recommend angular. And that is due to the team member communications. I will be reporting this to my superiors that are working for Google on a colab project anyways. That's not the way Todo things. |
Hi @alan-agius4. Thanks, |
Hi @thomasoreilly, No, there isn’t a configuration to disable the warning at a library level. The reason being is that the consumer of a given library must be made aware that by using a library in CJS format they might cause optimization bailouts which may impact negatively on SEO, bundle size and performance. This is because CJS libraries cannot be optimized as much as ESM or FESM by bundlers such as Webpack and Rollup. Users can choose to suppress the warning and accept that they might have larger bundles sizes and unused code in their final bundle, until either the problematic library is distributed in a modern format or they replace it with another modern library. |
Thanks for this information @alan-agius4. |
I hate warnings! BUT agreed with @thomasoreilly, the way that @sgunaseelan56 suppressed the warnings is working just fine... still don't see any differences on my building process so I can ignore it. |
it's a nightmare |
@sgunaseelan56 that seemed too have worked... thx |
Im currently using the custom-webpack builder, and im not able to use the allowedCommonJsDependencies property. |
on Angular File "architect": {
"build": {
"options": {
"allowedCommonJsDependencies": [
"uuid",
"ulid",
"lodash/get",
"lodash/isEmpty",
"lodash/isEqual",
"@aws-amplify/core",
"buffer",
"@aws-crypto/sha256-js",
"crypto-js/hmac-sha256",
"crypto-js/lib-typedarrays",
"zen-observable",
"js-cookie",
"isomorphic-unfetch",
"@aws-crypto/crc32",
"fast-xml-parser",
"@aws-crypto/sha256-browser",
"axios"
]
}}}
|
@guisperandio Have you found a fix por que |
@PBartrina Not yet, tbh I was not looking into it, cause the alert message it is not a problem yet, but definitelyit is something that im gonna look into next week |
How can I know which import will cause "CommonJS or AMD dependencies can cause optimization bailouts."? When I import { map } from 'rxjs/operators' Everything works well, but when I import { map } from 'rxjs/internal/operators' This warning is show, but I can't see the reason. |
You can find a good explanation here - https://stackoverflow.com/a/62604034/6097025 |
@PBartrina I tested that today and the allowedCommonJsDependencies it is working with @angular-builders/custom-webpack:browser now |
@guisperandio Thanks for the update! <3 |
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. |
After update to angular 10. I got this warning.
WARNING in ...\projects\client\src\app\localization.ts depends on devextreme/localization/globalize/date. CommonJS or AMD dependencies can cause optimization bailouts.
after read link "https://angular.io/guide/build#configuring-commonjs-dependencies"
i made this
But this don`t help me.
What i doing wrong?
The text was updated successfully, but these errors were encountered: