From def6ae38cb2e1c09a0511e85d43f73cc55e0e47d Mon Sep 17 00:00:00 2001 From: bergi Date: Mon, 21 Nov 2022 11:43:01 +0100 Subject: [PATCH] fix: use workaround loading process-shim for browserify --- README.md | 22 +--------------------- build/headers.mjs | 2 +- lib/internal/streams/destroy.js | 2 +- lib/internal/streams/duplexify.js | 2 +- lib/internal/streams/end-of-stream.js | 2 +- lib/internal/streams/from.js | 2 +- lib/internal/streams/pipeline.js | 2 +- lib/internal/streams/readable.js | 2 +- lib/internal/streams/writable.js | 2 +- process | 3 --- 10 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 process diff --git a/README.md b/README.md index 14c541325..8f76a7729 100644 --- a/README.md +++ b/README.md @@ -87,27 +87,7 @@ shown in the example above. ## Usage In Browsers -You will need a bundler like [`browserify`](https://github.com/browserify/browserify#readme), [`webpack`](https://webpack.js.org/), [`parcel`](https://github.com/parcel-bundler/parcel#readme) or similar. With Webpack 5 (which unlike other bundlers does not polyfill Node.js core modules and globals like `process`) you will also need to: - -1. Install polyfills by running `npm install buffer process --save-dev` -2. Create a [`webpack.config.js`](https://webpack.js.org/guides/getting-started/#using-a-configuration) file containing: - -```js -const webpack = require('webpack') - -module.exports = { - plugins: [ - new webpack.ProvidePlugin({ - process: 'process/browser' - }) - ], - resolve: { - fallback: { - buffer: require.resolve('buffer/') - } - } -} -``` +You will need a bundler like [`browserify`](https://github.com/browserify/browserify#readme), [`webpack`](https://webpack.js.org/), [`parcel`](https://github.com/parcel-bundler/parcel#readme) or similar. Polyfills are no longer required since version 4.2.0. # Streams Working Group diff --git a/build/headers.mjs b/build/headers.mjs index 0a8d92c34..9f056aea0 100644 --- a/build/headers.mjs +++ b/build/headers.mjs @@ -9,7 +9,7 @@ const bufferRequire = ` const processRequire = ` /* replacement start */ - const process = require('process') + const process = require('process/') /* replacement end */ ` diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js index dfcbddf12..768f2d79d 100644 --- a/lib/internal/streams/destroy.js +++ b/lib/internal/streams/destroy.js @@ -2,7 +2,7 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ diff --git a/lib/internal/streams/duplexify.js b/lib/internal/streams/duplexify.js index 4d74b18e0..43300ddc8 100644 --- a/lib/internal/streams/duplexify.js +++ b/lib/internal/streams/duplexify.js @@ -1,6 +1,6 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index b8456988a..57dbaa48a 100644 --- a/lib/internal/streams/end-of-stream.js +++ b/lib/internal/streams/end-of-stream.js @@ -1,6 +1,6 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ // Ported from https://github.com/mafintosh/end-of-stream with diff --git a/lib/internal/streams/from.js b/lib/internal/streams/from.js index 2b3a8411b..c7e753140 100644 --- a/lib/internal/streams/from.js +++ b/lib/internal/streams/from.js @@ -2,7 +2,7 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index d5392fa59..016e96ee6 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -1,6 +1,6 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ // Ported from https://github.com/mafintosh/pump with diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index b800ee3c2..3fc01d1f8 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -1,6 +1,6 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ // Copyright Joyent, Inc. and other Node contributors. diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js index 15136e06d..8a2800346 100644 --- a/lib/internal/streams/writable.js +++ b/lib/internal/streams/writable.js @@ -1,6 +1,6 @@ /* replacement start */ -const process = require('process') +const process = require('process/') /* replacement end */ // Copyright Joyent, Inc. and other Node contributors. diff --git a/process b/process deleted file mode 100644 index 7e2eb9531..000000000 --- a/process +++ /dev/null @@ -1,3 +0,0 @@ -// workaround for browserify bug: https://github.com/browserify/browserify/issues/1986 - -module.exports = require('./node_modules/process')