Repository navigation
fix(universal): link Lynx main-thread output by importing only used helpers - #1391
Merged
Merged
Conversation
…elpers Universal compiler output imported every region helper from its renderer module, used or not. The Lynx main thread's standalone runtime did not export universalBlock, so esbuild rejected even a plain `<view />` component. - The compiler records each helper reference as it emits it and imports only those, so a module never names a helper its output does not call. - @octanejs/lynx/main-renderer exports universalBlock. On the one-shot first screen a block renders like a taken @if arm, one range at its position, so host IDs match the background. - octane/universal(/native) and the Lynx main renderer export useFormState. The universal compiler already accepted that import, but no runtime provided it. Closes #1315 Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 29, 2026 12:29
Merged
2 of 5 tasks
trueadm
added a commit
that referenced
this pull request
Oct 2, 2026
… fixtures in PR CI (#1583) * fix(compiler): keep cached-array regions on signal-capable child holes Since #1069, a renderable `{expr}` hole in a DOM template lowers to the signal-capable `bindSignalChild` binding whenever the module can carry a signal handle, which is any identifier hole. That branch returned before the only-child path that wraps a compiler-owned calculated descriptor array in its `compilerCacheArray` auto-memo region, so an unchanged array inside a component-children body reached `childSlot` for the list and each item on every parent render. The hook-memo provider-output guard `inline_memo_snapshot_slots` rose from 0 to 256 per 128 updates. Wrap the signal-capable binding in the same region. Only an unchanged plain data array can hit; a signal handle or any other value fails `compilerCacheArray` and rebinds every render, and the existing identity miss rebuilds a previously cached array after the hole held something else. The new value-position case switches one calculated child between cached rows and a signal handle. It fails in the production compile when the region's identity miss is dropped, and passes on the uncached path too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE * test(bench): report hook-memo scenarios net of the root update driver Eight hook-memo ratio guards breached on main (eligible hit functions 704, eligible hit arrays 3,872, and so on) while the inline memo tier's own counts were unchanged. Per-site attribution put every excess event in the runtime's same-component `root.render()` path: the per-update request/retry closures and the root render transaction's undo log, OffscreenCapture arrays and committed-transaction queue, 2 functions and 10 arrays per render in both compiler variants. Bisecting `run.mjs` output found 5f7a457 (#833, root render transactions) to be the first breaching commit; it did not touch this benchmark, and its documented root-transaction cost is unrelated to hooks. Add a hook-free Driver control that runs the identical phase sequence, report every scenario net of the driver's same-phase counts (failing the run if a scenario falls below it), and keep raw counters in the JSON metadata. Two new guards pin the driver's per-update cost at its current 2 functions and 10 arrays so the root update path cannot grow silently. The corrected runner reports identical net counts on both sides of #833, and against 814a3c1 (before closure-free memo lowering) it still breaches the same seven memo guards the original measurement recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE * ci: check the Lynx bench fixture contracts on every pull request The weekly Bench workflow runs the Lynx table-stage and list fixture contracts before its ratio guards. Those tests compile copies of packages/lynx/src, and Lynx changes broke them twice (09-21: an unresolved `octane/internal/context` import; 09-28: a removed `universalBlock` export, fixed on main by #1391). PR CI never ran them, so each break surfaced only in the next weekly run and kept every ratio guard from executing. Add both suites to `ci:workflow:test`, which the lint job runs on every ready pull request, and assert the two lists stay aligned. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE * fix(compiler): keep raw-HTML hosts off the cached signal child region A host that may receive dangerouslySetInnerHTML, directly or through a spread, must reach its child binding on every render: that call is where children and raw HTML are kept mutually exclusive. The ordinary only-child path already checks this before choosing the cached-array region, but the region restored around bindSignalChild did not, so an unchanged cached array let a spread add raw HTML beside still-mounted rows without the error. Skip the region for such hosts, as the ordinary path does. The new spread case fails in the production compile without the guard. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hg86UdUyzRwFTLWhpAMdFE --------- Co-authored-by: Claude <[email protected]>
2 of 5 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.
Summary
Closes #1315.
Lynx main-thread compiler output failed to link with esbuild:
No matching export in "packages/lynx/src/main-renderer.ts" for import "universalBlock". This happened even for a plainexport function App() @{ <view id="simple" /> }. It is a regression from #1313, and the fix has two halves.octane): universal output imported all 13 region helpers fromrenderer.modulewhether it used them or not. Each emission site now records the helper it references (referenceHelper), and the import list comes from one table (UNIVERSAL_RENDERER_HELPER_IMPORTS) filtered to what the output uses. A plain component now importsdefineUniversalComponent,universalPlan, anduniversalValueonly. The three helpers that were already allocated lazily (firstScreenEvent, and the Three-onlyuniversalHostComponentLeafPlanandregisterThreeIntrinsic) now go through the same path. A module that references no helper gets no renderer import at all, instead of a bare side-effect import.@octanejs/lynx):main-renderer.tsnow exports a realuniversalBlock, so setup-bearing@{ … }child blocks render on the main thread instead of only compiling. The background claims one child owner range for each block. On the one-shot first screen that is exactly a taken@ifarm, one range at the block's position, souniversalBlock(body)returnsuniversalIf(true, body). Host IDs, topology, and listener metadata match the background batch, and the main-thread runtime needs no new branch inmaterialize.The new export guard found a second instance of the same bug:
useFormStatehas been in the universal compiler'soctaneimport allowlist since #943, but no universal runtime exported it. Bothoctane/universaland the Lynx renderers failed to link it.universal-core(which coversoctane/universalandoctane/universal/native) and the Lynx main renderer now alias it touseActionState, as the DOMoctaneentry already does.Validation
pnpm format:files:check(changed files); repo-widepnpm format:checknot runtsgo -p packages/octane/tsconfig.json,packages/octane/typetests,packages/lynx/tsconfig.json,tsconfig.testing.json, andpackages/lynx/typetests.pnpm typecheck:filespasses for the new test file. It reports existing DOM-lib/jsdom errors inmain-renderer.test.tsand an unresolved.tsrxfixture import incompatibility-exports.test.ts, on lines this PR doesn't touch. Both packages excludetests/from their tsconfig. Fullpnpm typechecknot run.pnpm sync: no generated changespnpm test(full): not run locally. Ran every relevant Vitest project instead:octane,octane-prod,lynx,three,ink,opentui,rspeedy-plugin,vite-plugin,rspack-plugin: 1,296 files, 25,431 tests passing before rebase55c2c018c: the lynx project plus the octane/octane-prod universal, compiler-capability, compatibility-exports, and actions suites: 82 files, 1,389 tests passingpackages/lynx/tests/compiled-runtime-link.test.ts@octanejs/lynxexports (background and main-thread), each runtime module exports every name the compiler can import from it: the helper table,rendererRegion, routedoctaneruntime imports, and thread-function imports tothreadFunctionsModule. Helpers that only the Three lowering or main-thread callback erasure emit are gated by renderer. Red whenuniversalBlockoruseFormStateis missing.<view />and a setup-bearing child block, bundled against this checkout's runtime modules and rendered.useStateand abindtaphandler. The main-thread first-screen batch must equal the background batch. Red if a main-thread block drops its range.universal-compiler-capabilities.test.ts: every import from the renderer module is referenced by the compiled module, for main-thread Lynx, background Lynx, and an object renderer, in dev and prod. Red on the pre-fix compiler.main-renderer.test.ts:universalBlockadded to the descriptor-level main-vs-background control-flow parity case.compatibility-exports.test.ts:octane/universalandoctane/universal/nativeexportuseFormState === useActionState.lynx-bundle-size, baselinede2685e13vs this change, same command. Raw bytes are unchanged for preview and IFR main and background (for example, IFR main 203,800 → 203,800 B). gzip moves −3 to +1 B, and Brotli moves −224 to +291 B. That churn is deterministic minifier renaming at identical raw length, caused by the tree-shakenuseFormStatealias. Without the alias, the background program is byte-identical to baseline. An earlier revision that added a$$kind === UNIVERSAL_BLOCKbranch tomaterializecost +109 B raw / +54 B gzip on every main-thread bundle; routing throughuniversalIfremoved that.Risk / follow-ups
lynx-bundle-sizesuite's budget gate already fails onorigin/mainbefore this change (preview main gzip 83,657 > 82,070). This PR doesn't move that number.lowerUniversalRendererRegionAst) still import their generated hook-runtime aliases unconditionally. Every universal runtime, including the Lynx main renderer, exports those names (the guard checks this), so they link.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches universal compiler import emission and Lynx first-screen rendering parity; scope is bounded by new link and batch-equality tests but affects all universal Lynx builds.
Overview
Fixes Lynx main-thread bundles failing to link when esbuild rejects imports for renderer helpers the compiled module never calls.
Compiler: Universal output now records each emitted renderer helper via
referenceHelperand builds import lists fromUNIVERSAL_RENDERER_HELPER_IMPORTSfiltered byusedHelpers, so a minimal component only pulls in helpers likedefineUniversalComponent,universalPlan, anduniversalValueinstead of the full helper surface.Lynx main thread:
@octanejs/lynx/main-rendereraddsuniversalBlock(implemented asuniversalIf(true, body)) so setup-bearing@{ … }blocks produce the same first-screen range topology as the background renderer, plususeFormStateas an alias ofuseActionState.Universal runtime:
octane/universalandoctane/universal/nativeexport the sameuseFormStatealias so universal modules that import it fromoctanecan link.Regression coverage includes esbuild link tests for plain and block components, compiler tests that every renderer import is referenced, and main-vs-background batch parity for blocks with hooks and events.
Reviewed by Cursor Bugbot for commit 40de374. Bugbot is set up for automated code reviews on this repo. Configure here.