Skip to content

build(rollup-utils): Skip bare side-effect imports for sideEffects: false externals - #23674

Open
JPeer264 wants to merge 1 commit into
developfrom
jp/side-effects
Open

build(rollup-utils): Skip bare side-effect imports for sideEffects: false externals#23674
JPeer264 wants to merge 1 commit into
developfrom
jp/side-effects

Conversation

@JPeer264

Copy link
Copy Markdown
Member

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:

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.

…false` externals

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@JPeer264
JPeer264 requested review from Lms24, chargome and timfish August 27, 2026 09:08
@JPeer264 JPeer264 self-assigned this Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.65 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.56 kB - -
@sentry/browser (incl. Tracing, Replay) 88.11 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.51 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.51 kB - -
@sentry/browser (incl. Feedback) 45.79 kB - -
@sentry/browser (incl. sendFeedback) 33.35 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.31 kB - -
@sentry/react (incl. Tracing) 50.84 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.88 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.12 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.01 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73 kB - -
CDN Bundle (incl. Tracing, Replay) 86.62 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.52 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.33 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.42 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.68 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.08 kB - -
@sentry/core/server 65.3 kB - -
@sentry/core/browser 52.37 kB - -
@sentry/node 122.35 kB +0.02% +21 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.22 kB - -
@sentry/node - without tracing 87.67 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 102.05 kB +0.02% +18 B 🔺
@sentry/aws-serverless 95.83 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 199.57 kB - -
@sentry/cloudflare (withSentry) 495.71 kB - -

View base workflow run

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.

2 participants