Skip to content

chore(build): Use standard regex for wasm terser mangle.properties option #4592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

lobsterkatie
Copy link
Member

Currently, @sentry/wasm's minification settings (the mangle.properties option in rollup's terser plugin) prevent the mangling of any property names. (Note: This is different from variable names, which do get mangled.)

In other packages, internal property names (those starting with a single _) are mangled. This PR ports that setting to the wasm package, which turns out not to meaningfully change the bundle, because nowhere in the package do such properties appear. As a result, the only effects of this change are different single-letter variables being used in the final minified bundle:

image

(That isn't the whole file, but the rest looks much the same.)

@lobsterkatie lobsterkatie force-pushed the kmclb-use-standard-regex-wasm-terser-properties branch from 2db2326 to b926168 Compare February 16, 2022 23:50
@github-actions
Copy link
Contributor

size-limit report

Path Base Size (af6c24f) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.69 KB 19.69 KB +0.01% 🔺
@sentry/browser - ES5 CDN Bundle (minified) 63.27 KB 63.27 KB 0%
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.36 KB 18.36 KB +0.02% 🔺
@sentry/browser - ES6 CDN Bundle (minified) 56.44 KB 56.44 KB 0%
@sentry/browser - Webpack (gzipped + minified) 22.14 KB 22.14 KB 0%
@sentry/browser - Webpack (minified) 76.14 KB 76.14 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.17 KB 22.17 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.33 KB 46.33 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.15 KB 27.15 KB +0.01% 🔺

@lobsterkatie lobsterkatie changed the title [WIP] chore(build): Use standard regex for wasm terser mangle.properties option chore(build): Use standard regex for wasm terser mangle.properties option Feb 17, 2022
@lobsterkatie lobsterkatie marked this pull request as ready for review February 17, 2022 00:14
@lobsterkatie lobsterkatie enabled auto-merge (squash) February 17, 2022 00:16
@lobsterkatie lobsterkatie merged commit 1bf9883 into master Feb 17, 2022
@lobsterkatie lobsterkatie deleted the kmclb-use-standard-regex-wasm-terser-properties branch February 17, 2022 00:16
@AbhiPrasad AbhiPrasad added this to the Pre 7.0.0 Work milestone Feb 23, 2022
lobsterkatie added a commit that referenced this pull request Mar 1, 2022
This is very similar to #4592, which brought `@sentry/wasm` in line with other bundles in terms of which object properties it was willing to mangle (changing it from "nope, nuthin'" to "anything private, a.k.a., anything starting with exactly one underscore").

That PR was effectively a no-op,  in that we made a change to a class of property which it turns out doesn't exist anywhere in the wasm package. In the case of this PR, though, that's not true: private properties do exist, and where they've been heretofore left alone by terser, they will now be mangled. This is a small bundle size win, but it is also _technically_ a breaking change, at least for anyone using those properties directly.

That said, there's a _reason_ we use a leading underscore to mark them as internal and tag them as private in TS - people aren't supposed to be using them. Further, out of the (hopefully very small if not non-existent) group of people mucking with our internals, this will only affect the subset who are both using the CDN and using one of these optional integrations, which the majority of our users do not. I therefore think it's a very small risk with not one but _two_ small rewards, the bundle size reduction and further standardization of our rollup config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants