-
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
Because you write require("crypto"), use in Browser Webpack Bundle will inject more than 400kb node-browser code include bundle #276
Comments
same question... |
same here, rollback to v3.3.0. |
If the issues caused by secure radom of crypto-js 4.0 bother you, such as too large bundle, unavalible in React Native... Maybe you can try crypto-es . We merged all updates of crypto-js 4.0 except the secure radom. |
@evanvosberg If I understand correctly, tree shaking capability of webpack can reduce the size of final build if this library Edit: I guess it's only that the entire codebase is not on ES... |
Does anyone solved this problem yet? i solved it by using |
@rahulbhadhoriya yes, using crypto-js 3.1.9-1, crypto-js 4.0 about for NodeJS |
Thanks for this! |
const isBrowser = typeof window !== 'undefined' && window.hasOwnProperty('Window') && window instanceof window.Window;
const crypto = isBrowser ? window.crypto : eval(`require('crypto')`); When bundle is building it doesn't consider imports from eval method (I tryed webpack). This means that output bundle will not contain |
If you use webpack to compile the file, you can add configuration to webpack.config.js node = {
crypto: false,
} |
It seems most of the concerns come from the fact that webpack will recognize the While as a library consumer, we can update webpack config to add Let's say we build package A which depends on
If the customer uses webpack to bundle its Instead, I am thinking if we can just use a trick in the
This way, node can still recognize it, but webpack won't try to resolve it since it is not a static path. |
decimal.js has encountered similar issue before, might be helpful. |
Hi, can you please share your webpack configuration? I am a little confused as to where to use it |
you can see https://v4.webpack.js.org/configuration/node/#root |
I guess this is already solved in the latest version v4.1.1? I'm using that one and don't face any of these issues anymore. |
in crypto-js/core.js
this lib can not use in the browser, because the polyfill is so big more than 400kb with webpack bundle
The text was updated successfully, but these errors were encountered: