Repository navigation
fix(native): share the :root variable registries across a dual-package split - #410
Open
YevheniiKotyrlo wants to merge 2 commits into
Open
YevheniiKotyrlo wants to merge 2 commits into
YevheniiKotyrlo wants to merge 2 commits into
Conversation
This was referenced Aug 14, 2026
Contributor
Author
No device frameThe defect needs a bundle that loads two copies of this package, so the description carries the colour I measured on a device, and the tests load the second copy with |
…e split Re-cut onto main (a5002c5). The test reads the registries through jest.requireActual, because main's jest runs no dynamic import.
YevheniiKotyrlo
force-pushed
the
fix/root-variable-registry-dual-package
branch
from
October 11, 2026 12:35
0a4018c to
0f7e7f5
Compare
This branch has not been deployed
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.
Problem
The
exportsmap givesimportandrequiredifferent builds, and Metro resolves that condition per requesting module. A bundle that pullsreact-native-cssfrom both a CommonJS dependency and ES-module source therefore evaluatesnative-internal/root.tstwice, and each copy creates its own:rootvariable registries. The compiled stylesheet is injected once, into the copy the app's.cssmodule resolved, so every component resolving through the other copy readsvar()from empty registries and renders without the value.expo-router'sLinkis one such component: its compiled CommonJS bindsdist/commonjs, while app source bindsdist/module. Atext-danger-foregroundlink on a dark surface paintedrgb(0, 0, 0)instead ofrgb(251, 44, 54)on Android. I measured that on 3.0.7.mainkeeps the sameexportsmap and the same module-scope registries.style-collection.tsandvariables.tsxalready keep their state onglobalThisfor this reason.root.tsdoes not.Solution
The registries live on
globalThis, as their siblings' state does, and are created and seeded in one step. The seed writes--__rn-css-remand the platform colour. If only the creation were shared, a copy that loads after the stylesheet inject would run the seed again and reset a project's:root { font-size: 16px }to 14.Tests
src/__tests__/native/root-variable-registry.test.ts:globalThis.jest.resetModules()against the sameglobalThis, binds the same registries and keeps a rem the first copy set to 16.On
mainboth fail; both pass here. Creating the registries in every copy fails the second test.Verification
On Windows with Node 26:
yarn lintcleanyarn typecheckcleanyarn test --maxWorkers=2 --coverage: 1333 passed, 4 failed. The 4 are the babel cases that also fail onmainon this machine.yarn buildcleanyarn example expo export --platform webexportedFixes #409, which reports the same split on iOS with the inspector showing two
rootVariables.Merge order
This overlaps #392; I'll re-cut whichever of the two lands second.
It also shares lines with #412 (
native-internal/root.ts); whichever lands second rebases.Base
Re-written on
main(a5002c5).