-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Angular & native crypto module #262
Comments
This is not a webpack issue only, seems other bundler do have the same problem. Here is the try to solve the React Native issue, which also has problems with creating a bundle. #259 Need to find a solution to get optional |
Interesting. Would this comment help by any chance? If the browserify trick makes sense, I can try it and let you know how it goes. |
(Cross-posted to StackOverflow for reach) |
Actually this one looks promising angular/angular-cli#1548 (comment) |
If you were to change
to
you would intersect with some webpack magic (unsure about other bundlers) and dead-code elimination would wipe out the entire if block and never execute the require, keeping it out of browser bundles (and similar to the inverse checks you are already doing). I'm not sure how this would work out for React-Native users; maybe they'd have to fall back to something like manually providing the crypto global?
And then you could provide another DCE bailout like Just spitballing with regard to the RN, but leaning into DCE is the best way to help browsers bundlers (really, anything using uglify or terser). |
I was able to fix this issue by running a postinstall script which fix the file ./node_modules/crypto-js/core.js. |
Sure, what does it look like? |
the same problem, any solution? |
You can use https://github.com/ds300/patch-package to remove the entire if-block containing the |
hi @merrywhether , yes this is what i did , but without using patch-package. https://github.com/ah584d/azure-sas-token/blob/master/angular/scripts/fixBugCryptoJsInAngular8.js |
same problem with Angular 9+, please fix this issue |
same problem with Angular9+. SOLUTION: downgrade to 3.3.0. it is working. |
works for me as well. |
Same issue for an Angular 9 project too. Downgrade works. Can you fix this issue to make it works properly? Maybe can we help you? |
I downgraded to 3.3.0 and I'm still getting these errors :(
and still seeing these warnings..
|
I had to do the same. I fixed that warnings with this: "allowedCommonJsDependencies": ["crypto-js"] inside the angular.json in the architect/build/options |
@marshall86 but that is just suppressing the warning right?.. and the bailout might still occur!? |
Not quite sure, didn't have any issue though, luckily :) |
I understand the move to 4.0.0 uses native crypto module.
As a result, with my Angular app, I get the error message below when building.
As I understand, the crypto module needs to be explicitly bundled by Webpack as it's not by default with Angular config.
Does anyone already know how to do that? I'm not that familiar with Webpack and would appreciate any hint.
The text was updated successfully, but these errors were encountered: