Closed rybesh closed 1 year ago
Take a look at https://github.com/nodejs/readable-stream#usage-in-browsers
I'm not using Webpack 5, so I don't understand how that passage applies to my case.
cc @ShogunPanda
There are several issues here:
require('process')
instead of using a global: https://github.com/nodejs/readable-stream/blob/7fdb3b4ec5135e586d5c6695f7e08d04f268b1cb/lib/internal/streams/pipeline.js#L2require('process')
: https://github.com/browserify/browserify/issues/1986process
package always lives at ./node_modules/process
(i.e. that it's not hoisted): https://github.com/nodejs/readable-stream/blob/7fdb3b4ec5135e586d5c6695f7e08d04f268b1cb/process#L3files
declaration in package.json
that's missing the process
file: https://github.com/nodejs/readable-stream/blob/7fdb3b4ec5135e586d5c6695f7e08d04f268b1cb/package.json#L26-L30@ShogunPanda When you worked on this, did you try require('process/')
instead of require('process')
? If that works (for all bundlers) then we don't need the workaround.
It looks like the workaround with require('process/')
would work on Node.js and all bundlers.
I didn't use the workaround because I wanted to keep the Node.js behavior to directly load the internal process module. But it looks like the process-shim doesn't contain much logic, so I guess it would be ok to have this one additional require.
@bergos Ah, I see now that it's your code (https://github.com/nodejs/readable-stream/pull/489) rather than @ShogunPanda's. Sorry, I missed that PR. Side note: if bundler configuration is no longer required, then Usage In Browsers is outdated.
I'm not a fan of the general approach, but in the interest of moving forward, I vote for require('process/')
too.
I'm ok in adding the process-shim.
I am using N3.js which recently upgraded readable-stream from 3.6.0 to 4.0.0. Now I can no longer build my project using browserify; I get the following error: