perf(build): Optimize terser minifier config for CDN bundles#19852
Open
HazAT wants to merge 2 commits intoautoresearch/browser-bundle-size-2026-03-17from
Open
perf(build): Optimize terser minifier config for CDN bundles#19852HazAT wants to merge 2 commits intoautoresearch/browser-bundle-size-2026-03-17from
HazAT wants to merge 2 commits intoautoresearch/browser-bundle-size-2026-03-17from
Conversation
Contributor
size-limit report 📦
|
Contributor
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
56e885a to
3bc0473
Compare
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Deps
Nestjs
Node
Other
Bug Fixes 🐛Core
Nextjs
Other
Documentation 📚New Release
Other
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
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
3bc0473 to
05a894e
Compare
This prevents the terser mangle option from mangling the 'Sentry' name, and avoids a terser bug where our top-level 'var Sentry=' gets stripped.
05a894e to
9ae982f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Enable additional terser compress and mangle options that safely reduce CDN
.min.jsbundle sizes. Saves ~300 bytes gzipped on the base browser bundle.Changes
compress.passes: 5compress.ecma: 2020compress.toplevel: truecompress.unsafe_arrows: truefunctionto=>wherethisis unused (~1.3KB raw)compress.unsafe_methods: true{ m(){} }compress.unsafe_comps / unsafe_math / pure_gettersmangle.toplevel: trueThese options only affect CDN
.min.jsbundles, not npm ESM/CJS output. Theunsafe_*options are safe for our codebase because the CDN bundles run in browser contexts where the assumptions hold.Also pre-reserves
sWin the mangle list for a follow-up change.Part of #19833.
Co-Authored-By: Claude claude@anthropic.com