Repository navigation
feat(mobile): build mobile and mobile-web with React Compiler - #50713
Merged
Merged
Conversation
nwparker
force-pushed
the
nwparker/mobile-color
branch
2 times, most recently
from
November 27, 2026 10:56
ff089e0 to
d3d4591
Compare
Render code no longer reads theme or language from module state, so compiled memos keep dark/light and live language switches working. - colors/styles: the live `colors` object is gone; components read useMobileColors() and useThemedStyles(sheet). themedStyleSheet now returns a per-scheme handle; non-render code uses getMobilePalette(). - i18n: helpers that run during render take `t`/locale from hooks; useMobileTranslation's identity now follows the language revision under the compiler (a useMemo dep it never read was dropped). - memo deps the callback never reads now go through recomputeOn(). - New ratchet check:mobile-react-compiler-hazard-ratchet (baseline 0) guards render-path theme/language reads, translate getters, unread memo deps and discarded subscriptions. - Native: app.json experiments.reactCompiler; Metro resolves react/compiler-runtime for compiled shared files to mobile's React. - mobile-web: esbuild plugin compiles mobile sources with oxc-transform-react; eager bundle budget +1 MiB for memo caches.
nwparker
force-pushed
the
nwparker/mobile-color
branch
from
November 27, 2026 11:22
d3d4591 to
0fbafef
Compare
This was referenced Nov 28, 2026
AmoabaKelvin
added a commit
that referenced
this pull request
Nov 28, 2026
…ompiler build (#51418) * fix(mobile): stop the Tasks page crashing when it re-renders Since the page is built with React Compiler (#50713), Tasks faulted with React error #300 and the phone showed 'The downloaded app could not be opened'. The Tasks stage hooks wrote their fields into one shared model with Object.assign, so the compiler-memoized model kept its identity while its contents changed, and MobileTasksScreen called MobileTasksLegacySurface as a plain function that the compiler cached on that identity. A cache hit skipped the surface's hooks. Each stage now returns a new model object, the surface renders as JSX, and the compiler hazard ratchet flags components called as functions and mutated props or hook arguments. * fix(ratchets): count arrow components and destructured props in the compiler hazard rules * fix(ratchets): don't count writes to a rest-props object as mutating props
9 of 11 tasks
10 of 11 tasks
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.
ELI5
React Compiler makes the phone app skip re-rendering things whose inputs haven't changed. The app used to keep its colors and language in shared global objects and force screens to redraw when those changed. The compiler can't see those globals, so turning it on would have left screens stuck on the old theme or language. Now every screen gets its colors, styles and text from hooks the compiler can see, and the compiler is on for both the native app and mobile-web.
What Changed
Theme: the live, mutated-in-place
colorsobject is removed.useMobileColors()anduseThemedStyles(sheet).themedStyleSheet((colors, scheme) => …)now returns a per-scheme handle,{ resolve(scheme) }, instead of a getter object.getMobilePalette()orsheet.resolve(getMobileColorScheme()).useMobileColorScheme()calls that only forced re-renders are gone.Language:
t,localeorcolorsfrom hooks instead of calling module-leveltranslate()orgetUiIntlLocale().useMobileTranslation()now buildstfrom a module function keyed on the language revision. The olduseMemo(() => …, [revision])never readrevision, so once compiled it kept one identity and live language switching broke. The compiled build on the simulator caught this.Compiler hazards:
useMemo/useCallbackdeps that the callback never reads (invalidation keys such astick,revision,keyHash) now go throughrecomputeOn([dep], …)frommobile/src/hooks/recompute-on.ts, mirroring desktop. A few cases that keep a value per key use a newuseKeptByKey.Compiler on:
app.jsonsetsexperiments.reactCompiler: true. Metro now resolvesreact(forreact/compiler-runtime) from sharedsrc/sharedfiles to mobile's React; Expo compiles those files too.mobile-web-react-compiler-plugin.mjs) compilesmobile/{app,src,web-entry}withoxc-transform-react. It uses the same compiler as the desktop compat ratchet, andORCA_REACT_COMPILER=0opts out.Guard: new
pnpm check:mobile-react-compiler-hazard-ratchet, auto-run by the ratchet runner andcheck:changed, with baseline 0. It fails on:translate,getMobileUiLocale,getMobileColorSchemeandgetMobilePalette, followed transitively through module helpers across filestranslateuseSyncExternalStoreRemoving the
colorsexport and the getter sheets also makes typecheck reject the old patterns.Smaller changes: a few files were split to stay under
max-lines. The page-style constants moved out ofbuild-mobile-web-app-bundle.mjs. The pre-existinguse-open-bot-home.tsimplicit-any errors are fixed.Why
This is the alternative to keeping mobile off the compiler forever. Hook-returned values are the only inputs the compiler keys on, so theme and language have to come in as hook values. A remount key on the root was rejected: it would wipe navigation and input state on every theme or language switch.
Linked Issue
N/A (maintainer)
Visual Proof
iOS simulator, compiled dev-client build (compiler on). The Feed stayed mounted while I switched theme and language in Settings.
Testing
useMobileTranslationbug and its fix.pnpm check:changed: all 55 pass.mobiletypecheck andcheck:tests-typecheck: clean.mobilevitest: 59/59 pass.pnpm build:mobile-webbuilds and verifies.npx expo export --platform iosbundles: one React copy and 772 compiled memo caches.Performance
verify-mobile-web-app-bundle.mjs. Building mobile-web withORCA_REACT_COMPILER=0avoids the growth if we'd rather not ship it there.Risk
Level: Medium–High. The PR touches about 930 mobile files, mostly mechanically through a codemod plus per-directory hand fixes.
app.jsonexperiment, so dev clients need one rebuild. Release builds pick it up normally.src/sharedcreateAgentSessionRewindHookstill takes a modulesayfunction, so its disabled-reason text can lag a language switch until the next state change. That is the same trade-off desktop already ships.experiments.reactCompiler: falseand drop the esbuild plugin; the hook-based theme and i18n code is correct with or without the compiler.AI Disclosure
Written with Claude Code (Opus 5.5), using a ts-morph codemod plus parallel sub-agents per directory. I reviewed the changes and verified them on the simulator.
Agent skill upstream boundary
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (viacheck:changed+build:mobile-web)