Skip to content

fix: remove DOM code from React Native build - #5677

Merged
quantizor merged 1 commit into
mainfrom
fix/native-document-undefined
Mar 19, 2026
Merged

quantizor merged 1 commit into
mainfrom
fix/native-document-undefined

Conversation

@quantizor

Copy link
Copy Markdown
Contributor

Summary

  • Replace instanceof Keyframes with a branded Symbol.for('sc-keyframes') check in flatten.ts
  • Convert value imports of Keyframes and StyleSheet to import type in flatten.ts, preventing rollup from bundling the DOM sheet stack into the native build
  • Native bundle drops from ~44KB to ~14KB with zero document/window references

Test plan

  • All 501 web tests pass
  • All 37 native tests pass
  • Build passes with bundlewatch check
  • Native bundle verified to contain zero document references
  • Manual test on RN 0.79+/0.81 project

Closes #5610

Replace `instanceof Keyframes` with a branded symbol check and convert
value imports to `import type` in flatten.ts. This prevents rollup from
bundling the entire DOM sheet stack (Sheet → Tag → dom → Rehydration)
into the native build, fixing crashes on RN 0.79+ where Hermes fails
at module evaluation when encountering `document` references.

Closes #5610
@changeset-bot

changeset-bot Bot commented Mar 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9bd5282

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
styled-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@quantizor
quantizor marked this pull request as ready for review March 19, 2026 04:59
@quantizor
quantizor merged commit 1203f80 into main Mar 19, 2026
5 checks passed
@quantizor
quantizor deleted the fix/native-document-undefined branch March 19, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React native 0.81 support

1 participant