Skip to content

fix(scraps): Remove process env checks from theme - #127595

Merged
natemoo-re merged 2 commits into
masterfrom
nate/scraps-no-process
Oct 15, 2026
Merged

natemoo-re merged 2 commits into
masterfrom
nate/scraps-no-process

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #127513 and the Bugbot comment on it.

Scraps is built as browser ESM with rslib. In that format rslib leaves process.env.* untouched (docs). The theme read process.env.IS_ACCEPTANCE_TEST when the module loaded. Vite and webpack 5 only replace NODE_ENV, so in apps built with them, importing @sentry/scraps/theme (or the root entry) from the published package could throw process is not defined. The Sentry app wasn't affected because rsbuild.config.ts defines both values.

Changes

  • theme.tsx: removed IS_ACCEPTANCE_OR_TESTING and EMPTY_TRANSITION. Framer transitions are now the same in every environment. The app already turns off animations in acceptance and Jest runs with MotionGlobalConfig.skipAnimations = true (static/app/bootstrap/commonInitialization.tsx, tests/js/setup.ts). In framer-motion 12.38 that makes every animation instant with no delay, which covers everything the theme override did. Spring transitions already relied on it.
  • theme.spec.tsx: replaced the NODE_ENV/IS_ACCEPTANCE_TEST test matrix with a check that motion values don't depend on the environment.
  • oxlint.config.ts: moved the shared no-restricted-syntax selectors into a restrictedSyntax const, so the Scraps src override can add to them instead of replacing them. Added two Scraps-only selectors. They flag any use of process except process.env.NODE_ENV, which every bundler replaces and which slot.tsx uses for its dev warning. They also flag globalThis/window/self.process.

Verification

  • A probe file showed the new rule flags process.env.FOO, typeof process, process.env['NODE_ENV'], const {env} = process, globalThis.process and window.process. It allows process.env.NODE_ENV and {process: 1}.process. Running it against the previous theme.tsx flagged the IS_ACCEPTANCE_TEST line.
  • The shared selectors still apply in the app (checked with a forwardRef probe). App files aren't affected by the Scraps-only rule.
  • oxlint on static/packages/scraps, static/app/components/core and oxlint.config.ts: no new problems (only existing fake-timer warnings). oxfmt --check passes.
  • Scraps pnpm test (240 tests) and pnpm run verify pass. The built dist now has only process.env.NODE_ENV (in slot.js).
  • App Jest for views/authV2, core/modal and core/slideOverPanel (155 tests) passes. pnpm run typecheck passes.
  • Not run: acceptance tests and the full app Jest suite.

via nate.

--

View Junior Session [Sentry]

Scraps ships ESM for browsers, and rslib keeps process.env reads as-is. The
theme read process.env.IS_ACCEPTANCE_TEST at module load, so importing the
theme from the published package could throw "process is not defined" in
bundlers that only replace NODE_ENV.

The app already disables animations in acceptance and Jest runs through
MotionGlobalConfig.skipAnimations, which makes every framer transition
instant. Drop the duplicate theme-level gating and add a Scraps lint rule
that allows only process.env.NODE_ENV.

Co-Authored-By: Nate Moore <nate.moore@sentry.io>
@sentry-junior
sentry-junior Bot requested review from a team as code owners October 15, 2026 18:46
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 15, 2026
@natemoo-re
natemoo-re enabled auto-merge (squash) October 15, 2026 18:59
@natemoo-re
natemoo-re merged commit fcadbb2 into master Oct 15, 2026
80 checks passed
@natemoo-re
natemoo-re deleted the nate/scraps-no-process branch October 15, 2026 19:05
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.

1 participant