Repository navigation
fix(scraps): Remove process env checks from theme - #127595
Merged
Merged
Conversation
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>
natemoo-re
approved these changes
Oct 15, 2026
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.
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 readprocess.env.IS_ACCEPTANCE_TESTwhen the module loaded. Vite and webpack 5 only replaceNODE_ENV, so in apps built with them, importing@sentry/scraps/theme(or the root entry) from the published package could throwprocess is not defined. The Sentry app wasn't affected becausersbuild.config.tsdefines both values.Changes
theme.tsx: removedIS_ACCEPTANCE_OR_TESTINGandEMPTY_TRANSITION. Framer transitions are now the same in every environment. The app already turns off animations in acceptance and Jest runs withMotionGlobalConfig.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 sharedno-restricted-syntaxselectors into arestrictedSyntaxconst, so the Scrapssrcoverride can add to them instead of replacing them. Added two Scraps-only selectors. They flag any use ofprocessexceptprocess.env.NODE_ENV, which every bundler replaces and whichslot.tsxuses for its dev warning. They also flagglobalThis/window/self.process.Verification
process.env.FOO,typeof process,process.env['NODE_ENV'],const {env} = process,globalThis.processandwindow.process. It allowsprocess.env.NODE_ENVand{process: 1}.process. Running it against the previoustheme.tsxflagged theIS_ACCEPTANCE_TESTline.forwardRefprobe). App files aren't affected by the Scraps-only rule.static/packages/scraps,static/app/components/coreandoxlint.config.ts: no new problems (only existing fake-timer warnings).oxfmt --checkpasses.pnpm test(240 tests) andpnpm run verifypass. The builtdistnow has onlyprocess.env.NODE_ENV(inslot.js).views/authV2,core/modalandcore/slideOverPanel(155 tests) passes.pnpm run typecheckpasses.via nate.
--
View Junior Session [Sentry]