Falso attempts to import the built-in Node.js crypto
module in the browser
#371
srmagura
started this conversation in
Show and tell
Replies: 1 comment
-
Root CauseThe line of code that is causing the problem is in the Since the How to Silence the WarningWebpackIf using Webpack, put this in your resolve: {
/* ... */
fallback: {
// For falso. This tells Webpack to not include a polyfill (since their
// bundle sizes are massive)
crypto: false,
stream: false,
},
}, ViteIf using Vite, create a file called // See `vite.config.ts` for why this exists
export {}; Then, add this to your resolve: {
alias: {
crypto: 'src/emptyModule.ts',
},
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is this a regression?
No
Description
If you import any function from Falso in the browser, you'll get a warning similar to the following from your bundler:
It happens because Falso or one of its dependencies is attempting to import the
crypto
module. This module is part of Node.js and is not available in the browser.You can work around the issue by aliasing
crypto
to a polyfill like crypto-browserify. But this is not recommended because that polyfill is very large.Please provide a link to a minimal reproduction of the bug
https://github.com/srmagura/falso-crypto-repro
Please provide the exception or error you saw
Please provide the environment you discovered this bug in
Anything else?
I did a quick search in the Falso codebase, and it seems that Falso itself is not importing
crypto
. So it must be one of Falso's dependencies that is importing it.Do you want to create a pull request?
Yes
Beta Was this translation helpful? Give feedback.
All reactions