Repository navigation
perf: keep the signal Action frame out of islands-only pages - #1678
Merged
Merged
Conversation
Only the renderer creates signal Action frames and the transition coordinator, but signals/graph.ts registered them at load, so every bundle that loaded the signal graph carried about 4 KB gzip that renderer-free pages never run. No import edge loads code only when both the renderer and the graph are present, so package.json now chooses the side that carries it: the graph by default (#octane/signal-actions/graph), or the renderer under the `octane-islands` condition (#octane/signal-actions/renderer). Both placements stage Action writes, including for signals imported after an Action awaited. The Vite plugin adds the condition to the production client build when every RenderRoute is islands-only. signal-chat's islands-only page drops from 71,763 B to 67,719 B gzip-9, and its e2e ceiling falls from 71 KiB to 68 KiB. The published runtime imports `#octane/dist/` twins of these keys, so dist/ resolves to dist/ both in the repository and in the tarball. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 3, 2026 17:53
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
50 other measured values are unchanged. Public-import reachability bundles (bytes)
99 other measured values are unchanged. |
This was referenced Oct 3, 2026
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
Islands-only pages no longer download the signal Action frame or the transition coordinator: about 4 KB gzip that they load but never run. signal-chat's islands-only page goes from 71,763 B to 67,719 B gzip-9 (−4,044 B, −5.6%), and its e2e ceiling drops from 71 KiB to 68 KiB.
Why a design was needed. Only the renderer creates frames (
nativeCandidateForActioninruntime.ts), yetsignals/graph.tsregistered both factories at load. Three constraints conflict:bundle-boundaries.test.mjskeepscreateRoot-only bundles at 0 bytes of this code, so the runtime can't import it.signals-action-lifecycle.test.tsneeds a frame when signals are imported after a renderer Action awaited, with no native reads; the props-handle and form-Action tests in that file pin the same case.So no single import edge loads it only when both the renderer and the graph are present, and the code has to live on one side, chosen per build.
Design.
octane's packageimportsnow choose the side throughsrc/signals/action-capability.ts, withaction-capability-elsewhere.tsas the other side's stub:#octane/signal-actions/graph(graph.ts)#octane/signal-actions/renderer(runtime.ts)octane-islandsEither placement is complete: any document that loads the renderer can create a frame as soon as the graph writes, including for late-imported signals. The condition only decides which pages download the code. Under
octane-islands, transition-state's registry also tree-shakes away.@octanejs/vite-pluginaddsoctane-islandsto the production client build when everyRenderRouteuseshydrate: 'islands', the scope chosen with the maintainer. Mixed apps keep the default, so renderer pages that don't use signals never pay. Other bundlers can opt in through their resolve conditions (documented indocs/ssr.md).Publishing. The
#octane/signal-actions/*keys point at./src. The per-file runtime build therefore rewrites them:dist/imports#octane/dist/signal-actions/*, which both manifests map todist/(so the condition still works for published consumers).dist/nodeand the CJS tree import the default target relatively, since Node never sets a bundler condition.verify-dist.mjschecks that the mappings agree and that no emitted module keeps a source-only key, so dist/ resolves the same in the repository (in-place smoke, benchmarks) and in the tarball.Validation
pnpm format:check(scopedpnpm format:fileson every changed file; CI runs the full gate)pnpm typecheck(pnpm typecheck:fileson the changed source and test files; CI runs the full gate)pnpm test(not run locally; left to CI)node --test benchmarks/scoped-signals/bundle-boundaries.test.mjs: 34/34. New test: underoctane-islandsthe engine and streamed-signal bootstraps keep 0 B oftransition-action/transition-coordinator(9,256 + 5,135 B minified by default);createRootkeeps 0 B by default and carries them under the condition; and a bundled renderer Action that imports signals after awaiting stages its write (in-scope[2, 4], committed0, then published once) under both placements. Seen failing three ways: graph registration kept under the condition (9,067 B in the engine bundle), renderer side not carrying the factories (byte assertion), and the same with the byte check removed (the write publishes early, 2 instead of 0).vitest run packages/octane/tests/signals-action-lifecycle.test.ts --project octane-signals: 8/8 (default placement).vitest run packages/vite-plugin-octane/tests/islands-route.test.ts: 6/6. New test: real Vite builds. The mixed app keeps the frame reachable from the signal-graph chunk and not from the runtime chunk; the all-islands app is the reverse, and its server still renders. Fails with the plugin change disabled.node packages/octane/scripts/build.mjs: full publish build, verifyDist (including the new import check), in-placesmokeDistof every ESM/CJS entry,published-errors.test.mjs, version check. Publisheddist/bundled with and withoutoctane-islandshonours the condition exactly as source does.pnpm build+OCTANE_EXAMPLE_PREVIEW=1 playwright test -g "islands-only JavaScript budget"passes at 67,719 B (main measured 71,763 B with the same commands). The facade chunk goes from 16,019 B to 12,013 B gzip; the frame and coordinator now sit in the runtime chunk, which islands-only pages never load.node benchmarks/bundle-size/run-minimal.mjs --budgets root-static-local root-chained-jsx hooks-state prop-attributes context: raw/gzip/brotli identical to main.Risk / follow-ups
installSignalActions()wrapper. No byte budget or ratio guard covers a signal-graph bundle (none of the budgeted fixtures importsoctane/signals).transition-state.ts(writer tracking) still ship in the shared chunk on islands pages, because transition-state is one module shared by the graph and the runtime.forkCandidatemethods insignals/requests.ts,computations.tsandengine.tsare also only reached from frames. They are class methods, and moving them to the renderer side would pull requests/computations into renderer bundles, so they need their own design; not attempted here.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes how transition Action code is split across bundles and depends on correct
octane-islandsresolution; wrong placement could break staging of signal writes inside renderer Actions, though tests cover both placements and late signal import.Overview
Islands-only client builds no longer ship the signal Action frame and transition coordinator (~4 KB gzip) with the signal graph. Those modules are only needed when the renderer stages
startTransitionwrites, so pages that load signals without the renderer were paying for dead code.Octane now picks which bundle carries that code via package
importsand theoctane-islandsresolve condition. By defaultgraph.tsstill registers the factories throughaction-capability.ts; underoctane-islandsthe renderer imports them directly and signal bundles get a no-op stub (action-capability-elsewhere.ts). Behavior stays the same for late-loaded signals after an Action awaits.@octanejs/vite-pluginaddsoctane-islandsto the production client resolve conditions when everyRenderRouteuseshydrate: 'islands'; mixed apps keep the default. Publisheddist/rewrites internal#octane/signal-actions/*imports to#octane/dist/*so tarball and in-repo builds honor the same conditions, withverify-distguarding drift.Docs, bundle-boundary / Vite integration tests, and the signal-chat islands JS budget ceiling (71 → 68 KiB) reflect the win.
Reviewed by Cursor Bugbot for commit 964e51a. Bugbot is set up for automated code reviews on this repo. Configure here.