Skip to content

ref(overlay): import NODE_ENV/defined from leaves to break import cycle#116805

Merged
JoshuaKGoldberg merged 5 commits into
masterfrom
ref/decycle-overlay-tooltip
Jun 4, 2026
Merged

ref(overlay): import NODE_ENV/defined from leaves to break import cycle#116805
JoshuaKGoldberg merged 5 commits into
masterfrom
ref/decycle-overlay-tooltip

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

Why

Sentry's frontend type-import graph forms a large strongly-connected component (SCC). run-on-changed counts import type edges, 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/overlay and utils/useHoverOverlay were each in the SCC for one trivial reason: they import runtime values from the sentry/constants and sentry/utils god-barrels (which are themselves in the cycle).

What

  • NODE_ENV is now imported from the existing sentry/constants/env leaf (in both files).
  • defined is extracted into a new sentry/utils/defined leaf; the sentry/utils barrel re-exports it so every existing sentry/utils consumer is untouched. overlay imports it from the leaf.

With overlay and useHoverOverlay no longer importing into the cycle, they leave the SCC — and so does components/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.

`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>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 3, 2026
…-tooltip

# Conflicts:
#	static/app/utils.tsx
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review June 4, 2026 15:43
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner June 4, 2026 15:43
Comment thread static/app/utils.tsx Outdated
@@ -1,14 +1,12 @@
export {defined} from 'sentry/utils/defined';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sus on the re-export. i know this one is used in a LOT of places though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.
Comment thread static/app/utils.tsx
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.
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner June 4, 2026 16:47
@JoshuaKGoldberg JoshuaKGoldberg merged commit f2fdd3e into master Jun 4, 2026
77 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the ref/decycle-overlay-tooltip branch June 4, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants