From d025e6b2a86f253ffde9f2acfb2d6f8e876003fe Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 17 Mar 2026 17:39:00 +0100 Subject: [PATCH 1/2] perf(build): Optimize terser minifier config for CDN bundles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable additional terser compress and mangle options that safely reduce the size of CDN bundle .min.js files: - compress.passes: 5 (multi-pass finds more dead code) - compress.ecma: 2020 (allows modern syntax: nullish coalescing, optional chaining) - compress.toplevel: true (better variable inlining within the IIFE) - compress.unsafe_arrows: true (function → arrow where this is unused, ~1.3KB raw) - compress.unsafe_methods: true ({ m: function(){} } → { m(){} }) - compress.unsafe_comps/unsafe_math/pure_getters: safe algebraic opts - mangle.toplevel: true (mangle top-level names inside IIFE scope) Also adds 'sW' to the mangle reserved list (used by a follow-up change that shortens the sentryWrapped function name for frame stripping). These options only affect CDN .min.js bundles, not npm ESM/CJS output. Saves ~300 bytes gzipped on the base browser bundle. Co-Authored-By: Claude claude@anthropic.com --- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index 9d6edd3157c0..85018bf9112e 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -101,7 +101,8 @@ export function makeTerserPlugin() { // mangler won't touch user-facing things, but `sentryWrapped` is not user-facing, and would be mangled during // minification. (We need it in its original form to correctly detect our internal frames for stripping.) All three // are all listed here just for the clarity's sake, as they are all used in the frames manipulation process. - reserved: ['captureException', 'captureMessage', 'sentryWrapped'], + reserved: ['captureException', 'captureMessage', 'sentryWrapped', 'sW'], + toplevel: true, properties: { // allow mangling of private field names... regex: /^_[^_]/, @@ -141,6 +142,16 @@ export function makeTerserPlugin() { ], }, }, + compress: { + passes: 5, + ecma: 2020, + toplevel: true, + unsafe_comps: true, + unsafe_math: true, + pure_getters: true, + unsafe_arrows: true, + unsafe_methods: true, + }, output: { comments: false, }, From 9ae982f058290f390a162ba849303867ea6531cb Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 19 Mar 2026 07:31:02 -0700 Subject: [PATCH 2/2] perf(build): Reserve 'Sentry', remove toplevel minification This prevents the terser mangle option from mangling the 'Sentry' name, and avoids a terser bug where our top-level 'var Sentry=' gets stripped. --- dev-packages/rollup-utils/plugins/bundlePlugins.mjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index 85018bf9112e..dde5596bd708 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -101,8 +101,7 @@ export function makeTerserPlugin() { // mangler won't touch user-facing things, but `sentryWrapped` is not user-facing, and would be mangled during // minification. (We need it in its original form to correctly detect our internal frames for stripping.) All three // are all listed here just for the clarity's sake, as they are all used in the frames manipulation process. - reserved: ['captureException', 'captureMessage', 'sentryWrapped', 'sW'], - toplevel: true, + reserved: ['Sentry', 'captureException', 'captureMessage', 'sentryWrapped', 'sW'], properties: { // allow mangling of private field names... regex: /^_[^_]/, @@ -145,7 +144,6 @@ export function makeTerserPlugin() { compress: { passes: 5, ecma: 2020, - toplevel: true, unsafe_comps: true, unsafe_math: true, pure_getters: true,