ref(nextjs): Exclude cross-platform tracing code from bundles#3978
Merged
lobsterkatie merged 5 commits intomasterfrom Sep 14, 2021
Merged
ref(nextjs): Exclude cross-platform tracing code from bundles#3978lobsterkatie merged 5 commits intomasterfrom
lobsterkatie merged 5 commits intomasterfrom
Conversation
Contributor
size-limit report
|
iker-barriocanal
approved these changes
Sep 14, 2021
Contributor
iker-barriocanal
left a comment
There was a problem hiding this comment.
🚀
I'd also rename the tests. If the integration is in src/integrations/node/mongo.ts, the test should be in test/integrations/node/mongo.test.ts (instead of test/integrations/mongo.test.ts).
AbhiPrasad
approved these changes
Sep 14, 2021
Member
Author
Oh, good call. Done. |
2e6b2ba to
8652e86
Compare
This was referenced Sep 14, 2021
lobsterkatie
added a commit
that referenced
this pull request
Dec 14, 2021
In #3978, code was introduced to prevent node tracing integrations (mongo, postgres, etc) from appearing in the browser bundle where they don't belong. However, as part of our larger push to make our code more treeshakable, we recently changed how we export those integrations[1], making the previous workaround unnecessary. As a bonus, this should fix a rendering issue some users were having when using the `fallback` flag. Tested locally and on vercel. Fixes #4090. [1] #4204
onurtemizkan
pushed a commit
that referenced
this pull request
Dec 19, 2021
In #3978, code was introduced to prevent node tracing integrations (mongo, postgres, etc) from appearing in the browser bundle where they don't belong. However, as part of our larger push to make our code more treeshakable, we recently changed how we export those integrations[1], making the previous workaround unnecessary. As a bonus, this should fix a rendering issue some users were having when using the `fallback` flag. Tested locally and on vercel. Fixes #4090. [1] #4204
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.
The
@sentry/tracingpackage contains shared code, code which only applies to browser, and code which only applies to node. At the moment, webpack is unable to treeshake the former out of the server build and the latter out of the client build. This PR does that treeshaking manually, taking advantage of webpack 5’s new ability to replace a module with an empty object by settingresolve.alias.<someModule> = falsein the webpack config.Notes:
All node tracing integrations have been moved into a
nodefolder, so we don't need to worry that at some point a non-node integration might get added tointegrationsand be accidentally excluded.Normally we only care about bundle size on the browser side, but since Vercel turns server routes into serverless functions, bundle size matters on the backend, too, so the change was made in both directions.
As a point of reference, on my test app it took the sentry portion of the client
_appbundle down from ~32.3 kb to ~30.6 kb, which is a little over a 5% savings.Before:
After: