-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
39 lines (36 loc) · 1.01 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
import fs from 'fs';
import path from 'path';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
const version = JSON.parse(fs.readFileSync('package.json')).version;
export default [
config(true, false),
config(false, false),
config(false, true),
];
function config (isWasm, isDebug) {
return {
input: `src/index.js`,
output: {
file: `dist/index${isWasm ? '.wasm' : ''}${isDebug ? '.debug' : ''}.js`,
format: "esm",
sourcemap: false,
banner: `/* ES Module Shims ${isWasm ? 'Wasm ' : ''}${isDebug ? 'DEBUG BUILD ' : ''}${version} */`
},
plugins: [
{
resolveId (id) {
if (isWasm && id === '../node_modules/es-module-lexer/dist/lexer.asm.js')
return path.resolve('node_modules/es-module-lexer/dist/lexer.js');
}
},
replace({
'self.ESMS_DEBUG': isDebug.toString(),
preventAssignment: true
}),
...(!isWasm && !isDebug ? [
terser()
] : []),
]
};
}