-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathrollup.config.mjs
38 lines (35 loc) · 1.06 KB
/
rollup.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import commonjs from '@rollup/plugin-commonjs';
import inject from '@rollup/plugin-inject';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
export default (commandLineArgs) => {
const sourcemap = (commandLineArgs.sourceMap || 'true') == 'true';
// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
delete commandLineArgs.sourceMap;
return {
input: 'lib/index.js',
output: {
file: 'dist/bundle.mjs',
format: 'esm',
sourcemap: sourcemap
},
plugins: [
json(),
nodeResolve({ preferBuiltins: false, browser: true }),
commonjs({}),
inject({
Buffer: ['buffer', 'Buffer'],
ReadableStream: ['web-streams-polyfill/ponyfill', 'ReadableStream'],
// Used by can-ndjson-stream
TextDecoder: ['text-encoding', 'TextDecoder']
}),
terser()
],
// This makes life easier
external: [
// This has dynamic logic - makes bundling hard
'cross-fetch'
]
};
};