Repository navigation
fix(compiler): keep .tsrx signal declaration modules renderer-free - #1289
Merged
Merged
Conversation
A client .tsrx module that only declares signals emitted enableNativeReadCollection(1) and enableSignalBindings(1) from octane/internal/client. The declarations themselves added enableSignalBindings to the module's runtime helpers, and that non-empty set then counted as renderer work. Any renderer-free consumer, such as adoptBindings, bundled the renderer: 48,585 instead of 24,781 bytes gzip in a measured example. Such a module now activates only the document signal owner, through __enableSignalDocument from octane/signals, exactly like the plain .ts path. Modules that render signal reads keep activating native reads through their documented octane/signals import. Two conversation-streaming fixture components that read signals during render without that import now declare it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 23, 2026 20:59
12 tasks done
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
.tsrxmodule that only declares signals (signal$/derived$/query$, no components or renderer imports) loaded the renderer. It emittedenableNativeReadCollection(1)andenableSignalBindings(1)fromoctane/internal/client.adoptBindings, therefore bundled the renderer.__enableSignalDocument(1)fromoctane/signals. That is exactly what the plain.tscompile path already emits for the same source.Why
In
compile.js, the signal declarations addenableSignalBindingstoctx.runtimeNeeded.nativeReadActivationNodesthen treated that non-empty set as renderer work and installed the native-read driver as well. Declaring signals ended up enabling the renderer.docs/signals.mdmakes the reading module responsible for activation: "Each module that consumes native reads needs a runtime import fromoctane/signals…".slot-hooks.jsalready follows that rule for.tsmodules.Measured with the same signal-driven view adopted through
adoptBindings(esbuild, production, gzip-9), signals declared in a.tsrxmodule:runtime.tsin bundleThe same declarations in a plain
.tsmodule: 24,163 gzip. This came out of measuring renderer-free islands for #1284.Changes
compiler/compile.js: adoesRendererWork(ctx)check (generated runtime helpers, or a renderer import) is now shared by the native-read activation and the signal-binding activation. It mirrors the.tspolicy inslot-hooks.js. When a module's eager signal declarations are its only work, it emits__enableSignalDocument(1).import 'octane/signals';enableServerSignalBindings.docs/signals.md: states that importing handles from a declaring module does not enable native reads.benchmarks/conversation-streaming/fixture:Body.tsrxandHistory.tsrxreadbody$.get()/history$.get()during render without the documented import. They only updated becauseState.tsrxswitched on native-read collection for the whole app. Each is an independent island whose graph is just itself plusState.tsrx, so both now declareimport 'octane/signals'.Behavior change
A component that reads signals during render without importing
octane/signalsno longer gets native-read collection from the.tsrxmodule that declares them. This already applied when the declarations lived in a.tsmodule, and the docs have always required the import.In the repo, only the two benchmark fixture components above relied on it.
examples/signal-chat/src/Composer.tsrxand the benchmarkComposer.tsrxread signal values only in event handlers, which never subscribe. Every other module that reads the affectedState.tsrxfiles importsoctane/signals.Validation
benchmarks/scoped-signals/bundle-boundaries.test.mjs(runs inci:workflow:test), with two parts:.tsrxmodule plus the owner APIs must not resolveruntime.tsorinternal/client.ts, and its derived value must update ([2, 8]). This part fails onmain("Signal declarations reached the renderer").1→5) in happy-dom. It fails (stays1) if native-read activation is removed from renderer modules too.packages/octane/tests/compiler: 2,640 passed.packages/vite-plugin-octane/tests/production.test.ts, which builds the fixture app containing a declarations-onlyState.tsrx: 19 passed.bundle-boundaries, split-context, split-hydrate and deferred boundary tests, plus the conversation-streaming behavior-only server test: 46 passed.pnpm format:files:check,pnpm changeset:check,pnpm sync.pnpm typecheck:filesfails only on the fixture's unchangedbackend.ts(@octanejs/app-coredoes not resolve there), and it fails identically onmain.run-browser.mjs) and repo-widepnpm test/pnpm typecheck. The repo-wide ones are left to CI.Risk / follow-ups
Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Compiler emission changes which modules load the renderer; apps that read signals during render without
import 'octane/signals'and relied on the declaring.tsrxmodule's side effect may stop re-rendering silently.Overview
.tsrxmodules that only declare signals (signal$/derived$/query$, with no components or renderer imports) no longer pull in the Octane renderer on load. They now emit__enableSignalDocument(1)fromoctane/signals, matching plain.tsmodules, instead ofenableSignalBindings/enableNativeReadCollectionfromoctane/internal/client. Renderer-free consumers such asadoptBindingscan import those state modules without bundlingruntime.ts(~24 KB gzip in a cited measurement).The compiler adds shared
doesRendererWork(ctx)(generated runtime helpers or non-type renderer imports) and uses it for both signal-binding activation and native-read activation. Modules that actually render still activate native reads via their own documentedimport 'octane/signals'.docs/signals.mdstates that importing handles from a declaring module does not enable native reads.Body.tsrxandHistory.tsrxin the conversation-streaming fixture add that import because they read signals during render. A newbundle-boundariestest locks in renderer-free declaration bundles and a control that reader modules still re-render when signals change.Reviewed by Cursor Bugbot for commit fa9803a. Bugbot is set up for automated code reviews on this repo. Configure here.