Skip to content

Commit 42d8960

Browse files
committed
Added support for esnext TS Core output
1 parent 2a5506f commit 42d8960

File tree

3 files changed

+50
-19
lines changed

3 files changed

+50
-19
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"lib:build:wasm": "npx rollup -c --environment PROD,WASM",
5656
"lib:watch:ts": "npx rollup -c -w --environment TS",
5757
"lib:build:ts": "npx rollup -c --environment PROD,TS",
58+
"lib:build:ts:esnext": "npx rollup -c --environment PROD,TS,ES_NEXT",
5859
"lib:deploy": "npx run-s core:build lib:build:wasm lib:build:ts lib:deploy:np",
5960
"lib:deploy:np": "npx np",
6061
"test": "npm run test:accuracy",

rollup.core.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,30 @@ import bundleSize from 'rollup-plugin-bundle-size';
1212
// Fs for some extra needed files
1313
const fs = require('fs');
1414

15-
const plugins = [
16-
typescript({
17-
tsconfig: './core/tsconfig.json'
18-
}),
19-
babel(),
20-
bundleSize()
21-
];
15+
let typescriptPluginOptions = {
16+
tsconfig: './core/tsconfig.json'
17+
};
18+
19+
if (process.env.ES_NEXT) {
20+
typescriptPluginOptions = {
21+
...typescriptPluginOptions,
22+
target: 'ESNext'
23+
};
24+
}
25+
26+
let plugins = [typescript(typescriptPluginOptions)];
2227

2328
let sourcemap = 'inline';
2429
if (process.env.PROD) {
2530
sourcemap = false;
2631
}
2732

33+
if (!process.env.ES_NEXT) {
34+
plugins = [...plugins, babel()];
35+
}
36+
37+
plugins = [...plugins, bundleSize()];
38+
2839
const coreTsBundles = [
2940
{
3041
input: './core/index.ts',

rollup.getcore.js

+31-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import bundleSize from 'rollup-plugin-bundle-size';
1414
import pkg from './package.json';
1515

1616
// Our base plugins needed by every bundle type
17-
const plugins = [
17+
let plugins = [
1818
resolve(), // so Rollup can find node modules
1919
commonjs(),
2020
json(),
@@ -23,32 +23,51 @@ const plugins = [
2323
include: ['**/*.wasm'],
2424
// Don't emit files, this will replace the worker build output
2525
emitFiles: false
26-
}),
27-
babel({
28-
// so Rollup can convert unsupported es6 code to es5
29-
exclude: ['node_modules/**'],
30-
plugins: [['@babel/plugin-proposal-class-properties'], ['@babel/plugin-proposal-object-rest-spread']]
31-
}),
32-
bundleSize()
26+
})
3327
];
3428

29+
if (!process.env.ES_NEXT) {
30+
plugins = [
31+
...plugins,
32+
babel({
33+
// so Rollup can convert unsupported es6 code to es5
34+
exclude: ['node_modules/**'],
35+
plugins: [['@babel/plugin-proposal-class-properties'], ['@babel/plugin-proposal-object-rest-spread']]
36+
})
37+
];
38+
}
39+
40+
plugins = [...plugins, bundleSize()];
41+
3542
// Array of bundles to make
3643
const bundleMap = [];
3744

3845
if (process.env.WASM) {
39-
bundleMap.push({
46+
let bundleMapObject = {
4047
name: 'WasmBoyWasmCore',
4148
input: 'core/portable/getWasmCore.js',
4249
output: 'dist/core/getWasmBoyWasmCore'
43-
});
50+
};
51+
52+
if (process.env.ES_NEXT) {
53+
bundleMapObject.output = 'dist/core/getWasmBoyWasmCore.esnext';
54+
}
55+
56+
bundleMap.push(bundleMapObject);
4457
}
4558

4659
if (process.env.TS) {
47-
bundleMap.push({
60+
let bundleMapObject = {
4861
name: 'WasmBoyTsCore',
4962
input: 'core/portable/getTsCore.js',
5063
output: 'dist/core/getWasmBoyTsCore'
51-
});
64+
};
65+
66+
if (process.env.ES_NEXT) {
67+
bundleMapObject.output = 'dist/core/getWasmBoyTsCore.esnext';
68+
}
69+
70+
bundleMap.push(bundleMapObject);
5271
}
5372

5473
const getCoreBundles = [];

0 commit comments

Comments
 (0)