Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(nextjs): Exclude cross-platform tracing code from bundles (#3978)
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[1] to replace a module with an empty object by setting `resolve.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 to `integrations` 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. [1] https://webpack.js.org/configuration/resolve/#resolvealias
- Loading branch information
1 parent
42dffe5
commit c8a941c
Showing
9 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { Express } from './express'; | ||
export { Postgres } from './postgres'; | ||
export { Mysql } from './mysql'; | ||
export { Mongo } from './mongo'; | ||
export { Express } from './node/express'; | ||
export { Postgres } from './node/postgres'; | ||
export { Mysql } from './node/mysql'; | ||
export { Mongo } from './node/mongo'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...s/tracing/test/integrations/mongo.test.ts → ...cing/test/integrations/node/mongo.test.ts
This file contains 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
4 changes: 2 additions & 2 deletions
4
...racing/test/integrations/postgres.test.ts → ...g/test/integrations/node/postgres.test.ts
This file contains 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