-
-
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
Tree-shaking browserTracingIntegration in NextJS #14011
Comments
Hmm, you can omit I just tried in our own size-limit setup, and it seems to be correct to me like this: {
name: '@sentry/nextjs (without tracing)',
path: 'packages/nextjs/build/esm/client/index.js',
import: '{ init }',
ignore: ['next/router', 'next/constants'],
gzip: true,
limit: '39 KB',
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
config.plugins.push(
new webpack.DefinePlugin({
__SENTRY_TRACING__: false,
}),
);
config.optimization.minimize = true;
config.optimization.minimizer = [new TerserPlugin()];
return config;
},
}, is smaller than without the webpack config, in the range that I would expect. You wrote:
Do you mean that with version 8.25.0 it worked for you, and then not anymore? |
Hey @mydea !
Correct! Only 8.25.0 (and below) works well. 🤷♂️ |
Hmm, and the only change you did there was to bump the version from 8.25.0 to 8.26.0 - no other (e.g. config) changes? I don't immediately see anything in 8.25.0...8.26.0 that jumps out, and our size limit seems to still tree shake properly 🤔 cc @lforst or @chargome could you try this in some "real" next app to verify that tree shaking works on the latest version of the SDK? |
@mydea Thanks for checking! What I see in 8.26.0:
Plus extra non-documented options here: https://github.com/getsentry/sentry-javascript/pull/13323/files#diff-338f827c7c3625622b0b38a45cd130517a9f872f6de2d354a7c80785462dcc3dR122 (which also didn't help) |
Yeah, but if tree shaking is properly set up, it should still remove this due to |
@antongunkin can you 100% verify that the only change you're making before and after it works is bumping the SDK? No other code changes? I just tried our tree-shaking capabilities in my test app and
Maybe try to use the webpack instance that nextjs gives you here instead of requiring it! I tested with the exact same versions you mentioned. Maybe also try to upgrade everything to the latest version. |
Ok, fixed, but it was weird. I had a lazy (next/dynamic) component with additionally lazy session replays ES6 import:
Fixed by replacing just to:
It's strange that Webpack couldn't resolve it since 8.26.0. And thank you! |
Thanks for the pointer to update the docs. Doing |
Looking at it more, this might be a webpack/nextjs config issue because I would assume webpack to kinda duplicate the bundles. Honestly, it might also just be a bundle analyzer thing. |
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/nextjs
SDK Version
8
Framework Version
Next 14.2.10
Link to Sentry event
No response
Reproduction Example/SDK Setup
Hey!
Can't get rid of extra
browserTracingIntegration
integration.As I can see it happened here: https://github.com/getsentry/sentry-javascript/releases/tag/8.26.0
It worked (-50kb size-limit) prior this version.
Could you please check?
Thank you!
Steps to Reproduce
sentry.client.config.ts
next.config.js
Expected Result
No
browserTracingIntegration.js
in clients js-bundle.Actual Result
Extra integration, increased bundle-size.
The text was updated successfully, but these errors were encountered: