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
I'm using Webpack with Sentry 8.55.0 and I tried to set the recommended variables in my build, as it shows on the page:
new webpack.DefinePlugin({
__SENTRY_DEBUG__: false,
__SENTRY_TRACING__: false,
__RRWEB_EXCLUDE_IFRAME__: true,
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
}),
// ... other plugins
But I don't see almost any difference in the build output. What should I look for to validate that these variables are taking effect? Should entire internal Sentry modules get removed from the build?
One thing I should mention is that I've confirmed that automatic tree shaking is already working. Interestingly, when I do this:
import * as SentryClient from "@sentry/browser"
I see some tree shaking taking place. A bunch of Sentry modules now appear in 0 chunks in my build (as compared with using CJS require("@sentry/browser" where there is no tree shaking at all.
But when I change it to explicit import only the specific functions I'm calling, like this:
import {close, endSession, init, startSession, captureSession, getCurrentScope} from "@sentry/browser"
There's way, way more tree shaking that happens. A huge number of Sentry modules are removed from the build when I do this. So clearly Webpack does a much better job if you are explicit about what is being imported.
I'm wondering if that is already shaking out the modules that would be removed by the manual shaking using the DefinePlugin variables. Or is there more that can be done?
If there was some way to know which modules should be removed with those variables, I can validate that as much tree shaking as possible is taking effect.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I recently came across this page that talks about tree shaking in Sentry:
https://docs.sentry.io/platforms/javascript/configuration/tree-shaking/
I'm using Webpack with Sentry 8.55.0 and I tried to set the recommended variables in my build, as it shows on the page:
But I don't see almost any difference in the build output. What should I look for to validate that these variables are taking effect? Should entire internal Sentry modules get removed from the build?
One thing I should mention is that I've confirmed that automatic tree shaking is already working. Interestingly, when I do this:
import * as SentryClient from "@sentry/browser"I see some tree shaking taking place. A bunch of Sentry modules now appear in 0 chunks in my build (as compared with using CJS
require("@sentry/browser"where there is no tree shaking at all.But when I change it to explicit import only the specific functions I'm calling, like this:
import {close, endSession, init, startSession, captureSession, getCurrentScope} from "@sentry/browser"There's way, way more tree shaking that happens. A huge number of Sentry modules are removed from the build when I do this. So clearly Webpack does a much better job if you are explicit about what is being imported.
I'm wondering if that is already shaking out the modules that would be removed by the manual shaking using the
DefinePluginvariables. Or is there more that can be done?If there was some way to know which modules should be removed with those variables, I can validate that as much tree shaking as possible is taking effect.
Thanks!
Best regards,
Scott
Beta Was this translation helpful? Give feedback.
All reactions