Skip to content

Commit 4d400d6

Browse files
committed
feat(build): Allow passing Sucrase options for rollup
This allows you to configure Sucrase for rollup bundles. Needed for our work on the Feedback screenshotting feature as we want to use Preact + JSX in the project. (ref: #10590)
1 parent 3e2c8f4 commit 4d400d6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

dev-packages/rollup-utils/bundleHelpers.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import { mergePlugins } from './utils.mjs';
2525
const BUNDLE_VARIANTS = ['.js', '.min.js', '.debug.min.js'];
2626

2727
export function makeBaseBundleConfig(options) {
28-
const { bundleType, entrypoints, jsVersion, licenseTitle, outputFileBase, packageSpecificConfig } = options;
28+
const { bundleType, entrypoints, jsVersion, licenseTitle, outputFileBase, packageSpecificConfig, sucrase } = options;
2929

3030
const isEs5 = jsVersion.toLowerCase() === 'es5';
3131

3232
const nodeResolvePlugin = makeNodeResolvePlugin();
33-
const sucrasePlugin = makeSucrasePlugin();
33+
const sucrasePlugin = makeSucrasePlugin(sucrase);
3434
const cleanupPlugin = makeCleanupPlugin();
3535
const markAsBrowserBuildPlugin = makeBrowserBuildPlugin(true);
3636
const licensePlugin = makeLicensePlugin(licenseTitle);

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ export function makeBaseNPMConfig(options = {}) {
2828
hasBundles = false,
2929
packageSpecificConfig = {},
3030
addPolyfills = true,
31+
sucrase = {},
3132
} = options;
3233

3334
const nodeResolvePlugin = makeNodeResolvePlugin();
34-
const sucrasePlugin = makeSucrasePlugin({ disableESTransforms: !addPolyfills });
35+
const sucrasePlugin = makeSucrasePlugin({ disableESTransforms: !addPolyfills, ...sucrase });
3536
const debugBuildStatementReplacePlugin = makeDebugBuildStatementReplacePlugin();
3637
const cleanupPlugin = makeCleanupPlugin();
3738
const extractPolyfillsPlugin = makeExtractPolyfillsPlugin();

0 commit comments

Comments
 (0)