-
Notifications
You must be signed in to change notification settings - Fork 66
/
rollup.benchmark.js
92 lines (85 loc) · 2.31 KB
/
rollup.benchmark.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
82
83
84
85
86
87
88
89
90
91
92
// Bundle for the benchmarking app
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import compiler from '@ampproject/rollup-plugin-closure-compiler';
import { terser } from 'rollup-plugin-terser';
import url from 'rollup-plugin-url';
import json from 'rollup-plugin-json';
import serve from 'rollup-plugin-serve';
import bundleSize from 'rollup-plugin-bundle-size';
import postcss from 'rollup-plugin-postcss';
import copy from 'rollup-plugin-copy-glob';
import pkg from './package.json';
const babelPluginConfig = {
// https://github.com/webpack/webpack/issues/2031#issuecomment-219040479
exclude: [/node_modules\/(?!(shared-gb)\/).*/],
plugins: [
['@babel/plugin-proposal-class-properties'],
['@babel/plugin-proposal-object-rest-spread'],
['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
['@babel/plugin-proposal-export-default-from']
]
};
let plugins = [
postcss({
extensions: ['.css']
}),
resolve({
preferBuiltins: false
}),
babel(babelPluginConfig),
commonjs(),
json(),
url({
limit: 1000000 * 1024, // Always inline
include: ['**/*.gb', '**/*.gbc', '**/*.png', '**/*.wasm'],
// Don't emit files, this will replace the worker build output
emitFiles: false
})
];
let sourcemap = false;
if (process.env.BENCHMARK && process.env.SERVE) {
plugins = [
...plugins,
serve({
contentBase: ['dist/', 'build/benchmark/', 'demo/benchmark/', 'demo/debugger/'],
port: 8080
})
];
sourcemap = 'inline';
} else {
// Not running through closure to show difference between
// Closure and non closure.
plugins = [
...plugins,
copy([
{
files: 'demo/debugger/assets/**/*',
dest: 'build/benchmark/assets'
},
{
files: 'demo/benchmark/index.html',
dest: 'build/benchmark/'
}
]),
// TODO: Compiler gives Out of memory errors in node :(
// compiler()
terser()
];
}
plugins = [...plugins, bundleSize()];
const benchmarkBundles = [
{
input: 'demo/benchmark/index.js',
output: {
name: 'WasmBoyBenchmark',
file: 'build/benchmark/index.iife.js',
format: 'iife',
sourcemap: sourcemap
},
context: 'window',
plugins: plugins
}
];
export default benchmarkBundles;