Repository navigation
feat(islands): renderer-free island activation and islands-only routes - #1582
Merged
Merged
Conversation
Binding programs subscribe to imported signal reads, run mount-only effects, and lower @try/@pending/@catch, so whole islands compile as binding views. An independent island whose only child is a zero-argument binding view activates through that view's program without the renderer, and RenderRoute's hydrate: 'islands' serves the server-rendered shell with a renderer-free bootstrap. signal-chat runs islands-only. Closes #1514 Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 2, 2026 17:35
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
14 other measured values are unchanged. Public-import reachability bundles (bytes)
69 other measured values are unchanged. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
Bugbot Autofix prepared fixes for all 3 issues found in the latest run.
- ✅ Fixed: Shell check skips independent={false} Hydrate
- The attribute check now inspects the value—bare
independentandindependent={true}return early as independent islands, whileindependent={false}correctly falls through to report an ordinary Hydrate that needs the renderer.
- The attribute check now inspects the value—bare
- ✅ Fixed: Shell check misses non-function exports
- The root-seeding loop now resolves
export { Name }re-export specifiers,export default Identifierreferences, andexport const Name = function/arrowVariableDeclaration inits to their function bodies, so the walk covers all export forms.
- The root-seeding loop now resolves
- ✅ Fixed: Shell check misses wrapped signal reads
- Signal-read detection now matches
OptionalCallExpressionalongsideCallExpression, peels TYPE_WRAPPERS on the callee before checking forMemberExpression/OptionalMemberExpression, and the controlled value/checked literal test also unwraps TS wrappers before theLiteralcomparison.
- Signal-read detection now matches
Or push these changes by commenting:
@cursor push a08aa9b7d8
Preview (a08aa9b7d8)
diff --git a/packages/octane/src/compiler/islands-shell.js b/packages/octane/src/compiler/islands-shell.js
--- a/packages/octane/src/compiler/islands-shell.js
+++ b/packages/octane/src/compiler/islands-shell.js
@@ -83,7 +83,36 @@
functions.set(declaration.id.name, declaration);
const name = statement.type === 'ExportDefaultDeclaration' ? 'default' : declaration.id.name;
if (exported && (exports === null || exports.includes(name))) roots.push(declaration);
+ } else if (exported && declaration?.type === 'VariableDeclaration') {
+ for (const declarator of declaration.declarations ?? []) {
+ const init = declarator.init;
+ if (
+ declarator.id?.type === 'Identifier' &&
+ init &&
+ (init.type === 'FunctionExpression' || init.type === 'ArrowFunctionExpression')
+ ) {
+ functions.set(declarator.id.name, init);
+ if (exports === null || exports.includes(declarator.id.name)) roots.push(init);
+ }
+ }
}
+ if (statement.type === 'ExportNamedDeclaration') {
+ for (const specifier of statement.specifiers ?? []) {
+ if (specifier.exportKind === 'type') continue;
+ const exportedName = specifier.exported?.name ?? specifier.exported?.value;
+ if (exports !== null && !exports.includes(exportedName)) continue;
+ const fn = functions.get(specifier.local?.name);
+ if (fn) roots.push(fn);
+ }
+ } else if (
+ statement.type === 'ExportDefaultDeclaration' &&
+ declaration?.type === 'Identifier'
+ ) {
+ if (exports === null || exports.includes('default')) {
+ const fn = functions.get(declaration.name);
+ if (fn) roots.push(fn);
+ }
+ }
}
const problems = [];
const components = new Map();
@@ -107,7 +136,21 @@
const attributes = opening.attributes ?? [];
if (tag !== null && octane(tag, 'Hydrate')) {
// An independent island activates on its own; it is not shell work.
- if (attributes.some((attribute) => attributeName(attribute) === 'independent')) return;
+ // Bare `independent` and `independent={true}` are independent;
+ // `independent={false}` is an ordinary boundary that needs the renderer.
+ if (
+ attributes.some((attribute) => {
+ if (attributeName(attribute) !== 'independent') return false;
+ if (attribute.value == null) return true;
+ let expr =
+ attribute.value.type === 'JSXExpressionContainer'
+ ? attribute.value.expression
+ : attribute.value;
+ while (TYPE_WRAPPERS.has(expr?.type)) expr = expr.expression;
+ return !(expr?.type === 'Literal' && expr.value === false);
+ })
+ )
+ return;
report(node, 'an ordinary <Hydrate> needs the renderer to hydrate its children');
} else if (tag !== null && /^[A-Z]/.test(tag) && !octane(tag, 'Fragment')) {
const local = functions.get(tag);
@@ -137,10 +180,13 @@
else if (
(name === 'value' || name === 'checked') &&
CONTROLLED.has(tag ?? '') &&
- attribute.value?.type === 'JSXExpressionContainer' &&
- attribute.value.expression.type !== 'Literal'
- )
- report(attribute, `a controlled ${JSON.stringify(name)} needs the renderer`);
+ attribute.value?.type === 'JSXExpressionContainer'
+ ) {
+ let expr = attribute.value.expression;
+ while (TYPE_WRAPPERS.has(expr?.type)) expr = expr.expression;
+ if (expr?.type !== 'Literal')
+ report(attribute, `a controlled ${JSON.stringify(name)} needs the renderer`);
+ }
}
} else if (node.type === 'JSXTryExpression' || node.type === 'TryStatement') {
report(node, '@try recovery needs the renderer; move it into an independent island');
@@ -149,11 +195,16 @@
/\$$/.test(nameOf(node.expression) ?? '')
) {
report(node, 'a signal handle binding needs client code the shell never loads');
- } else if (node.type === 'CallExpression') {
+ } else if (node.type === 'CallExpression' || node.type === 'OptionalCallExpression') {
const callee = node.callee;
const name = nameOf(callee);
+ let peeled = callee;
+ while (TYPE_WRAPPERS.has(peeled?.type)) peeled = peeled.expression;
const member =
- callee?.type === 'MemberExpression' && !callee.computed ? callee.property.name : null;
+ (peeled?.type === 'MemberExpression' || peeled?.type === 'OptionalMemberExpression') &&
+ !peeled.computed
+ ? peeled.property.name
+ : null;
if (name !== null && /^use(?:[A-Z0-9_]|$)/.test(name))
report(node, `hook ${name}() needs the renderer`);
else if (name !== null && SIGNAL_DECLARATIONS.has(name))
diff --git a/packages/octane/tests/compiler/islands-shell.test.ts b/packages/octane/tests/compiler/islands-shell.test.ts
--- a/packages/octane/tests/compiler/islands-shell.test.ts
+++ b/packages/octane/tests/compiler/islands-shell.test.ts
@@ -64,4 +64,59 @@
expect(analyzeIslandsShell(source, '/src/Page.tsrx', ['Uses']).problems[0].line).toBe(2);
expect(analyzeIslandsShell(source, '/src/Page.tsrx', null).problems).toHaveLength(2);
});
+
+ it('rejects independent={false} Hydrate as ordinary shell work', () => {
+ const { problems } = analyzeIslandsShell(
+ shell('<Hydrate independent={false} when={interaction()}><Island /></Hydrate>'),
+ '/src/Page.tsrx',
+ );
+ expect(problems.map((p) => p.message).join('\n')).toMatch(/ordinary <Hydrate>/);
+ });
+
+ it('accepts independent={true} Hydrate', () => {
+ const { problems } = analyzeIslandsShell(
+ shell('<Hydrate independent={true} when={interaction()}><Island /></Hydrate>'),
+ '/src/Page.tsrx',
+ );
+ expect(problems).toEqual([]);
+ });
+
+ it('checks exports authored as export { Name }', () => {
+ const source = `import { Hydrate } from 'octane';
+function App() @{ <button onClick={() => {}}>Click</button> }
+export { App }`;
+ const { problems } = analyzeIslandsShell(source, '/src/Page.tsrx', ['App']);
+ expect(problems.map((p) => p.message).join('\n')).toMatch(/"onClick" needs client code/);
+ });
+
+ it('checks exports authored as export default Identifier', () => {
+ const source = `import { Hydrate } from 'octane';
+function App() @{ <button onClick={() => {}}>Click</button> }
+export default App`;
+ const { problems } = analyzeIslandsShell(source, '/src/Page.tsrx', ['default']);
+ expect(problems.map((p) => p.message).join('\n')).toMatch(/"onClick" needs client code/);
+ });
+
+ it('checks exports authored as export const Name = arrow', () => {
+ const source = `import { Hydrate } from 'octane';
+export const App = (props) => @{ <button onClick={() => {}}>Click</button> }`;
+ const { problems } = analyzeIslandsShell(source, '/src/Page.tsrx', ['App']);
+ expect(problems.map((p) => p.message).join('\n')).toMatch(/"onClick" needs client code/);
+ });
+
+ it('rejects an optional signal read like count$?.get()', () => {
+ const { problems } = analyzeIslandsShell(
+ shell('<p>{String(count$?.get()) as string}</p>'),
+ '/src/Page.tsrx',
+ );
+ expect(problems.map((p) => p.message).join('\n')).toMatch(/\.get\(\) read/);
+ });
+
+ it('rejects a signal read through a TS-wrapped callee', () => {
+ const { problems } = analyzeIslandsShell(
+ shell('<p>{String((count$ as any).get()) as string}</p>'),
+ '/src/Page.tsrx',
+ );
+ expect(problems.map((p) => p.message).join('\n')).toMatch(/\.get\(\) read/);
+ });
});You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit aabf31b. Configure here.
- Run the signal-chat JavaScript budget journey from its own spec, which the Playwright config loads only against the production preview, rather than skipping it in development. - Recognize only server-rendered `@try` arms (`y0`-`y2`) as balanced binding opens and spell the check compactly; the renderer pays 39 raw bytes for the new marker, so the root-chained-jsx budget rises to cover it. - Pin the example E2E shard balance for the added journey. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Treat only a bare `independent` or `independent={true}` <Hydrate> as an
island, matching the compiler; `independent={false}` is an ordinary
boundary that needs the renderer.
- Follow every export form to the component it renders: anonymous default
functions, default-exported identifiers, export lists, function-valued
consts, and relative re-exports. An export the source cannot resolve
(a wrapped component, a package or star re-export, a missing name) is a
problem rather than a silent pass.
- Detect signal reads through a cast or non-null callee and computed
`['get']`-style members, and check arrow components' expression bodies.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A binding view's client template writes an empty `@try` range as `[b;id;site;y`, before the region selects an arm. Building that region on the client balances the range with the same open-comment grammar, so rejecting a bare `y` made any `@try` created after activation throw #286 (signal-chat's stop/resume journey). Accept `y` and `y0`-`y2` again, in one guarded regular-expression test that keeps the renderer cost small, and raise root-chained-jsx's raw budget one step to cover it. The initial-document-signals island fixture now resolves its island module's requests as a bundler would: the prop-less child's island request forwards to the renderer island module. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 2, 2026
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
#1582 (53db436) gave ssrTry a `slot` arrow that labels a presentation-binding view's arm. ssrTry evaluated that arrow on every call, even when no binding marker was passed. The ssr-final-replay work suite counts closure expressions evaluated under ssrTry. Its stream-32-1 target rose from 13,728 to 14,784, exactly one more per call across 1,056 calls, which breaches the wave-budget guard. The labeller is now the module-level ssrTryArm(content, arm, bindingMarker). MARKERS is still read at call time and the emitted HTML is unchanged. stream-32-1 measures 13,728 again. Co-authored-by: Claude Opus 5.5 <[email protected]>
6 of 7 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 #1514. Step 2 (zero-argument views) landed in #1568; this PR finishes steps 3–6. Pages whose interactive parts are signal-driven islands now activate those islands without the renderer, and a route can opt out of hydrating its shell.
x$.get()/x$.latest(fallback)in attributes, text,@iftests,@foritems and blockconstdeclarations. The program subscribes to every source a preparation read and prepares again when one changes. The former #308 activation diagnostic now applies only where no program can subscribe (fixed scalar views, module-scope reads).useLayoutEffect(cb, [])/useEffect(cb, [])in a view's setup run once after activation, children before parents, under the program's signal owner. Their cleanup runs when the view leaves or the program is disposed.@tryin binding programstryregion: a thrown thenable selects@pending, any other error selects@catch.@catchis sticky until its deferredresetruns, matching the renderer. Activation adopts whichever arm the server rendered, including a streamed swap. A boundary still streaming at activation is claimed, so its late segment can't replace live DOM.<Hydrate>whose only child is a prop-less component imported from a project.tsrxmodule asks that module for its activator (?octane-island=). A zero-argument'use dom bindings'view answers with__createBindingIslandActivator, which adopts the island's range and replays captured input. Any other component forwards to the unchanged renderer island module through a static re-export, so it pays no extra request.new RenderRoute({ …, hydrate: 'islands' })serves the same document with a second, renderer-free bootstrap (virtual:octane-islands). That entry handles capture, streamed signals, the document lifecycle, island registration, thenpreHydrate. The shell keeps its CSS but its page chunk is never preloaded.Build check for islands mode. The build fails closed when the shell needs client work. That covers hooks, handlers, refs, controlled values, ordinary
<Hydrate>,@try, signal reads and handle bindings, spreads, uncheckable components, and root boundaries. It also fails when the islands entry orpreHydratecan reach the renderer. Rsbuild refuses the option for now.Signal-chat pilot. Both routes are islands-only and all five islands are binding views. Metrics and the composer's
readyflag moved to signals.main@ 02e4eb0That is −56%, inside the issue's 70 KiB ceiling. The KiB unit matches the issue's baseline: its "156.4 KB" is this same main build. The new e2e journey enforces the ceiling.
Two runtime fixes found by the pilot:
pagehidenotified live bindings synchronously, before islands were disposed, and threwScopeDisposedErrorVersion Packages #151. A committed binding now treats that as the end of its data and stops quietly with its last DOM. This also covers plain step-2 views over module signals.cloneHydrationReplayEventmoved out ofruntime.tsintohydration/replay-event.ts, so the renderer-free activator can replay events without the renderer.Decisions taken from the earlier plan
@try: keep the last DOM and stay subscribed. A failure before the first commit throws from activation. A later failure goes toreportError.readyflag: moved to a module signal set by the mount effect, rather than loweringuseStateor treatingreadyas a constant.useStatestays a diagnostic in binding views.hydrate: 'islands', Vite-only. The original plan proposed two PRs (6a and 6b); this one PR delivers both.Validation
pnpm format:check: not run repo-wide.pnpm format:filesran on every changed file.pnpm typecheck: not run in full. Clean:typecheck:fileson every changed TypeScript file inpackages/octane/src, plusoctane-tscforapp-core,vite-plugin-octane,rsbuild-plugin-octaneandexamples/signal-chat.pnpm test: not run in full; CI runs it.main:octaneproject: 12 files, 538 tests. Coversbehavior-root,hydration/independent-island*,independent-parent,early-independent-intent,compiler/islands-shell,binding-handoff,scalar-dom-bindings,streaming-ssr,suspense-hydrateandrange-boundary.vite-plugin:islands-routeandproduction, 22 tests. Before the rebase,plugin,render-routeanddev-build-metadataalso passed (45 tests).node --test benchmarks/scoped-signals/bundle-boundaries.test.mjs: 33 pass.benchmarks/bundle-size/minimal-gates.test.mjs: 6 pass.rsbuild-plugin: the new islands refusal test.e2e/islands-budget.spec.ts, which the Playwright config loads only for the production preview.Bundle cost for existing binding views.
@trysupport, mount effects and the read tracker are compiler-selected capabilities, likelist, so programs that don't use them don't carry them. What remains in the lean structural adopter is the glue plus the retirement fix every program needs: +327 B gzip (8,694 → 9,021, esbuild, minified, gzip-9). Scalar views are unchanged (3,418 → 3,424).Renderer cost. The renderer has to treat a
@trybinding range as balanced:y0–y2in server HTML, and a bareyin a binding view's client template before the region selects an arm. One guarded regular-expression test inisBindingOpenCommentdoes this. It costs 49 raw bytes inroot-chained-jsx(85,938 → 85,987; gzip-9 28,504 → 28,534; brotli 25,309 → 25,327). Its committed budget rises to 86,016 / 28,544 / 25,344, becausemainsat 14 raw bytes under the old one. The other budgeted scenarios stay within their budgets.Risk / follow-ups
nonemode, client navigation into an islands-only route, and Rsbuild support remain proposed indocs/hydration-islands-plan.md.@trykeeps its server DOM. Its handlers are not installed until data arrives, so input captured before activation is replayed with no listener and is lost.renderToString)@trypending fallback while the client read is still pending. This happens with or without'use dom bindings'.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Changes hydration/bootstrap, compiler-selected island activators, and binding runtime semantics (subscribed reads, @Try, lifecycle); build-time shell checks are conservative but misclassification could break islands-only pages or leave interactive shell code unloaded.
Overview
This PR finishes renderer-free independent island activation and adds an explicit
hydrate: 'islands'route mode so the server shell never loads the Octane renderer.DOM binding programs gain subscribed imported reads (
count$.get()/.latest()),@try/@pending/@catch(including streamed-boundary claim and server arm adoption), blockconstdeclarations, and mount-onlyuseLayoutEffect/useEffectwith[]. Retiring the signal owner ends programs quietly instead of throwing. An independent<Hydrate>whose only child is a prop-less'use dom bindings'view from a project.tsrxmodule activates via__createBindingIslandActivatorand a compiler?octane-island=indirection; other islands still load the renderer chunk.App bootstrap adds
create_islands_entry_source(virtual:octane-islands): shared prelude with the full hydrate entry, but nohydrateRootor route/layout import. Production serves islands routes with a swapped bootstrap script, skips page-chunk modulepreload, andanalyzeIslandsShellfails the Vite build when the shell needs hooks, handlers, signals, ordinary Hydrate, etc.signal-chat is the pilot (both routes islands-only, panels on bindings); a production Playwright spec enforces no renderer/runtime hydrate chunks and a 70 KiB gzip-9 JS budget. Replay event cloning moves to
hydration/replay-event.tsso the binding activator does not import the renderer.Reviewed by Cursor Bugbot for commit 849abba. Bugbot is set up for automated code reviews on this repo. Configure here.