-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
rollup.config.js
38 lines (34 loc) · 986 Bytes
/
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
import fs from 'fs';
import replace from '@rollup/plugin-replace';
import path from 'path';
const version = JSON.parse(fs.readFileSync('package.json')).version;
export default [
config(true, false),
config(false, false),
config(false, true),
];
function config (isWasm, isDebug) {
const name = 'es-module-shims'
return {
input: `src/${name}.js`,
output: {
file: `dist/${name}${isWasm ? '.wasm' : ''}${isDebug ? '.debug' : ''}.js`,
format: 'iife',
strict: false,
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
}),
]
};
}