Skip to content

Commit bcbe5e0

Browse files
authored
Add usage instructions for Webpack 5 (#455)
1 parent 07462e1 commit bcbe5e0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ Note that `require('stream')` will return `Stream`, while
7676
whatever is exported directly, but rather use one of the properties as
7777
shown in the example above.
7878

79+
## Usage In Browsers
80+
81+
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:
82+
83+
1. Install polyfills by running `npm install buffer process --save-dev`
84+
2. Create a [`webpack.config.js`](https://webpack.js.org/guides/getting-started/#using-a-configuration) file containing:
85+
86+
```js
87+
const webpack = require('webpack')
88+
89+
module.exports = {
90+
plugins: [
91+
new webpack.ProvidePlugin({
92+
process: 'process/browser'
93+
})
94+
],
95+
resolve: {
96+
fallback: {
97+
buffer: require.resolve('buffer/')
98+
}
99+
}
100+
}
101+
```
102+
79103
# Streams Working Group
80104

81105
`readable-stream` is maintained by the Streams Working Group, which

0 commit comments

Comments
 (0)