ref(overlay): import NODE_ENV/defined from leaves to break import cycle#116805
Merged
Conversation
`overlay` and `useHoverOverlay` were pulled into the frontend type-import strongly-connected component (SCC) solely by value-imports from the `sentry/constants` and `sentry/utils` god-barrels: - `NODE_ENV` now comes from the `sentry/constants/env` leaf - `defined` is extracted to a `sentry/utils/defined` leaf (the `sentry/utils` barrel re-exports it, so existing consumers are untouched) With those two modules out of the cycle, `core/tooltip` — one of the most widely-imported core components — and its dependents leave the SCC too. Largest SCC drops 1867 -> 1770. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-tooltip # Conflicts: # static/app/utils.tsx
ryan953
reviewed
Jun 4, 2026
| @@ -1,14 +1,12 @@ | |||
| export {defined} from 'sentry/utils/defined'; | |||
Member
There was a problem hiding this comment.
sus on the re-export. i know this one is used in a LOT of places though.
Member
Author
There was a problem hiding this comment.
Agh another one snuck in. I'll remove this and tell future agents to stop re-exports.
...I also am dubious that this helper is worth it in so many places. I'll start that conversation separately.
ryan953
approved these changes
Jun 4, 2026
This was referenced Jun 4, 2026
The barrel re-export (export {defined} from 'sentry/utils/defined') let
consumers keep importing defined from the sentry/utils barrel. That does
not shrink the import cycle and risks re-coupling the barrel to the leaf,
so drop it and point every consumer at sentry/utils/defined directly.
ryan953
approved these changes
Jun 4, 2026
The prior commit dropped the sentry/utils defined re-export but only repointed static/app and tests/js. The vendored getsentry frontend (static/gsApp, static/gsAdmin) also imported defined from sentry/utils, which broke its typecheck and jest. Repoint those consumers too.
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.
Why
Sentry's frontend type-import graph forms a large strongly-connected component (SCC).
run-on-changedcountsimport typeedges, so this cycle makes its "impacted files" analysis flag a huge fraction of the app for almost any change. We're shrinking the SCC by repointing barrel imports onto pure leaf modules.components/overlayandutils/useHoverOverlaywere each in the SCC for one trivial reason: they import runtime values from thesentry/constantsandsentry/utilsgod-barrels (which are themselves in the cycle).What
NODE_ENVis now imported from the existingsentry/constants/envleaf (in both files).definedis extracted into a newsentry/utils/definedleaf; thesentry/utilsbarrel re-exports it so every existingsentry/utilsconsumer is untouched.overlayimports it from the leaf.With
overlayanduseHoverOverlayno longer importing into the cycle, they leave the SCC — and so doescomponents/core/tooltip(one of the most widely-imported core components) along with its dependents.Impact
Largest type-import SCC drops 1867 → 1770 (−97).
Part of a series of SCC-shrinking PRs. Identified via a greedy independent-cut analysis of the type-import graph.