Skip to content

fix(build): Remove node code from CDN bundles #4548

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

@lobsterkatie lobsterkatie commented Feb 11, 2022

This PR changes the way we substitute true for __SENTRY_BROWSER_BUNDLE__, the flag which enables us to treeshake anything Node-related out of CDN bundles.

There are two main changes:

  • In the browser rollup config, the substitution is moved from the terser stage to an earlier stage, immediately after TS compilation, in order that the treeshaking we need now applies to all versions of the bundle, rather than just the minified ones.

  • The substitution is added to all other rollup configs. (Even though packages like @sentry/tracing and @sentry/integrations are cross-platform, in this case we know we're building CDN bundles (which are only relevant in a browser setting), so it's safe to restrict it.)

As an example, here's the effect of these changes on the main browser bundle:

image
image
image

@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2022

size-limit report

Path Base Size (4ff68c1) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.73 KB 19.72 KB -0.03% 🔽
@sentry/browser - ES5 CDN Bundle (minified) 63.06 KB 63.04 KB -0.04% 🔽
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.44 KB 18.44 KB +0.02% 🔺
@sentry/browser - ES6 CDN Bundle (minified) 56.5 KB 56.49 KB -0.03% 🔽
@sentry/browser - Webpack (gzipped + minified) 22.16 KB 22.16 KB 0%
@sentry/browser - Webpack (minified) 75.87 KB 75.87 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.19 KB 22.19 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.27 KB 46.27 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 28.3 KB 27.19 KB -3.9% 🔽

@lobsterkatie lobsterkatie merged commit 7f40e50 into master Feb 11, 2022
@lobsterkatie lobsterkatie deleted the kmclb-remove-node-code-from-CDN-bundles-WEB-601 branch February 11, 2022 14:33
@AbhiPrasad AbhiPrasad added this to the Treeshaking / Bundle Size milestone Feb 11, 2022
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