Skip to content

Commit f2b9734

Browse files
committed
chore: try oxc minifier
1 parent 9caf30c commit f2b9734

File tree

4 files changed

+15
-42
lines changed

4 files changed

+15
-42
lines changed

dev-packages/rollup-utils/bundleHelpers.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
makeRrwebBuildPlugin,
1414
makeSetSDKSourcePlugin,
1515
makeBannerOptions,
16-
makeTerserPlugin,
16+
makeMinifierOptions,
1717
} from './plugins/index.mjs';
1818
import { mergePlugins, treeShakePreset } from './utils.mjs';
1919

@@ -83,17 +83,18 @@ export function makeBaseBundleConfig(options) {
8383
output: {
8484
banner,
8585
format: 'esm',
86+
minify: makeMinifierOptions(),
8687
},
87-
plugins: [makeTerserPlugin()],
8888
// Don't bundle any of Node's core modules
8989
external: builtinModules,
9090
};
9191

9292
const awsLambdaExtensionBundleConfig = {
9393
output: {
9494
format: 'esm',
95+
minify: makeMinifierOptions(),
9596
},
96-
plugins: [makeIsDebugBuildPlugin(true), makeTerserPlugin()],
97+
plugins: [makeIsDebugBuildPlugin(true)],
9798
// Don't bundle any of Node's core modules
9899
external: builtinModules,
99100
};
@@ -146,7 +147,7 @@ export function makeBundleConfigVariants(baseConfig, options = {}) {
146147

147148
const includeDebuggingPlugin = makeIsDebugBuildPlugin(true);
148149
const stripDebuggingPlugin = makeIsDebugBuildPlugin(false);
149-
const terserPlugin = makeTerserPlugin();
150+
const minifierOptions = makeMinifierOptions();
150151
const setSdkSourcePlugin = makeSetSDKSourcePlugin('cdn');
151152

152153
// The additional options to use for each variant we're going to create.
@@ -161,15 +162,17 @@ export function makeBundleConfigVariants(baseConfig, options = {}) {
161162
'.min.js': {
162163
output: {
163164
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`,
165+
minify: minifierOptions,
164166
},
165-
plugins: [stripDebuggingPlugin, setSdkSourcePlugin, terserPlugin],
167+
plugins: [stripDebuggingPlugin, setSdkSourcePlugin],
166168
},
167169

168170
'.debug.min.js': {
169171
output: {
170172
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.debug.min.js`,
173+
minify: minifierOptions,
171174
},
172-
plugins: [includeDebuggingPlugin, setSdkSourcePlugin, terserPlugin],
175+
plugins: [includeDebuggingPlugin, setSdkSourcePlugin],
173176
},
174177
};
175178

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

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
/**
2-
* CommonJS plugin docs: https://github.com/rollup/plugins/tree/master/packages/commonjs
3-
* License plugin docs: https://github.com/mjeanroy/rollup-plugin-license
4-
* Replace plugin docs: https://github.com/rollup/plugins/tree/master/packages/replace
5-
* Resolve plugin docs: https://github.com/rollup/plugins/tree/master/packages/node-resolve
6-
* Terser plugin docs: https://github.com/TrySound/rollup-plugin-terser#options
7-
* Terser docs: https://github.com/terser/terser#api-reference
8-
* Typescript plugin docs: https://github.com/rollup/plugins/tree/master/packages/typescript/#readme
9-
*/
10-
111
import * as childProcess from 'child_process';
12-
132
import { replacePlugin } from 'rolldown/plugins';
14-
import terser from '@rollup/plugin-terser';
153

164
/**
175
* Create a plugin to add an identification banner to the top of stand-alone bundles.
@@ -41,7 +29,6 @@ export function makeIsDebugBuildPlugin(includeDebugging) {
4129
__SENTRY_DEBUG__: JSON.stringify(includeDebugging),
4230
},
4331
{
44-
// TODO `preventAssignment` will default to true in version 5.x of the replace plugin, at which point we can get rid
4532
// of this. (It actually makes no difference in this case whether it's true or false, since we never assign to
4633
// `__SENTRY_DEBUG__`, but if we don't give it a value, it will spam with warnings.)
4734
preventAssignment: true,
@@ -75,22 +62,18 @@ export function makeBrowserBuildPlugin(isBrowserBuild) {
7562
'process.env.NODE_ENV': JSON.stringify('production'),
7663
},
7764
{
78-
// TODO This will be the default in the next version of the `replace` plugin
7965
preventAssignment: true,
8066
},
8167
);
8268
}
8369

84-
// `terser` options reference: https://github.com/terser/terser#api-reference
85-
// `rollup-plugin-terser` options reference: https://github.com/TrySound/rollup-plugin-terser#options
86-
8770
/**
88-
* Create a plugin to perform minification using `terser`.
71+
* Create minifier options for the rollup build.
8972
*
90-
* @returns An instance of the `terser` plugin
73+
* @returns {import('rolldown').OutputOptions['minify']}
9174
*/
92-
export function makeTerserPlugin() {
93-
return terser({
75+
export function makeMinifierOptions() {
76+
return {
9477
mangle: {
9578
// `captureException` and `captureMessage` are public API methods and they don't need to be listed here, as the
9679
// mangler won't touch user-facing things, but `sentryWrapped` is not user-facing, and would be mangled during
@@ -136,8 +119,5 @@ export function makeTerserPlugin() {
136119
],
137120
},
138121
},
139-
output: {
140-
comments: false,
141-
},
142-
});
122+
};
143123
}

dev-packages/rollup-utils/utils.mjs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ export function mergePlugins(pluginsA, pluginsB) {
2121
// here.
2222
// Additionally, the excludeReplay plugin must run before TS/Sucrase so that we can eliminate the replay code
2323
// before anything is type-checked (TS-only) and transpiled.
24-
const order = [
25-
'remove-dev-mode-blocks',
26-
'excludeReplay',
27-
'typescript',
28-
'sucrase',
29-
'...',
30-
'terser',
31-
'license',
32-
'output-base64-worker-script',
33-
];
24+
const order = ['remove-dev-mode-blocks', 'excludeReplay', '...', 'output-base64-worker-script'];
3425
const sortKeyA = order.includes(a.name) ? a.name : '...';
3526
const sortKeyB = order.includes(b.name) ? b.name : '...';
3627

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"dev-packages/bundler-tests"
105105
],
106106
"devDependencies": {
107-
"@rollup/plugin-terser": "^0.4.4",
108107
"@size-limit/file": "~11.1.6",
109108
"@size-limit/webpack": "~11.1.6",
110109
"@types/jsdom": "^21.1.6",

0 commit comments

Comments
 (0)