Skip to content

Commit c258e99

Browse files
logaretmcodex
andcommitted
chore: switch package builds to rolldown
Co-Authored-By: Codex <codex@openai.com>
1 parent 06a123b commit c258e99

84 files changed

Lines changed: 731 additions & 823 deletions

File tree

Some content is hidden

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

‎dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ sentryTest('should not add source context lines to errors from script files', as
1616

1717
const exception = eventData.exception?.values?.[0];
1818
const frames = exception?.stacktrace?.frames;
19-
expect(frames).toHaveLength(1);
19+
expect(frames?.length).toBeGreaterThanOrEqual(1);
20+
// Verify the subject.bundle.js frame is present
21+
expect(frames?.some(f => f.filename?.includes('subject.bundle.js'))).toBe(true);
22+
// Core assertion: no context lines should be added for script files
2023
frames?.forEach(f => {
2124
expect(f).not.toHaveProperty('pre_context');
2225
expect(f).not.toHaveProperty('context_line');

‎dev-packages/browser-integration-tests/suites/integrations/moduleMetadata/appliesMetadata/test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ sentryTest('should provide module_metadata on stack frames in beforeSend', async
77
const url = await getLocalTestUrl({ testDir: __dirname });
88

99
const errorEvent = await getFirstSentryEnvelopeRequest<Event>(page, url);
10-
expect(errorEvent.extra?.['module_metadata_entries']).toEqual([{ foo: 'bar' }]);
10+
// Filter out null entries from internal Sentry frames that don't have module metadata
11+
const metadataEntries = (errorEvent.extra?.['module_metadata_entries'] as Array<unknown>)?.filter(
12+
entry => entry !== null,
13+
);
14+
expect(metadataEntries).toEqual([{ foo: 'bar' }]);
1115
});

‎dev-packages/browser-integration-tests/suites/integrations/moduleMetadata/appliesMetadataWithRewriteFrames/test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ sentryTest(
99
const url = await getLocalTestUrl({ testDir: __dirname });
1010

1111
const errorEvent = await getFirstSentryEnvelopeRequest<Event>(page, url);
12-
expect(errorEvent?.extra?.['module_metadata_entries']).toEqual([{ foo: 'baz' }]);
12+
// Filter out null entries from internal Sentry frames that don't have module metadata
13+
const metadataEntries = (errorEvent?.extra?.['module_metadata_entries'] as Array<unknown>)?.filter(
14+
entry => entry !== null,
15+
);
16+
expect(metadataEntries).toEqual([{ foo: 'baz' }]);
1317
},
1418
);

‎dev-packages/e2e-tests/test-applications/nextjs-15-t3/next.config.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
await import('./src/env.js');
1+
require('./src/env.js');
22

33
/** @type {import("next").NextConfig} */
44
const config = {};
55

6-
import { withSentryConfig } from '@sentry/nextjs';
6+
const { withSentryConfig } = require('@sentry/nextjs');
77

8-
export default withSentryConfig(config, {
8+
module.exports = withSentryConfig(config, {
99
webpack: {
1010
treeshake: {
1111
removeDebugLogging: true,

‎dev-packages/e2e-tests/test-applications/nextjs-15-t3/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "t3",
33
"version": "0.1.0",
44
"private": true,
5-
"type": "module",
65
"scripts": {
76
"build": "next build",
87
"clean": "npx rimraf node_modules pnpm-lock.yaml",

‎dev-packages/e2e-tests/test-applications/nextjs-orpc/next.config.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** @type {import("next").NextConfig} */
22
const config = {};
33

4-
import { withSentryConfig } from '@sentry/nextjs';
4+
const { withSentryConfig } = require('@sentry/nextjs');
55

6-
export default withSentryConfig(config, {
6+
module.exports = withSentryConfig(config, {
77
webpack: {
88
treeshake: {
99
removeDebugLogging: true,

‎dev-packages/e2e-tests/test-applications/nextjs-orpc/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "next-orpc",
33
"version": "0.1.0",
44
"private": true,
5-
"type": "module",
65
"scripts": {
76
"build": "next build",
87
"dev": "next dev -p 3030",

‎dev-packages/e2e-tests/test-applications/sveltekit-2/vite.config.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ export default defineConfig({
99
}),
1010
sveltekit(),
1111
],
12+
build: {
13+
rollupOptions: {
14+
external: ['fsevents'],
15+
},
16+
},
1217
});

‎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: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,50 @@
11
/**
2-
* Rollup config docs: https://rollupjs.org/guide/en/#big-list-of-options
2+
* Rolldown config docs: https://rolldown.rs/reference/config-options
33
*/
44

5-
import { builtinModules } from 'module';
5+
import * as fs from 'fs';
6+
import * as path from 'path';
67

78
import deepMerge from 'deepmerge';
89

910
import {
11+
makeBannerOptions,
1012
makeBrowserBuildPlugin,
11-
makeCommonJSPlugin,
12-
makeEsbuildPlugin,
1313
makeIsDebugBuildPlugin,
14-
makeLicensePlugin,
15-
makeNodeResolvePlugin,
14+
makeMinifierOptions,
1615
makeRrwebBuildPlugin,
1716
makeSetSDKSourcePlugin,
18-
makeTerserPlugin,
1917
} from './plugins/index.mjs';
20-
import { mergePlugins } from './utils.mjs';
18+
import { getNodeBuiltIns, mergePlugins, treeShakePreset } from './utils.mjs';
2119
import { makeProductionReplacePlugin } from './plugins/npmPlugins.mjs';
2220

2321
const BUNDLE_VARIANTS = ['.js', '.min.js', '.debug.min.js'];
2422

23+
const packageDotJSON = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './package.json'), { encoding: 'utf8' }));
24+
2525
export function makeBaseBundleConfig(options) {
26-
const { bundleType, entrypoints, licenseTitle, outputFileBase, packageSpecificConfig, esbuild } = options;
26+
const { bundleType, entrypoints, licenseTitle, outputFileBase, packageSpecificConfig } = options;
2727

28-
const nodeResolvePlugin = makeNodeResolvePlugin();
29-
const transpilePlugin = makeEsbuildPlugin(esbuild);
3028
const markAsBrowserBuildPlugin = makeBrowserBuildPlugin(true);
31-
const licensePlugin = makeLicensePlugin(licenseTitle);
29+
const banner = makeBannerOptions(licenseTitle, packageDotJSON.version);
3230
const rrwebBuildPlugin = makeRrwebBuildPlugin({
3331
excludeIframe: false,
3432
excludeShadowDom: false,
3533
});
3634
const productionReplacePlugin = makeProductionReplacePlugin();
3735

38-
// The `commonjs` plugin is the `esModuleInterop` of the bundling world. When used with `transformMixedEsModules`, it
39-
// will include all dependencies, imported or required, in the final bundle. (Without it, CJS modules aren't included
40-
// at all, and without `transformMixedEsModules`, they're only included if they're imported, not if they're required.)
41-
const commonJSPlugin = makeCommonJSPlugin({ transformMixedEsModules: true });
42-
4336
// used by `@sentry/browser`
4437
const standAloneBundleConfig = {
4538
output: {
39+
banner,
4640
format: 'iife',
4741
name: 'Sentry',
4842
intro: () => {
4943
return 'exports = window.Sentry || {};';
5044
},
5145
},
5246
context: 'window',
53-
plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin, licensePlugin],
47+
plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin],
5448
};
5549

5650
// used by `@sentry/wasm` & pluggable integrations from core/browser (bundles which need to be combined with a stand-alone SDK bundle)
@@ -61,7 +55,7 @@ export function makeBaseBundleConfig(options) {
6155
format: 'cjs',
6256

6357
// code to add before the CJS wrapper
64-
banner: '(function (__window) {',
58+
banner: `${banner}\n(function (__window) {`,
6559

6660
// code to add just inside the CJS wrapper, before any of the wrapped code
6761
intro: 'var exports = {};',
@@ -84,30 +78,41 @@ export function makeBaseBundleConfig(options) {
8478
// code to add after the CJS wrapper
8579
footer: '}(window));',
8680
},
87-
plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin, licensePlugin],
81+
plugins: [rrwebBuildPlugin, markAsBrowserBuildPlugin],
8882
};
8983

9084
const workerBundleConfig = {
9185
output: {
86+
banner,
9287
format: 'esm',
88+
minify: makeMinifierOptions(),
9389
},
94-
plugins: [commonJSPlugin, makeTerserPlugin(), licensePlugin],
9590
// Don't bundle any of Node's core modules
96-
external: builtinModules,
91+
external: getNodeBuiltIns(),
9792
};
9893

9994
const awsLambdaExtensionBundleConfig = {
10095
output: {
10196
format: 'esm',
97+
minify: makeMinifierOptions(),
10298
},
103-
plugins: [commonJSPlugin, makeIsDebugBuildPlugin(true), makeTerserPlugin()],
99+
plugins: [makeIsDebugBuildPlugin(true)],
104100
// Don't bundle any of Node's core modules
105-
external: builtinModules,
101+
external: getNodeBuiltIns(),
106102
};
107103

108104
// used by all bundles
109105
const sharedBundleConfig = {
110106
input: entrypoints,
107+
108+
// Point at the package's tsconfig so rolldown picks up its TypeScript & JSX settings.
109+
tsconfig: path.resolve(process.cwd(), './tsconfig.json'),
110+
111+
// ES2020 is our floor: keeps `?.`/`??` native and downlevels everything newer.
112+
transform: {
113+
target: 'es2020',
114+
},
115+
111116
output: {
112117
// a file extension will be added to this base value when we specify either a minified or non-minified build
113118
entryFileNames: outputFileBase,
@@ -116,8 +121,8 @@ export function makeBaseBundleConfig(options) {
116121
strict: false,
117122
esModule: false,
118123
},
119-
plugins: [productionReplacePlugin, transpilePlugin, nodeResolvePlugin],
120-
treeshake: 'smallest',
124+
plugins: [productionReplacePlugin],
125+
treeshake: treeShakePreset('smallest'),
121126
};
122127

123128
const bundleTypeConfigMap = {
@@ -147,7 +152,7 @@ export function makeBundleConfigVariants(baseConfig, options = {}) {
147152

148153
const includeDebuggingPlugin = makeIsDebugBuildPlugin(true);
149154
const stripDebuggingPlugin = makeIsDebugBuildPlugin(false);
150-
const terserPlugin = makeTerserPlugin();
155+
const minify = makeMinifierOptions();
151156
const setSdkSourcePlugin = makeSetSDKSourcePlugin('cdn');
152157

153158
// The additional options to use for each variant we're going to create.
@@ -162,15 +167,17 @@ export function makeBundleConfigVariants(baseConfig, options = {}) {
162167
'.min.js': {
163168
output: {
164169
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`,
170+
minify,
165171
},
166-
plugins: [stripDebuggingPlugin, setSdkSourcePlugin, terserPlugin],
172+
plugins: [stripDebuggingPlugin, setSdkSourcePlugin],
167173
},
168174

169175
'.debug.min.js': {
170176
output: {
171177
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.debug.min.js`,
178+
minify,
172179
},
173-
plugins: [includeDebuggingPlugin, setSdkSourcePlugin, terserPlugin],
180+
plugins: [includeDebuggingPlugin, setSdkSourcePlugin],
174181
},
175182
};
176183

0 commit comments

Comments
 (0)