Repository navigation
build(mobile): split the Route A page into per-route chunks (OTA phase C, C1.5) - #21475
Conversation
…e C, C1.5) The page bundled as one 8.16 MB script because every route was a static import. The route manifest now defers each screen behind `import()`, the build is esm with splitting on, and the document loads the entry as a module. What the browser parses before the first route can paint drops from 8.16 MB to 908 KiB; the whole page still weighs the same. Two budgets hold it: the chunk count, which catches a split running away, and the bytes the entry reaches by static import, which catches it collapsing back. The second is the one that matters, and it is measured from esbuild's metafile because only that says which import is static. The RequireContext stays synchronous, since expo-router reads keys() to build the route tree before anything renders. A lazy module cannot answer `unstable_settings` or `ErrorBoundary`, which expo-router reads off the namespace, so a test holds that no route in the subtree exports either. The render check now waits for the route's own text: the entry's mount signal lands while the route chunk is still being fetched. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe mobile web route manifest now resolves synchronous route exports with esbuild and rejects unresolved star re-exports. The web entry adds a Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk remains in the reviewed split-bundle changes. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed context, rationale, implementation details, sizes, bounds, testing, and review history. However, it omits several required template sections or equivalent content, including ELI5, Linked Issue with an issue reference, Visual Proof or an explicit N/A statement, Testing with the required checklist, Agent skill upstream boundary, Notes, and the final Checklist. Resolution Add the missing required sections. Include a valid issue reference after "Fixes #", provide before-and-after visual proof or state "N/A" with a reason, add the Testing checklist and platform coverage, complete the Agent skill upstream boundary section, address the Notes items, and complete the final Checklist.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 28102ffb-7081-4c6a-9e60-f271a742472c
📒 Files selected for processing (6)
config/scripts/build-mobile-web-app-bundle.mjsconfig/scripts/build-mobile-web-app-bundle.test.mjsconfig/scripts/mobile-web-app-render.test.mjsconfig/scripts/mobile-web-app-route-manifest.mjsconfig/scripts/verify-mobile-web-app-bundle.mjsmobile/web-entry/index.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
ℹ️ Minor suggestions only. The split itself is sound — I read the whole diff and checked the load-bearing claims against expo-router
55.0.18and esbuild directly.
Reviewed changes
- Per-route lazy chunks —
renderMobileWebAppRouteManifestemits{ default: lazy(() => import(module)) }per key; esbuild runsformat: 'esm'+splitting: truewith content-hashedchunkNamesand a pinnedentryname, and the document's script tag becomestype="module". - Entry-closure budget — new
entryStaticClosurewalks static imports from the entry;MAX_ENTRY_BYTES(3 MiB),MAX_CHUNKS(64) andMAX_ASSETS(128) bound the split, and the verifier reads both new numbers off the fresh build. - Suspense and render-check timing —
RootProviderswraps children inSuspense, and the render check now waits on the route's own text instead of the entry mount signal. - Lazy-export guard —
routeModuleNamedExportspins that no mounted route exportsunstable_settings/ErrorBoundary.
ℹ️ The guard protecting the lazy manifest is not run by the builder
bundleMobileWebApp never calls routeModuleNamedExports; only build-mobile-web-app-bundle.test.mjs does. So pnpm build:mobile-web:app on a checkout where a route has grown unstable_settings would still emit a bundle that silently drops it, and only the CI test job would catch it. There is also no implemented way to make one route static, despite the PR body saying a route "can opt back to a static import" — every key is hardcoded to lazy in the generator.
Technical details
# Guard runs in tests only, with no static-import escape hatch
## Affected sites
- `config/scripts/build-mobile-web-app-bundle.mjs:201` — `bundleMobileWebApp` builds the manifest and calls esbuild without checking `routeModuleNamedExports`.
- `config/scripts/mobile-web-app-route-manifest.mjs:92` — `renderMobileWebAppRouteManifest` hardcodes `lazy(() => import(module))` for every key, so there is no per-route static option.
- `config/scripts/build-mobile-web-app-bundle.test.mjs:134` — the only caller of the guard.
## Required outcome
- A route that grows a synchronous expo-router export fails `build:mobile-web:app` itself, not only the test run; and the path to "make this route static" is either implemented or documented.
## Open questions for the human
- Is editing `renderMobileWebAppRouteManifest` by hand the intended remediation, or should the manifest generator accept a per-route static list?ℹ️ Nitpicks
config/scripts/verify-mobile-web-app-bundle.mjs:17citesMOBILE_WEB_SHELL_MAX_ASSETS(an Android-only constant). The cross-platform ceiling isMOBILE_WEB_BUNDLE_MAX_ASSETS = 256insrc/shared/mobile-web-bundle/manifest-contract.ts, which the mobile reply schema and the native shell both enforce.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…egex
`export { x as ErrorBoundary }`, `export class ErrorBoundary` and a re-export all
reach the namespace without matching the declaration pattern the guard was
matching, so the lazy manifest dropped the boundary and the page painted blank.
A star re-export is now reported rather than read as clean.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Measured: statically importing one route already breaks the 3 MiB bound for 5 of the 14. The hatch only works for a layout node, which is the only place expo-router reads a synchronous export from. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
64 was three routes of headroom over the 53 chunks 14 routes measure, so C2's routes would have failed on a number measured before they existed. Four per route plus 16 tracks the measured slope; the entry-bytes bound stays the real budget. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
expo-router wraps every screen in its own, so this one never fires; all nine render checks stay green without it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e's chunk Goes red with splitting off: the tasks screen paints out of the entry and no new script is fetched. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…path hash esbuild's [hash] is over the metafile's input keys, which are paths relative to absWorkingDir, so a checkout at another depth or with node_modules as a symlink named a byte-identical chunk differently and shipped a different buildId for one commit. Outputs are now renamed leaves-first to the sha256 of their final bytes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The guard ran only in a test while the docstring said it failed the build. It now runs in bundleMobileWebApp and names the route and the export. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
ℹ️ No critical issues. The delta since the last review is clean — the guard rewrite reads names off esbuild's own parse and fails closed on
export *, and I verified the metafileexportsfield and the star-export output shape directly against the pinned esbuild0.25.12. Two documentation-accuracy notes below.
Reviewed changes
- Guard reads the namespace, not source text —
routeModuleNamedExportsis replaced byrouteModuleSynchronousExports, which parses each route with esbuild (bundle: false,metafile: true) so aliased, class, and re-exported names are all caught, and an unresolvedexport *is returned separately so the guard fails closed. - Chunk ceiling derived from the route count —
MOBILE_WEB_APP_BUNDLE_MAX_CHUNKS = 64becomesmobileWebAppBundleMaxChunks(routeCount) = 4 * routeCount + 16, and the verifier readsfirst.routeKeys.lengthoff the fresh build. - Entry
Suspenseremoved —RootProvidersnow renders<RpcClientProvider>{children}</RpcClientProvider>, relying on expo-router's per-screen boundary, pinned by a test againstuseScreens.js. - Render check refactor and navigation test —
openPage/waitForRoutesplit out; a new test navigates viahistory.pushState+popstateand asserts a chunk is fetched and the tasks screen paints.
ℹ️ The PR description still describes the pre-refactor mechanism
Three claims in the PR body no longer match the branch head: it says RootProviders wraps children in one Suspense (removed in 2ee360a), names routeModuleNamedExports (renamed to routeModuleSynchronousExports in 27fdedcf), and lists MOBILE_WEB_APP_BUNDLE_MAX_CHUNKS = 64 as a verifier bound (replaced by mobileWebAppBundleMaxChunks in b399bb8). The "How" and "Bounds in the verifier" sections are the map a reviewer reads first, so refreshing them keeps the description from contradicting the code.
Technical details
# PR description is stale relative to the branch
## Affected sites
- PR body "How" — "`RootProviders` wraps children in one `Suspense`" (no longer true; `mobile/web-entry/index.tsx:19` has no boundary).
- PR body "How" — "`routeModuleNamedExports` in the manifest generator pins that" (renamed to `routeModuleSynchronousExports`).
- PR body "Bounds in the verifier" — "`MOBILE_WEB_APP_BUNDLE_MAX_CHUNKS = 64`" (replaced by `mobileWebAppBundleMaxChunks(routeCount)` in `config/scripts/verify-mobile-web-app-bundle.mjs:40`).
## Required outcome
- The description's mechanism and bounds sections match the branch head.ℹ️ Nitpicks
mobile/web-entry/route-manifest.ts:5still says the generated body replaces Metro'srequire.contextwith "the static imports esbuild needs"; the manifest now emits lazyimport()entries, so "static" is no longer accurate.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…e images A flat 128 stopped agreeing with the chunk ceiling at 18 routes, where the asset count would have failed first and named the count instead of the split. Chunks plus images plus the document keeps the chunk ceiling the one that trips. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The builder's test file passed 600 lines. The route manifest, the synthesized RequireContext and the web entry are their own subject and move together. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Without .js as jsx the guard reported a React Native .js route carrying JSX as "JSX syntax extension is not enabled" instead of reading its exports. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
"some new script arrived" passed on any fetch. The builder now names the chunk each route lands in, read off the metafile, and the check asserts that exact path arrived and was not already loaded. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
esbuild writes metafile input keys after resolving symlinks, so every scratch route tree under /var on macOS reached no output and failed the build. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Round 2 fixed on |
…'s map The derived ceiling had no upper bound, and the native shells return null for a manifest over their own 256 rather than truncating it. At 42 images the formula crosses that at 50 routes, inside what Phase C adds, so the build would stay green while the phone got nothing. The number is read from the contract through esbuild, not restated here. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Both throws only ran through a whole bundle before, where neither can be provoked. A cycle and a route no output claims are now asserted directly; each test goes red when its throw is removed. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The route-export guard fails this script by design, and a raw stack put the route and the export name under twelve frames of node internals. Mirrors the verifier's exit; the message is printed as thrown because every throw on this path already names its source. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Round 3 fixed on |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Delta since the prior pullfrog review at 9c01300 (7 commits, head bbce21e):
- Content-hash output renaming —
renameOutputsByContentrenames every emitted output to the sha256 of its final bytes, leaves first, rewriting each importer's/assets/<child>specifier before hashing it, sobuildIdis a function of the bytes rather than of the checkout path. An output cycle throws. - Route-to-chunk lookup —
routeChunkNamesreads each route's owning output from the esbuild metafile inputs andrealpathSyncs the route path before matching, covering scratch trees reached through a symlink. - Build-time export guard —
assertRoutesCarryNoSynchronousExportsnow runs insidebundleMobileWebApp, so a route that growsunstable_settings/ErrorBoundary(aliased, class, re-exported, or viaexport *) failsbuild:mobile-web:apprather than only a test. - Shared route-source loaders —
ROUTE_SOURCE_LOADERSis spread into both the guard's parse and the builder's loader table, with a parity test. - Derived asset ceiling —
mobileWebAppBundleMaxAssets(routeCount, imageCount)replaces the flat 128, so the chunk ceiling always trips first and names the split rather than the count. - Test coverage — route-manifest tests split into their own file; the navigation test asserts the tasks route's own chunk arrives; a two-depth test pins path-independent naming.
I checked renameOutputsByContent directly against the pinned esbuild 0.25.12 on a split graph with a shared chunk: every output is named by the sha256 of its post-rewrite bytes and no stale /assets/<old> reference survives. The guard's build-time wiring and the path-independent buildId close the two substantive concerns from the earlier reviews.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Delta since the previous review at bbce21e (3 commits, head 6ae5878):
- Asset ceiling bounded by the shell's own map —
readMobileWebBundleMaxAssetsevaluatesMOBILE_WEB_BUNDLE_MAX_ASSETSfrom the shared manifest contract (esbuild-bundles the.ts, imports its data URL), andassertAssetCeilingFitsShellfails the verifier when4r + 16 + images + 1would exceed it. Sincebuild:mobile-web:appis builder + verifier, this is a real build failure, not a comment. - Hard-stop coverage — direct tests for the two throws in the content-addressed naming: an output cycle and a route the metafile maps to no output.
- One-line builder failure — the direct-invocation path catches, prints
error.message, and exits 1 instead of surfacing a stack for the by-design route guards.
build-mobile-web-app-bundle.test.mjs passes locally (13 non-bundling tests, 25 bundling skipped without mobile deps), including the new ceiling boundary (49 routes → 255, 50 → 259 over 256) and both hard stops; oxlint is clean. The round-3 guard closes a gap the earlier rounds did not cover.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

What this is
OTA phase C, step C1.5: the Route A page bundle (
build:mobile-web:app, C0.7) is cut into per-route chunks. The shipped bundle is unchanged:build:mobile-weband packaging still build Phase A's bootstrap; this only changes the CI-proven app bundle that C1 flipsbuild:releaseto. Released phones unchanged; no RPC operation, no recorder file.Why
C0.7 measured one 8.16 MB script at 78% of the shell's 10 MiB per-asset cap, and found esbuild
splittinginert against static imports. The first migrated domain (C1, the worktree list) needs about a quarter of that closure, and every later route would grow the one script toward the cap. Splitting holds the parse-before-first-paint cost flat as routes migrate.How
{ default: lazy(() => import(module)) }per key, so theRequireContextexpo-router reads stays synchronous (it walkskeys()to build the tree before rendering) and only the screen behind each key is deferred.RootProviderswraps children in oneSuspense.format: 'esm',splitting: true; the document's script tag becomestype="module". esbuild's[hash]chunk name is only a placeholder: it hashes input paths relative tomobile/, so a symlinked node_modules or a deeper checkout renames chunks. The builder renames every output to the sha256 of its final bytes, leaves first, rewriting each importer's/assets/<name>specifier before hashing it, so the bundle is a function of bytes only. A test builds one route tree from two depths and compares chunk names and buildId.unstable_settingsorErrorBoundaryin any form (esbuild metafile parse per route, star re-exports fail closed), since a lazy module cannot answer expo-router's synchronous reads.script-src 'self'already covers same-origin dynamic import; CSP unchanged. The C1 probe provedimport()resolves through the scheme handler on both platforms.Sizes (bytes)
/h/<id>The 14 route chunks total 1.75 MB (session 1.30 MB, tasks 286 KB, worktree list under 1 KB); 36 shared chunks hold the rest. Content-hash names add 21 KB over esbuild's short names.
Bounds in the verifier
MOBILE_WEB_APP_BUNDLE_MAX_ENTRY_BYTES = 3 MiB: the entry plus everything it reaches by static import. Proven red by mutation:splitting: falsefails at 8.2 MB; every route static fails at 8.16 MB. This is not a per-route opt-out: 5 of 14 routes (session 7.16 MiB, tasks 5.91, source-control 5.78, review 5.77, files/preview 5.21) cannot be static. The hatch exists only for layout nodes, where expo-router readsunstable_settings, and the one layout measures 2.22 MiB static.mobileWebAppBundleMaxChunks(routeCount) = 4 × routes + 16(72 at 14 routes, 53 measured): esbuild emits a chunk per distinct importer set, about three per route at the top, so the ceiling follows the route count instead of failing C2 on an arbitrary number.mobileWebAppBundleMaxAssets(routeCount, imageCount)= chunk ceiling + images + the document, so the chunk ceiling always trips first. The verifier fails when that derived ceiling passes what the phone accepts, read fromMOBILE_WEB_BUNDLE_MAX_ASSETSin the shared manifest contract (bundled by esbuild since the module's imports carry no extension), so the number appears nowhere in the scripts; green at 49 routes, red at 50.buildIdreproducible across shallow and deep checkouts with symlinked and real node_modules.Verification
Mobile tsc 0; oxlint 0; anti-slop 0; oxfmt clean; changed-code gate 0 new findings; builder, route-manifest, render, verifier, overrides, Phase A builder and parity tests pass; the render check paints
Host not foundthrough the lazy path and the navigation test fetches the tasks chunk in headless Chromium.Reviews
Round 1 (SHIP AFTER FIXES): the export guard regexed source and missed aliased, class and re-exported forms (proved end to end: boundary dropped, page blank, CI green) → esbuild metafile parse, run in the build; the "one route static" claim was false for 5/14 routes → comment corrected;
MAX_CHUNKS64 had ~3 routes of headroom → derived formula; aSuspensethat never fires (expo-router wraps every screen; a test reads itsuseScreens.jsso the premise cannot rot) → deleted; client-side navigation untested → pinned. Round 2 (SHIP AFTER FIXES): buildId was path-dependent through esbuild's chunk hashing (fresh checkout, same shape → same id; one directory deeper → different id; C0.7's base identical at both) → content-hash rename with a two-depth test; the asset ceiling overtook the chunk ceiling from 18 routes → derived; the guard lacked the builder's.jsJSX loader → shared table; the navigation test asserted any new script → the route's own chunk. Round 3 (targeted at the rename): correct on three tree shapes, both ordering mutations caught; the derived asset ceiling had lost its pin under the shell's hard limit → guard against the contract constant; direct tests for the two throws; one-line builder failure. CodeRabbit's error-boundary finding (a rejected lazy import has no boundary) is real and routed to C1.1, where the entry mounts oninitand can report over the bridge.