Uh oh!
There was an error while loading. Please reload this page.
chore: Make @sentry/conventions sideEffect free during bundling - #22015
Merged
Conversation
Uh oh!
There was an error while loading. Please reload this page.
49 tasks
JPeer264 added a commit
that referenced
this pull request
Sep 2, 2026
…false` externals (#23674) For CF integration tests there were a lot of warnings printed: ``` ▲ [WARNING] Ignoring this import because ".../packages/core/build/esm/index.js" was marked as having no side effects [ignored-bare-import] packages/cloudflare/build/esm/prod/sdk.js:3:7: 3 │ import '@sentry/core'; ``` ### Root cause `treeshake.moduleSideEffects` in `dev-packages/rollup-utils/npmHelpers.mjs` told Rollup that every external module has side effects. When Rollup tree-shakes away all named bindings of such an external, it keeps a bare side-effect import to preserve those effects. That import contradicts the dependency's own `"sideEffects": false`, which is what the consuming bundler reports. The Cloudflare instance is reachable from a single line in `packages/cloudflare/src/sdk.ts`: ```ts export { _clearGlobalClientCache } from './clientCache'; ``` _clearGlobalClientCache is a test-only helper that no entrypoint reaches, so Rollup drops the re-export. clientCache.ts imports GLOBAL_OBJ from @sentry/core, and Rollup hoists that external dependency into sdk.js as a bare import to keep its supposed side effects alive. #22015 already hit this and special-cased @sentry/conventions. That patched one instance rather than the mechanism, so the next package to trip it, @sentry/core, brought the warnings straight back. ### Solution Now we check for the key `sideEffects` in the respesctitive `package.json`. If there is `sideEffects` set it will take its value, and if there is non then we assume there are side effects, just as before. With that the warnings are gone. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@sentry/conventionsare marked withsideEffects. That leads to having@sentry/conventions/attributesas side effect import in the bundled output:By telling rollup that
@sentry/conventionsis side effect free, the side effect import from the output is being removed (it also reflects thepackage.json#sideEffectfieldOriginally I came to this fix as the Cloudflare integration tests were quite verbose in this warning: