-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ref(nextjs): Exclude cross-platform tracing code from bundles #3978
ref(nextjs): Exclude cross-platform tracing code from bundles #3978
Conversation
size-limit report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
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
).
Oh, good call. Done. |
2e6b2ba
to
8652e86
Compare
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
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
The
@sentry/tracing
package 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> = false
in the webpack config.Notes:
All node tracing integrations have been moved into a
node
folder, so we don't need to worry that at some point a non-node integration might get added tointegrations
and 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
_app
bundle down from ~32.3 kb to ~30.6 kb, which is a little over a 5% savings.Before:
After: