-
Notifications
You must be signed in to change notification settings - Fork 66
/
rollup.core.js
81 lines (70 loc) · 1.86 KB
/
rollup.core.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
70
71
72
73
74
75
76
77
78
79
80
81
// Rollup Config for our Core TS Builds
import typescript from 'rollup-plugin-typescript';
import babel from 'rollup-plugin-babel';
import bundleSize from 'rollup-plugin-bundle-size';
// TODO(torch2424), write a file in core/portable/instantiateWasm.js
// That simply gives back our wasmInstance and WasmByte Memory already instantiated
// That way it will be as if we got the Core directly from JS like the TS build.
// Rename core.*.js to core.ts.*.js, and follow same for wasm
// Fs for some extra needed files
const fs = require('fs');
let typescriptPluginOptions = {
tsconfig: './core/tsconfig.json'
};
if (process.env.ES_NEXT) {
typescriptPluginOptions = {
...typescriptPluginOptions,
target: 'ESNext'
};
}
let plugins = [typescript(typescriptPluginOptions)];
let sourcemap = 'inline';
if (process.env.PROD) {
sourcemap = false;
}
if (!process.env.ES_NEXT) {
plugins = [...plugins, babel()];
}
plugins = [...plugins, bundleSize()];
const coreTsBundles = [
{
input: './core/index.ts',
output: {
banner: () => {
return fs.readFileSync('./core/portable/wasmMock.js', 'utf8');
},
file: `dist/core/core.esm.js`,
format: 'esm',
name: 'WasmBoyCore',
sourcemap: sourcemap
},
plugins: plugins
},
{
input: './core/index.ts',
output: {
banner: () => {
return fs.readFileSync('./core/portable/wasmMock.js', 'utf8');
},
file: `dist/core/core.umd.js`,
format: 'umd',
name: 'WasmBoyCore',
sourcemap: sourcemap
},
plugins: plugins
},
{
input: './core/index.ts',
output: {
banner: () => {
return fs.readFileSync('./core/portable/wasmMock.js', 'utf8');
},
file: `dist/core/core.cjs.js`,
format: 'cjs',
name: 'WasmBoyCore',
sourcemap: sourcemap
},
plugins: plugins
}
];
export default coreTsBundles;