Skip to content

Conversation

@logaretm
Copy link
Collaborator

What

A PR to go in tandem with getsentry/sentry-javascript#18359 once it gets merged and released.

It documents the new tree-shaking options now abstracted away into webpack.treeshake namespace. It has a few differences to the existing tree-shaking flags under the hood:

  • All options are optimized to be set to true to take effect, unlike the flags where some had to be set to true and some had to be set to false.
  • Now exposed as an SDK webpack.treeshake build options rather than needing the user to be aware of the webpack define plugin API.

Marking it as a draft to avoid merging it before the PR goes live.

@linear
Copy link

linear bot commented Dec 11, 2025

@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sentry-docs Ready Ready Preview, Comment Dec 18, 2025 3:33pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
develop-docs Ignored Ignored Preview Dec 18, 2025 3:33pm

Copy link
Collaborator

@inventarSarah inventarSarah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Added some suggestions


<SdkOption name="webpack.treeshake.removeDebugLogging" type="boolean" defaultValue="false">

Setting this option to `true` will remove all debug logging code from the Sentry SDK. Note that it has nothing to do with `enableLogs` or Sentry's logs product.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two sentences are a bit confusing to me -- which logs does it concern?

Copy link
Collaborator Author

@logaretm logaretm Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit tricky 😅, so ... we have those DEBUG logs that show up when the user has debug: true but they aren't removed from the bundle.

So this option is supposed to remove them from the bundle, but we have a logs product enabled by enableLogs on the SDK configuration (not build options), so this is basically trying to avoid that very confusion, that it doesn't affect the logs product and it only affect those DEBUG statements.

What do you think we could do here to explain that? this has been always a confusion point for many users.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this, maybe?

Setting this option to true will remove all Sentry SDK debug logging code (the console logs that appear when you set debug: true in your SDK configuration). This doesn't affect Sentry's Logs product (controlled by the enableLogs option) or your app's logging.

Copy link
Collaborator Author

@logaretm logaretm Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I think the console mention here nails it. Thanks! Pushed it!

Copy link
Collaborator

@inventarSarah inventarSarah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💫nice!

@logaretm logaretm marked this pull request as ready for review December 18, 2025 14:58
Copilot AI review requested due to automatic review settings December 18, 2025 14:58
logaretm and others added 12 commits December 18, 2025 16:58
Co-authored-by: Charly Gomez <[email protected]>
Co-authored-by: Charly Gomez <[email protected]>
Co-authored-by: Charly Gomez <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
Co-authored-by: Sarah Mischinger <[email protected]>
@logaretm logaretm force-pushed the awad/js-1222-add-treeshaking-options-docs branch from 3d7f5d9 to 0ec7cee Compare December 18, 2025 14:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive documentation for the new tree-shaking webpack configuration options in the Next.js SDK. It moves away from the older webpack DefinePlugin approach to a more user-friendly webpack.treeshake configuration namespace abstracted through the withSentryConfig function.

Key changes:

  • New dedicated tree-shaking documentation page for Next.js with detailed explanations of all available options
  • Updated build configuration documentation to reference the new webpack.treeshake options
  • Removed the outdated Next.js tree-shaking section from the common configuration docs

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
docs/platforms/javascript/guides/nextjs/configuration/tree-shaking.mdx New comprehensive guide documenting the webpack.treeshake configuration options with examples and detailed descriptions of each option
docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx Added webpack.treeshake option reference linking to the new tree-shaking documentation
docs/platforms/javascript/common/configuration/tree-shaking.mdx Removed outdated Next.js-specific tree-shaking section using DefinePlugin and fixed minor formatting issues

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +48
// Tree shaking options...
removeDebugLogging: false,
removeTracing: false,
excludeReplayIframe: false,
excludeReplayShadowDOM: false,
excludeReplayCompressionWorker: false,
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code example shows all tree-shaking options set to false, which is also the default value. This might be confusing for users trying to understand how to actually enable tree-shaking. Consider either showing the options set to true to demonstrate enabling tree-shaking, or adding a comment explaining that these are the defaults and users should set them to true to enable the respective tree-shaking optimizations.

Suggested change
// Tree shaking options...
removeDebugLogging: false,
removeTracing: false,
excludeReplayIframe: false,
excludeReplayShadowDOM: false,
excludeReplayCompressionWorker: false,
// Enable tree shaking by setting these options to true (defaults are all false).
removeDebugLogging: true,
removeTracing: true,
excludeReplayIframe: true,
excludeReplayShadowDOM: true,
excludeReplayCompressionWorker: true,

Copilot uses AI. Check for mistakes.
logaretm and others added 2 commits December 18, 2025 16:23
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
@logaretm logaretm merged commit e1c7023 into master Dec 18, 2025
14 checks passed
@logaretm logaretm deleted the awad/js-1222-add-treeshaking-options-docs branch December 18, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants