parse-asn1
parse-asn1 copied to clipboard
"Module not found" in latest release (5.1.7)
Can't build the app anymore after your last release:
Module not found: Error: Can't resolve 'vm' in '~/app/node_modules/asn1.js/lib/asn1' @ ./node_modules/asn1.js/lib/asn1.js 5:14-42 @ ./node_modules/parse-asn1/asn1.js 6:11-29 @ ./node_modules/parse-asn1/index.js 3:11-28 @ ./node_modules/browserify-sign/browser/sign.js 9:16-37 @ ./node_modules/browserify-sign/browser/index.js 7:11-28 @ ./node_modules/crypto-browserify/index.js 39:11-37
Looks like problem is here: https://github.com/browserify/parse-asn1/commit/f23087045497c93bd0a151e29b1e3f738e898cb8
vm is a node core module; presumably your bundler is failing to properly handle node core modules in its browser build?
Yes, bundler is webpack 5, and it requires to add fallback: vm: require.resolve("vm-browserify"). Now i've added this fallback, and got new crash: Uncaught TypeError: Cannot read properties of undefined (reading 'slice') at ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js (_stream_writable.js:57:72)
Unfortunately webpack 5 decided to stop being a working node core module bundler by default. You'll have to manually configure a bunch of replacements. https://web3auth.io/docs/troubleshooting/webpack-issues#react-create-react-app has an example config that may prove useful.
Specifically, the readable-stream issue is that process.version isn't a string - but https://unpkg.com/[email protected]/lib/_stream_writable.js shows that if your bundler replaces process.browser with true, and then does dead code elimination, that entire line after && would be deleted and wouldn't run.
but guys, 5.1.7 causes problems in live projects, when 5.1.6 was perfectly worknig. Isn't it a reason to revert this commit?
@VasylBoyko again, unfortunately, sometimes bugfixes (which this one was) can still break people (obligatory xkcd 1172). i can't conceive of an application, including a RN one, where you wouldn't need to configure webpack and/or metro to properly and implicitly handle node globals and core modules, so I continue to be surprised people run into this.