-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
55 lines (53 loc) · 1.79 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
import terser from "@rollup/plugin-terser";
import copy from 'rollup-plugin-copy';
import typescript from "rollup-plugin-typescript2";
import { readFileSync } from "fs";
// Just want to override tslib from the rollup-plugin-typescript2
const tslib = readFileSync("./src/tslib.js", "utf-8");
export default {
input: 'src/index.ts',
output: [
{
file: './build/bundle.min.mjs',
format: 'esm',
sourcemap: true,
freeze: false
},
...(process.env.FULL ? [
{
file: './build/bundle.min.cjs',
format: 'commonjs',
sourcemap: true,
freeze: false
}, {
name: '__IteratorHelpersPolyfill',
file: './build/bundle.min.js',
format: 'umd',
sourcemap: true,
freeze: false
}
] : [])
],
plugins: [
Object.defineProperty(typescript(), "load", { value: x => x === "\0tslib.js" ? tslib : null }),
terser({
format: { comments: false },
mangle: {
properties: {
builtins: true,
regex: /^(?:fn|minimal|results|rejected|lastValue|initializer|methods|fields|positions|index|start|_(?:[^_]\w+)?)$/m
},
reserved: ['AsyncIterator', 'Iterator', 'Config']
},
compress: { unsafe: true }
}),
...(process.env.FULL ? [
copy({
targets: [
{ src: 'declarations/index.d.ts', dest: 'declarations', rename: 'index.d.cts' },
{ src: 'declarations/index.d.ts', dest: 'declarations', rename: 'index.d.mts' },
]
})
] : [])
]
};