-
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
Webpack 5 compatibility #8579
Comments
Also seeing warning for crypto-js: "/node_modules/amazon-cognito-identity-js/es/AuthenticationHelper.js depends on 'crypto-js/core'. CommonJS or AMD dependencies can cause optimization bailouts. |
When I searched for the buffer dependency mentioned, the npm page says it is for the browser. The page you linked mentions you can disable those warnings
|
Thanks @chrisbonifacio I should have checked I was able to silence the optimization warnings with respect to CommonJS or AMD modules by adding the following to "allowedCommonJsDependencies": [
"buffer",
"crypto-js",
"isomorphic-unfetch"
], The only warning error now is the breaking change with webpack 5. Not sure what has to be done here, or if Cognito SDK requires the missing polyfill? I feel like this is something that should be cleaned up on the SDK side. "Module not found: Error: Can't resolve 'crypto' in '/home/yadav/websites/hdt/aws-cognito/aws-cognito-register-user/node_modules/crypto-js'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }" |
@rajinder-yadav Yup, that error message is spot on and yes, that would be the ideal solution. I did bring this to the team yesterday and they're currently looking into handling this on our side. |
@rajinder-yadav Hi thank you for cutting the issue and you are right, this is a known issue as webpack 5 no longer shim in browserify version of node-js built-in. (In webpack 4, the browserify version of the node-js built in is a direct dependency of webpack) For crypto-js, it is due to its explicitly For buffer, I need to investigate more to see how we can handle it. I am looking at some related issues now: |
Thanks @hkjpotato and @chrisbonifacio for looking into this issue, happy to hear progress is getting made! Looking forward to see Angular 12 building cleanly again :-D @hkjpotato appreciate the explanation of the issues, it helped with gaining a better understanding of the cause. |
@rajinder-yadav Hi, we have updated the Note we still need to add the following config to acknowledge the commonJS dependencies
I will close the issue for now, but let me know if you have further question. |
@hkjpotato great work, thanks for the fix! |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
I am making use of Cognito in my Angular 12 app, including the following
I am seeing the following messages in my Angular 12 app:
My question is why is a Node.js include being used for a frontend browser app, (I believe) this is causing problems with Webpack 5.
Expected behavior
Angular 12 app should build with any warning message using the Cognito npm module
Reproduction steps
Create a Angular 12 app
install npm module amazon-cognito-identity-js
code a simple registration page
build the app and see tons of build warnings
using the following for reference code: https://github.com/aws-amplify/amplify-js/tree/main/packages/amazon-cognito-identity-js
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: