Skip to content

Commit 3a06dc9

Browse files
authored
fix: add node_module polyfills by defualt (#212)
Before: need to add stream and buffer libraries manually to webapck5 projects
1 parent d26d91b commit 3a06dc9

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"react-test-renderer": "^17.0.2",
114114
"rollup": "^2.53.1",
115115
"rollup-plugin-copy": "^3.4.0",
116+
"rollup-plugin-polyfill-node": "^0.10.1",
116117
"rollup-plugin-postcss": "^4.0.0",
117118
"rollup-plugin-scss": "^3.0.0",
118119
"rollup-plugin-size-snapshot": "^0.12.0",

rollup.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import replace from '@rollup/plugin-replace';
1111
import typescript from '@rollup/plugin-typescript';
1212
import autoprefixer from 'autoprefixer';
1313
import copy from 'rollup-plugin-copy';
14-
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
14+
import nodePolyfills from 'rollup-plugin-polyfill-node';
15+
// import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
1516

1617
// config from package.json
1718
import pkg from './package.json';
@@ -100,7 +101,9 @@ module.exports = ({
100101
preferBuiltins: true,
101102
}),
102103
commonjs(),
103-
sizeSnapshot(),
104+
nodePolyfills({
105+
include: ['buffer', 'stream']
106+
}),
104107
copy({
105108
verbose: true,
106109
targets: [

0 commit comments

Comments
 (0)