Skip to content

Commit 35df87d

Browse files
timfishlogaretm
authored andcommitted
chore(build): Use Rolldown
1 parent ad0ce51 commit 35df87d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+225
-176
lines changed

dev-packages/node-core-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"scripts": {
1313
"build": "run-s build:transpile build:types",
1414
"build:dev": "yarn build",
15-
"build:transpile": "rollup -c rollup.npm.config.mjs",
15+
"build:transpile": "rolldown -c rollup.npm.config.mjs",
1616
"build:types": "tsc -p tsconfig.types.json",
1717
"clean": "rimraf -g **/node_modules && run-p clean:script",
1818
"clean:script": "node scripts/clean.js",

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"scripts": {
1313
"build": "run-s build:transpile build:types",
1414
"build:dev": "yarn build",
15-
"build:transpile": "rollup -c rollup.npm.config.mjs",
15+
"build:transpile": "rolldown -c rollup.npm.config.mjs",
1616
"build:types": "tsc -p tsconfig.types.json",
1717
"clean": "rimraf -g suites/**/node_modules suites/**/tmp_* && run-p clean:script",
1818
"clean:script": "node scripts/clean.js",

dev-packages/rollup-utils/bundleHelpers.mjs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import deepMerge from 'deepmerge';
99
import {
1010
makeBrowserBuildPlugin,
1111
makeCleanupPlugin,
12-
makeCommonJSPlugin,
1312
makeIsDebugBuildPlugin,
1413
makeLicensePlugin,
15-
makeNodeResolvePlugin,
1614
makeRrwebBuildPlugin,
1715
makeSetSDKSourcePlugin,
1816
makeSucrasePlugin,
@@ -26,7 +24,6 @@ const BUNDLE_VARIANTS = ['.js', '.min.js', '.debug.min.js'];
2624
export function makeBaseBundleConfig(options) {
2725
const { bundleType, entrypoints, licenseTitle, outputFileBase, packageSpecificConfig, sucrase } = options;
2826

29-
const nodeResolvePlugin = makeNodeResolvePlugin();
3027
const sucrasePlugin = makeSucrasePlugin({}, sucrase);
3128
const cleanupPlugin = makeCleanupPlugin();
3229
const markAsBrowserBuildPlugin = makeBrowserBuildPlugin(true);
@@ -37,11 +34,6 @@ export function makeBaseBundleConfig(options) {
3734
});
3835
const productionReplacePlugin = makeProductionReplacePlugin();
3936

40-
// The `commonjs` plugin is the `esModuleInterop` of the bundling world. When used with `transformMixedEsModules`, it
41-
// will include all dependencies, imported or required, in the final bundle. (Without it, CJS modules aren't included
42-
// at all, and without `transformMixedEsModules`, they're only included if they're imported, not if they're required.)
43-
const commonJSPlugin = makeCommonJSPlugin({ transformMixedEsModules: true });
44-
4537
// used by `@sentry/browser`
4638
const standAloneBundleConfig = {
4739
output: {
@@ -93,7 +85,7 @@ export function makeBaseBundleConfig(options) {
9385
output: {
9486
format: 'esm',
9587
},
96-
plugins: [commonJSPlugin, makeTerserPlugin(), licensePlugin],
88+
plugins: [makeTerserPlugin(), licensePlugin],
9789
// Don't bundle any of Node's core modules
9890
external: builtinModules,
9991
};
@@ -102,7 +94,7 @@ export function makeBaseBundleConfig(options) {
10294
output: {
10395
format: 'esm',
10496
},
105-
plugins: [commonJSPlugin, makeIsDebugBuildPlugin(true), makeTerserPlugin()],
97+
plugins: [makeIsDebugBuildPlugin(true), makeTerserPlugin()],
10698
// Don't bundle any of Node's core modules
10799
external: builtinModules,
108100
};
@@ -118,7 +110,7 @@ export function makeBaseBundleConfig(options) {
118110
strict: false,
119111
esModule: false,
120112
},
121-
plugins: [productionReplacePlugin, sucrasePlugin, nodeResolvePlugin, cleanupPlugin],
113+
plugins: [sucrasePlugin, cleanupPlugin],
122114
treeshake: 'smallest',
123115
};
124116

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { defineConfig } from 'rollup';
1515
import {
1616
makeCleanupPlugin,
1717
makeDebugBuildStatementReplacePlugin,
18-
makeNodeResolvePlugin,
1918
makeProductionReplacePlugin,
2019
makeRrwebBuildPlugin,
2120
makeSucrasePlugin,
@@ -38,7 +37,6 @@ export function makeBaseNPMConfig(options = {}) {
3837
bundledBuiltins = [],
3938
} = options;
4039

41-
const nodeResolvePlugin = makeNodeResolvePlugin();
4240
const sucrasePlugin = makeSucrasePlugin({}, sucrase);
4341
const debugBuildStatementReplacePlugin = makeDebugBuildStatementReplacePlugin();
4442
const cleanupPlugin = makeCleanupPlugin();
@@ -59,9 +57,6 @@ export function makeBaseNPMConfig(options = {}) {
5957
// Include __esModule property when there is a default prop
6058
esModule: 'if-default-prop',
6159

62-
// output individual files rather than one big bundle
63-
preserveModules: true,
64-
6560
// Allow wrappers or helper functions generated by rollup to use any ES2015 features
6661
generatedCode: {
6762
preset: 'es2015',
@@ -97,7 +92,7 @@ export function makeBaseNPMConfig(options = {}) {
9792
},
9893
},
9994

100-
plugins: [nodeResolvePlugin, sucrasePlugin, debugBuildStatementReplacePlugin, rrwebBuildPlugin, cleanupPlugin],
95+
plugins: [sucrasePlugin, debugBuildStatementReplacePlugin, rrwebBuildPlugin, cleanupPlugin],
10196

10297
// don't include imported modules from outside the package in the final output
10398
external: [

dev-packages/rollup-utils/plugins/bundlePlugins.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import * as childProcess from 'child_process';
1212

13-
import commonjs from '@rollup/plugin-commonjs';
14-
import { nodeResolve } from '@rollup/plugin-node-resolve';
1513
import replace from '@rollup/plugin-replace';
1614
import terser from '@rollup/plugin-terser';
1715
import license from 'rollup-plugin-license';
@@ -146,12 +144,3 @@ export function makeTerserPlugin() {
146144
},
147145
});
148146
}
149-
150-
// We don't pass these plugins any options which need to be calculated or changed by us, so no need to wrap them in
151-
// another factory function, as they are themselves already factory functions.
152-
153-
export function makeNodeResolvePlugin() {
154-
return nodeResolve();
155-
}
156-
157-
export { commonjs as makeCommonJSPlugin };

dev-packages/rollup-utils/plugins/make-esm-plugin.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from 'node:fs';
2+
import path from 'node:path';
23

34
/**
45
* Outputs a package.json file with {type: module} in the root of the output directory so that Node
@@ -11,9 +12,7 @@ export function makePackageNodeEsm() {
1112
// We need to keep the `sideEffects` value from the original package.json,
1213
// as e.g. webpack seems to depend on this
1314
// without this, tree shaking does not work as expected
14-
const packageJSONPath = (await this.resolve('package.json')).id;
15-
16-
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
15+
const packageJSON = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './package.json'), { encoding: 'utf8' }));
1716
const sideEffects = packageJSON.sideEffects;
1817
// For module federation we need to keep the version of the package
1918
const version = packageJSON.version;

dev-packages/rollup-utils/plugins/npmPlugins.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ export function makeSucrasePlugin(options = {}, sucraseOptions = {}) {
3838
);
3939
}
4040

41-
export function makeJsonPlugin() {
42-
return json();
43-
}
44-
4541
/**
4642
* Create a plugin which can be used to pause the build process at the given hook.
4743
*

dev-packages/test-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"build": "run-s build:transpile build:types",
3737
"build:tarball": "run-s build:transpile build:types",
3838
"build:dev": "yarn build",
39-
"build:transpile": "rollup -c rollup.npm.config.mjs",
39+
"build:transpile": "rolldown -c rollup.npm.config.mjs",
4040
"build:types": "tsc -p tsconfig.types.json",
4141
"clean": "rimraf -g ./node_modules ./build"
4242
},

dev-packages/test-utils/rollup.npm.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default makeNPMConfigVariants(
66
output: {
77
// set exports to 'named' or 'auto' so that rollup doesn't warn
88
exports: 'named',
9-
preserveModules: false,
109
},
1110
},
1211
}),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"prettier": "^3.6.2",
131131
"prettier-plugin-astro": "^0.14.1",
132132
"rimraf": "^5.0.10",
133-
"rollup": "^4.35.0",
133+
"rolldown": "^1.0.0-beta.45",
134134
"rollup-plugin-cleanup": "^3.2.1",
135135
"rollup-plugin-license": "^3.3.1",
136136
"size-limit": "~11.1.6",

0 commit comments

Comments
 (0)