browser build of 6.6.0-prerelease-20260908162735 leaves bare `process;` (breaks Vite/Storybook/Chromatic)
Summary
[email protected] ships a bare top-level process; statement in the browser bundles. Evaluating that identifier in a browser environment (no Node process global) throws:
ReferenceError: process is not definedThis does not appear in the previous prerelease 6.6.0-prerelease-20260905051044.
Affected artifacts
| File | bare process; |
|---|---|
dist/styled-components.browser.esm.js |
1 (new) |
dist/styled-components.browser.cjs.js |
1 (new) |
dist/styled-components.esm.js / .cjs.js / .js / .min.js |
0 |
Snippet from styled-components.browser.esm.js (minified):
...}),g}process;var ut=new Set(["a","abbr","address",...Likely origin
Introduced with the RSC / Suspense style-emission fix:
- Commit: https://github.com/styled-components/styled-components/commit/1c0e309
- PR: https://github.com/styled-components/styled-components/pull/5808
Source looks consistent with a module-level process.env.NODE_ENV !== 'production' ? … : null in packages/styled-components/src/models/StyledComponent.ts (e.g. the new createRSCCache(...) path) whose dead-code elimination / browser replace left a residual process; instead of removing the whole statement.
Reproduction
- Install
[email protected]. - Resolve the browser ESM build (
dist/styled-components.browser.esm.js). - Search for a bare
process;(notprocess.env.NODE_ENV, nottypeof process). - Load that module in a browser (or Storybook/Chromatic verify) without a
processpolyfill.
Compare to 6.6.0-prerelease-20260905051044: same browser files have zero bare process;.
Why this bites Storybook / Vite / Chromatic
Many Storybook + Vite setups intentionally do not polyfill process (they only define things like process.env / process.env.NODE_ENV). Vite can replace process.env.NODE_ENV, but it does not rewrite a leftover bare identifier statement process;. Chromatic’s post-upload browser verify then fails with process is not defined even though storybook build itself may succeed.
We hit this in production CI after bumping only this prerelease; unit/Storybook-Vitest jobs stayed green, Chromatic verify failed.
Expected
Browser builds should not contain any free process identifier that must be evaluated at runtime. process.env.NODE_ENV checks should fully DCE / replace in browser bundles (or stay behind typeof process !== 'undefined' guards that never evaluate a bare process statement).
Workaround
Locally we can pnpm patch both browser builds to delete the stray process;, or pin the previous prerelease until a fixed publish lands.
Environment
- Package:
[email protected] - Prior good:
[email protected] - Consumed via Vite 8 + Storybook 10 + Chromatic CLI (browser verify)
Happy to test a canary that drops the bare process; from the browser builds.
Source: styled-components/styled-components