You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tree-shaking browserTracingIntegration in NextJS #14011
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?
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.
Hey @mydea and @lforst , thanks again for checking!
I just tried different project with same next and sdk versions and it works without any changes...
So I can confirm that problem on my side only. Will let you know soon, maybe it's just some node_modules conflicts e.g.
Thanks for the pointer to update the docs. Doing import('@sentry/nextjs') indeed inhibits tree shaking because dynamic imports will always pull in the entire dependency.
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.
Activity
mydea commentedon Oct 17, 2024
Hmm, you can omit
enableTracing: false, this should not be necessary.I just tried in our own size-limit setup, and it seems to be correct to me like this:
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?
antongunkin commentedon Oct 17, 2024
Hey @mydea !
Correct! Only 8.25.0 (and below) works well.
And yes,
enableTracing: falsedoes nothing.🤷♂️
mydea commentedon Oct 17, 2024
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?
antongunkin commentedon Oct 17, 2024
@mydea Thanks for checking!
What I see in 8.26.0:
browserTracingIntegrationin Meta Framework SDKs #13010Plus extra non-documented options here: https://github.com/getsentry/sentry-javascript/pull/13323/files#diff-338f827c7c3625622b0b38a45cd130517a9f872f6de2d354a7c80785462dcc3dR122 (which also didn't help)
4 remaining items
lforst commentedon Oct 18, 2024
@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
browserTracingIntegrationproperly tree-shakes as soon as I addMaybe 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.
antongunkin commentedon Oct 18, 2024
Hey @mydea and @lforst , thanks again for checking!
I just tried different project with same next and sdk versions and it works without any changes...
So I can confirm that problem on my side only. Will let you know soon, maybe it's just some node_modules conflicts e.g.
antongunkin commentedon Oct 18, 2024
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.
Also worth to check this documentation: https://docs.sentry.io/platforms/javascript/guides/nextjs/session-replay/#lazy-loading-replay
And thank you!
lforst commentedon Oct 21, 2024
Thanks for the pointer to update the docs. Doing
import('@sentry/nextjs')indeed inhibits tree shaking because dynamic imports will always pull in the entire dependency.lforst commentedon Oct 21, 2024
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.