Skip to content

Commit 0c518f5

Browse files
lobsterkatieAbhiPrasad
authored andcommitted
ref(build): Use sucrase for es6 bundles (#5111)
This switches the building of our es6 CDN bundles to use sucrase instead of `tsc` (or, more accurately, to use the sucrase rollup plugin rather than the typescript rollup plugin), in order both to build more quickly (in a time trial of multiple runs on GHA, this change brings the average `yarn build` run down from ~8 minutes to ~4 minutes) and to ensure that we have exact code parity between our CDN bundles and our npm packages. Because sucrase doesn't down-compile the way `tsc` will, the building of the es5 bundles hasn't been changed, and that build still uses the typescript plugin.
1 parent 5530cf3 commit 0c518f5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

rollup/bundleHelpers.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
makeIsDebugBuildPlugin,
1212
makeLicensePlugin,
1313
makeNodeResolvePlugin,
14+
makeRemoveBlankLinesPlugin,
15+
makeRemoveESLintCommentsPlugin,
16+
makeSucrasePlugin,
1417
makeTerserPlugin,
1518
makeTSPlugin,
1619
} from './plugins/index.js';
@@ -20,6 +23,9 @@ export function makeBaseBundleConfig(options) {
2023
const { input, isAddOn, jsVersion, licenseTitle, outputFileBase } = options;
2124

2225
const nodeResolvePlugin = makeNodeResolvePlugin();
26+
const sucrasePlugin = makeSucrasePlugin();
27+
const removeBlankLinesPlugin = makeRemoveBlankLinesPlugin();
28+
const removeESLintCommentsPlugin = makeRemoveESLintCommentsPlugin();
2329
const markAsBrowserBuildPlugin = makeBrowserBuildPlugin(true);
2430
const licensePlugin = makeLicensePlugin(licenseTitle);
2531
const tsPlugin = makeTSPlugin(jsVersion.toLowerCase());
@@ -75,7 +81,17 @@ export function makeBaseBundleConfig(options) {
7581
strict: false,
7682
esModule: false,
7783
},
78-
plugins: [tsPlugin, markAsBrowserBuildPlugin, nodeResolvePlugin, licensePlugin],
84+
plugins:
85+
jsVersion === 'es5'
86+
? [tsPlugin, markAsBrowserBuildPlugin, nodeResolvePlugin, licensePlugin]
87+
: [
88+
sucrasePlugin,
89+
removeBlankLinesPlugin,
90+
removeESLintCommentsPlugin,
91+
markAsBrowserBuildPlugin,
92+
nodeResolvePlugin,
93+
licensePlugin,
94+
],
7995
treeshake: 'smallest',
8096
};
8197

0 commit comments

Comments
 (0)