Skip to content

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

Merged
JPeer264 merged 1 commit into
developfrom
jp/side-effects
Sep 2, 2026
Merged

build(rollup-utils): Skip bare side-effect imports for sideEffects: false externals#23674
JPeer264 merged 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.

@JPeer264
JPeer264 requested review from Lms24, chargome and timfish August 27, 2026 09:08
@JPeer264 JPeer264 self-assigned this Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.56 kB -5.74% -1.74 kB 🔽
@sentry/browser - with treeshaking flags 26.92 kB -5.44% -1.55 kB 🔽
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB +0.02% +4 B 🔺
@sentry/browser (incl. Tracing) 48.86 kB +0.58% +277 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.87 kB +0.57% +275 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.79 kB +0.64% +327 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.35 kB +0.42% +368 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.75 kB +0.5% +385 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 93.04 kB +0.37% +334 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 106 kB +0.58% +609 B 🔺
@sentry/browser (incl. Feedback) 46.05 kB -3.37% -1.6 kB 🔽
@sentry/browser (incl. sendFeedback) 33.62 kB -4.28% -1.5 kB 🔽
@sentry/browser (incl. FeedbackAsync) 38.73 kB -3.85% -1.55 kB 🔽
@sentry/browser (incl. Metrics) 29.51 kB -5.56% -1.74 kB 🔽
@sentry/browser (incl. Logs) 29.8 kB -5.46% -1.72 kB 🔽
@sentry/browser (incl. Metrics & Logs) 30.43 kB -5.34% -1.72 kB 🔽
@sentry/react 30.3 kB -5.56% -1.78 kB 🔽
@sentry/react (incl. Tracing) 51.06 kB +0.58% +292 B 🔺
@sentry/vue 35.73 kB +1.1% +388 B 🔺
@sentry/vue (incl. Tracing) 51.13 kB +1.17% +589 B 🔺
@sentry/svelte 28.59 kB -5.74% -1.74 kB 🔽
CDN Bundle 30.35 kB -3.99% -1.26 kB 🔽
CDN Bundle (incl. Tracing) 49.5 kB +1.25% +608 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.58 kB -3.62% -1.22 kB 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 51.41 kB +1.18% +596 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB -1.53% -1.13 kB 🔽
CDN Bundle (incl. Tracing, Replay) 87 kB +0.61% +520 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.86 kB +0.63% +551 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.93 kB +0.81% +741 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.83 kB +0.75% +701 B 🔺
CDN Bundle - uncompressed 89.95 kB -4.16% -3.9 kB 🔽
CDN Bundle (incl. Tracing) - uncompressed 147.56 kB +0.55% +807 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.24 kB -3.9% -3.9 kB 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.25 kB +0.53% +807 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB -1.61% -3.67 kB 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.05 kB +0.4% +1.04 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.73 kB +0.39% +1.04 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.75 kB +0.38% +1.05 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.42 kB +0.37% +1.05 kB 🔺
@sentry/nextjs (client) 53.68 kB +0.74% +391 B 🔺
@sentry/sveltekit (client) 49.29 kB +0.6% +293 B 🔺
@sentry/core/server 65.82 kB +0.68% +441 B 🔺
@sentry/core/browser 51.94 kB +0.42% +217 B 🔺
@sentry/node 123.85 kB +5.52% +6.47 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.53 kB added added
@sentry/node - without tracing 88.15 kB +7.65% +6.26 kB 🔺
@sentry/aws-serverless 96.5 kB +5.7% +5.2 kB 🔺
@sentry/cloudflare (withSentry) - minified 201.21 kB -5.98% -12.78 kB 🔽
@sentry/cloudflare (withSentry) 500.7 kB -5.34% -28.23 kB 🔽
@sentry/node - without channel injection 103.28 kB added added

View base workflow run

…false` externals

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@JPeer264
JPeer264 merged commit 3251e33 into develop Sep 2, 2026
283 of 284 checks passed
@JPeer264
JPeer264 deleted the jp/side-effects branch September 2, 2026 05:43
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