Skip to content

fet(build): Create debug versions of minified bundles #4699

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
merged 7 commits into from
Mar 11, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Mar 9, 2022

This adds to our base CDN rollup config the ability to create bundles which are minified but nonetheless contain debug logging.

Notable changes:

  • Setting the constant (__SENTRY_DEBUG__) which controls whether or not to include logging is now done by a separate rollup plugin rather than by terser (which was setting the now-obsolete __SENTRY_NO_DEBUG__ flag). This allows rollup to do the treeshaking, which is good because it lets us create a non-minified no-debug bundle. Though such a bundle doesn't make a lot of sense to publish (why strip the logging if you’re not also going to minify the code?), it is very helpful for us, because it allows us to see what's being treeshaken in the context of human-readable code.

  • The scope of the helper function makeMinificationVariants has broadened to include the creation of all bundle variants*. As a result, it no longer takes an array of configs (which it might have gotten had there ever been a makeJSVersionVariants or makeDebugVariants whose results could have been passed to makeMinificationVariants) but instead takes a single base config which it then spins out into all necessary flavors. This broadening of scope is also now reflected in variable names and the function name itself.

* This is not quite true, in that it's still not handling the ES5/ES6 question. I chose not to incorporate that because as soon as we go ES6-only in v7, it will no longer be an issue for any package except perhaps the browser package.

Ref: https://getsentry.atlassian.net/browse/WEB-546

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2022

size-limit report

Path Base Size (ba14cc5) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.43 KB 19.37 KB -5.18% 🔽
@sentry/browser - ES5 CDN Bundle (minified) 65.2 KB 61.92 KB -5.04% 🔽
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.01 KB 18.04 KB -5.12% 🔽
@sentry/browser - ES6 CDN Bundle (minified) 58.22 KB 55.32 KB -4.99% 🔽
@sentry/browser - Webpack (gzipped + minified) 22.3 KB 22.3 KB 0%
@sentry/browser - Webpack (minified) 76.58 KB 76.58 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.33 KB 22.33 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.56 KB 46.56 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.25 KB 25.26 KB -7.32% 🔽
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.62 KB 23.65 KB -7.68% 🔽

@AbhiPrasad AbhiPrasad closed this Mar 9, 2022
@AbhiPrasad AbhiPrasad closed this Mar 9, 2022
@AbhiPrasad AbhiPrasad reopened this Mar 9, 2022
@AbhiPrasad AbhiPrasad reopened this Mar 9, 2022
@AbhiPrasad
Copy link
Member

Woops 🙈

1 similar comment
@AbhiPrasad
Copy link
Member

Woops 🙈

@lobsterkatie lobsterkatie force-pushed the kmclb-create-debug-bundles branch from ed654f3 to 57ec132 Compare March 9, 2022 18:53
@lobsterkatie lobsterkatie marked this pull request as ready for review March 9, 2022 19:38
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me overall. Code-wise I think it makes sense. I left some comments on naming but given my (probably limited) understanding of our naming conventions, take them with a grain of salt.

EDIT: Whoops, the comments did not make it, re-added them below

@lobsterkatie lobsterkatie force-pushed the kmclb-create-debug-bundles branch from 57ec132 to 2eb6467 Compare March 11, 2022 14:33
@lobsterkatie lobsterkatie enabled auto-merge (squash) March 11, 2022 14:35
@lobsterkatie lobsterkatie merged commit af7081c into master Mar 11, 2022
@lobsterkatie lobsterkatie deleted the kmclb-create-debug-bundles branch March 11, 2022 14:47
lobsterkatie added a commit that referenced this pull request Mar 15, 2022
Given that now most of our testing runs in parallel in CI, the biggest bottleneck has become the build step. Within that step, the single slowest thing we do is build integration bundles, simply because of the number of bundles which need to be created. (This is especially true now that we're creating three versions of each bundle rather than two[1].)

To speed things up a bit, this parallelizes the building of those bundles. Though it ends up not being as dramatic a time savings as one might hope (because the typescript plugin's caching mechanism doesn't play nicely with concurrent builds[2]), it nonetheless drops the total build time from roughly two minutes down to 70-80 seconds in my local testing.

[1] #4699
[2] ezolenko/rollup-plugin-typescript2#15
lobsterkatie added a commit to getsentry/sentry-docs that referenced this pull request Mar 22, 2022
A number of PRs (see below) have recently added to the bundles available for use on the CDN. This documents the new options, and does some general wordsmithing on the page.

Bundle-adding PRs:
getsentry/sentry-javascript#4674
getsentry/sentry-javascript#4699
getsentry/sentry-javascript#4718
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.

3 participants