This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
forked from MattiasBuelens/web-streams-polyfill
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
69 lines (66 loc) · 1.94 KB
/
rollup.config.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const rollupDts = require('rollup-plugin-dts');
const rollupInject = require('rollup-plugin-inject');
const rollupStrip = require('rollup-plugin-strip');
const { terser: rollupTerser } = require('rollup-plugin-terser');
function buildConfig(entry, { esm = false, minify = false, es6 = false } = {}) {
const outname = `${entry}${es6 ? '.es6' : ''}`;
return {
input: `src/${entry}.ts`,
output: [
{
file: `dist/${outname}${minify ? '.min' : ''}.js`,
format: 'umd',
freeze: false,
sourcemap: true,
name: 'WebStreamsPolyfill'
},
esm ? {
file: `dist/${outname}${minify ? '.min' : ''}.mjs`,
format: 'es',
freeze: false,
sourcemap: true
} : undefined
].filter(Boolean),
plugins: [
rollupDts.js({
tsconfig: 'src/tsconfig.json',
target: es6 ? 'es2015' : 'es5'
}),
rollupInject({
include: 'src/**/*.ts',
exclude: 'src/stub/symbol.ts',
modules: {
Symbol: path.resolve(__dirname, './src/stub/symbol.ts')
}
}),
rollupStrip({
include: 'src/**/*.ts',
functions: ['assert', 'debug', 'verbose'],
sourceMap: true
}),
minify ? rollupTerser({
keep_classnames: true, // needed for WPT
mangle: {
toplevel: true
},
compress: {
inline: 1 // TODO re-enable when this is fixed: https://github.com/mishoo/UglifyJS2/issues/2842
},
sourcemap: true
}) : undefined
].filter(Boolean)
};
}
module.exports = [
// polyfill
buildConfig('polyfill', { esm: true }),
buildConfig('polyfill', { minify: true }),
// polyfill/es6
buildConfig('polyfill', { es6: true, esm: true }),
buildConfig('polyfill', { es6: true, minify: true }),
// ponyfill
buildConfig('ponyfill', { esm: true }),
// ponyfill/es6
buildConfig('ponyfill', { es6: true, esm: true })
];