Conversation
PR #6829 marked @sentry/react-native as side-effect free so bundlers can tree-shake unused exports. That flag is an unguarded, package-wide promise: if any shipped module ever runs code at import time, a bundler may drop it when its exports are unused, silently breaking the SDK in consumer bundles. Add scripts/check-side-effects.js, wired into `yarn lint`, which scans src/js (excluding Node-only tools/) and fails if a module has an import-time side effect: a bare side-effect import, or a top-level executed statement (call, assignment, IIFE, global write). Declarations are allowed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Contributor
Review feedback (Seer + Cursor Bugbot): the scan only flagged top-level
ExpressionStatements and clause-less imports, so a side effect wrapped in an
`if`/`for`/`while`/`try`/block — or an empty-binding `import {} from 'x'` —
slipped through while the lint stayed green.
Invert to an allowlist: permit only pure declarations at module top level
(function/class/interface/type/enum/namespace/variable/export/import-equals),
flag every other statement, and treat an import that binds nothing (incl.
`import {} from 'x'`) as a side-effect import. Type-only imports are erased,
so they're allowed. Exclude `vendor/` (audited third-party code) alongside
`tools/`, so the guard targets first-party SDK code.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit aabb031. Configure here.
antonis
marked this pull request as ready for review
October 5, 2026 08:28
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 free
to 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.
📢 Type of change
📜 Description
Adds a lint check that fails if any module in
packages/core/src/js(excluding the Node-onlytools/) runs code at import time.💡 Motivation and Context
Follow-up to #6829 / getsentry/sentry#126410.
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps