-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Lots of warnings in Angular 9 CommonJS or AMD dependencies can cause optimization bailouts. #6202
Comments
These warnings seem to be red-herring and something angular introduced in version 10. See angular/angular-cli#18057 and angular/angular-cli#18058. We will follow these issues closely to see if there are any fixes we can add in the library to suppress them. For now it should be safe to use Amplify library even with the presence of these warnings. |
Hi, the problem is @AWS-SDK use in Amplify libraries. @AWS-SDK uses CommonJS. It is recommended that you avoid depending on CommonJS modules in your Angular applications. Depending on CommonJS modules can prevent bundlers and minifiers from optimizing your application, which results in larger bundle sizes. Instead, it is recommended that you use ECMAScript modules in your entire application. |
Remove warnings adding this code https://gist.github.com/gsans/8982c126c4fef668c094ff288f04241b |
Thanks. |
Thanks @gsans, yeah, that worked for me 2. I didn't realize at first I needed to add the values to the right of the depends, not the left. Too bad AWS uses CommonJS. My bundle size is already huge :( |
There are even more dependencies. "options": { |
I added all necessary libraries to the allowedCommonJsDependencies, but I am still getting the following error: Uncaught ReferenceError: exports is not defined And here is what I added in the angular.json: "allowedCommonJsDependencies": [ any idea on what I am missing? |
You just have to add missing libraries, like I mentioned. |
I have already done that |
So, it is strange... |
if you check what is complaining about, it is already in the allowedCommonJsDependencies ... So I don't get it ... |
@eelayoubi that seems a different issue. The fix that appears in this thread is to remove the warnings. Your trace is not from a warning but an error. |
@gsans you are correct, although the warnings while building the project disappeared, this error stayed in the console. I thought it might be related. I will check again. |
@eelayoubi IIRC correctly that occurs when you're in Angular 9/10 and you are using the older @aws-amplify library for angular. Make sure to use and
|
@ErikHDev as per the tutorial we are installing the latest versions of '@aws-amplify/ui-angular' & 'aws-amplify' (I verified the package.json too). and yes, I am using angular 10. |
This is one of the reasons why amplify-js is pretty large in size. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Definitely still needed. |
@Amplifiyer , some feedback on this problem, i understand that you make use of the CommonJs modules that affect the size of the angular packages, you are plan to release a version using ES modules? |
Hiding the warnings is not a fix - it just masks the problem and probably makes it less likely to be fixed properly. Which issue can we follow where the use of legacy commonjs modules is being tracked and migration progress can be followed? |
As nice as it would be to have an ECMAScript aws-sdk for our Angular apps, it's not a show-stopper. The warnings went away for most of us after updating angular.json to ignore certain Common JS dependencies. For people looking to shed some aws-sdk weight, consider only importing what you need (which has been available in aws-sdk for the last couple of years): import Amplify from '@aws-amplify/auth'; // (assuming you only need Cognito) The above sheds almost 10MB in my case (from 13.9MB to 4.27MB, vendor.js). |
Issue leaking to other frameworks like Vue. Not only Angular as this results in larger bundle sizes: https://twitter.com/taseroth/status/1307429119387463680?s=19 |
Yikes! Lets get a resolution on this, padding |
I can confirm the warnings are gone in my app as well after upgrading. However bundle size remained the same, in fact went up by 100kb or so after updating to the latest @aws-amplify npm packages. |
I did some research into this using Angular CLI 11 (thanks for the tip!): #7842 fixed some The new bundle-sizes seem reasonable though for Amplify + Auth, though?
|
The fix I'd like to see for this issue is investigating why Angular is giving this warning when we have |
I still have this issue after updating from 9 to 12, it's is warning me about a service |
@Donovantxy I'm not sure what you mean, can you share code or screenshots or console output? |
These are the warnings I'm getting from building the project with Angular 11.2.4
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
bump |
This is my current list of warnings after clearing the npm cache and deleting node_modules (Angular CLI v12.2.7):
When upgrading my Amplify CLI, this deprecation warning caught my eye:
Just a wild guess, but maybe @aws-amplify and othter aws npm packages use a similarly old version of uuid and other dependencies, which do not have es6 module support, yet. May be a low hanging fruit upgrading those dependencies. |
bump for the new year! |
bump angular cli 13.2.5
|
Related to #10010 |
I can confirm most of the warning has gone away with the latest AWS SDK version. The only things left are from the
|
I just started a new project, added
"@angular/core": "^15.2.0", |
Almost 3 years and still the same problem! 😞 👎 |
We are working on resolving these errors. It requires a substantial amount of refactoring on our end, and we are defining now exactly how to go about it. We will provide an update on this issue when we have next steps identified. |
Hello everyone! As part of our next major version, we now have a prototype working while removing most of the errors, except the sha256 package error. We are attempting to find a solution for it now. We just wanted to let you know this is still on our radar! |
Any updates on this? |
Describe the bug
Installing the latest version of @aws-amplify/ui-angular and aws-amplify causes many warnings in the console when adding authentication. Also unable to remove warnings using angular.json.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
NO warnings.
Code Snippet
What is Configured?
The text was updated successfully, but these errors were encountered: