Repository navigation
Description
Goal
Reduce shipped JavaScript across Octane applications, public binding packages, SSR entrypoints, and compiler-generated output while preserving observable runtime behavior, hydration, registration, CSS, event handling, and supported root semantics.
Treat this issue as the umbrella for independently reviewable follow-up PRs. Reference it from partial PRs without closing it until the complete tracked work is resolved or explicitly descoped.
Existing foundation
- perf: add minimal-import bundle reachability budgets #631 added ten executable production-bundle scenarios, 30 raw/gzip/Brotli size guards, dependency-reachability assertions, and behavior checks for specialized roots, reusable roots, hooks, context, hydration, Suspense, and Zustand bindings.
- fix(bindings): classify production bundle side effects #637 extended the existing reachability harness to 24 executable production-bundle scenarios and 72 raw/gzip/Brotli guards, including all seven reviewed binding imports under both Vite/Rolldown and esbuild.
- perf: reduce core runtime and compiled application bundles #638 eliminated SSR initialization roots and added executable server-helper, buffered-render, and component-owned-effects scenarios, expanding the harness to 27 production builds and 81 raw/gzip/Brotli guards before perf(cli): specialize disposable SPA starter roots #648.
- perf(cli): specialize disposable SPA starter roots #648 extended the same reachability harness to 28 executable production builds and 84 raw/gzip/Brotli guards, including the complete actual CLI-generated SPA starter.
- Existing compiler optimizations already include shared binding-bag factories, event helpers, compact hook slots, hydration isolation, and compiler-proven disposable roots; do not reimplement those landed optimizations.
All measurements below are gzip bytes from minified production builds and include the Octane runtime unless stated otherwise. esbuild and Vite/Rolldown are intentionally shown separately because their tree-shaking behavior differs.
Workstream 1: classify binding-package side effects correctly
Completed in #637 (merge commit 121ab459, 2026-08-08): six reviewed packages now declare sideEffects: false; Aria preserves its root, focus tracking, prototype patch, and reachable transition bootstrap through a three-file allowlist; package-owned dual-bundler regressions and safety controls landed. Validation passed 867 affected-package tests, 99 cross-ecosystem side-effect tests, 24 executable bundle scenarios, and all 72 byte guards. The executable Floating UI esbuild consumer fell from 39,035 to 4,592 gzip bytes (88.2%).
At the original audit, 53 of 68 published packages omitted sideEffects. Broad root barrels consequently retained unrelated component modules, top-level contexts, and large sections of Octane's generic runtime; #637 corrected the seven reviewed bindings below.
| Public import | Original Vite gzip | Modeled classified Vite gzip | Vite saving | Original -> modeled esbuild gzip |
|---|---|---|---|---|
@octanejs/base-ui: Separator |
103,668 | 3,921 | 99,747 | 92,536 -> 3,828 |
@octanejs/aria: useSeparator |
68,281 | 2,416 | 65,865 | 58,109 -> 36,376 |
@octanejs/motion: animate |
68,868 | 25,234 | 43,634 | 61,497 -> 22,616 |
@octanejs/radix: Separator |
45,084 | 4,826 | 40,258 | 40,477 -> 4,556 |
@octanejs/mantine-hooks: useCounter |
19,992 | 17,763 | 2,229 | 16,104 -> 15,809 |
@octanejs/usehooks-ts: useCounter |
18,973 | 17,716 | 1,257 | 16,822 -> 15,834 |
@octanejs/floating-ui: computePosition |
4,929 | 4,820 | 109 | 38,486 -> 4,255 |
Completed implementation (#637):
- Add reviewed
sideEffects: falsedeclarations to Base UI, Motion, Radix, Floating UI, Mantine Hooks, and Usehooks TS after confirming those package source modules have no required module-evaluation effects. - Add package-owned, public-import production-bundle regressions proving selected exports remain functional and unrelated sibling modules disappear.
- Validate representative packages under both Vite/Rolldown and esbuild; Floating UI demonstrates that a large esbuild win need not reproduce under Vite.
- Give Aria an explicit allowlist preserving
./src/index.ts,./src/interactions/useFocusVisible.ts, and./src/utils/runAfterTransition.ts; audit additional public entrypoints separately. - Execute the Aria result and prove global focus listeners and the
HTMLElement.prototype.focuspatch survive. Allowlisting only the effectful leaf modules is insufficient because Vite can discard the root barrel before reaching them. - Preserve genuine side effects in RainbowKit CSS, Nuqs debugging/global adapter context, Testing Library configuration, Recharts middleware, and Styled Components development initialization.
- Enforce reviewed-manifest metadata through the reachability inventory guard and verify each Aria allowlist path exists and is included in the published package; Octane source/dist registration paths are covered by fix: preserve side-effect-only bootstrap entrypoints #633.
Safety boundary: do not mechanically add sideEffects: false to all 53 packages.
Workstream 2: preserve intentionally effectful bootstrap entrypoints
Public Octane and TanStack Start bootstrap fixes merged in #633 (commit 7f6a134e) on 2026-08-07. Executable source and published-dist preloads, the complete 55-test TanStack suite, 10 Octane development/production checks, and all 10 reachability scenarios/30 size guards passed. The separate private Lynx/Rspeedy audit remains open.
Before #633, both octane and @octanejs/tanstack-start declared "sideEffects": false even though each package contains an entrypoint whose public purpose depends on module-evaluation side effects.
Octane compiler registration
Bundling:
import 'octane/compiler/register';previously allowed esbuild to discard registration entirely. Executing the resulting preload against the existing extensionless .tsrx server fixture failed instead of producing <main>Hello, Octane!</main>; the merged regression now verifies the expected HTML.
- Preserve
./src/compiler/register.jsfor workspace/source consumers. - Preserve
./dist/compiler/register.jsfor the published package. - Bundle and actually execute the public preload against the existing SSR fixture.
- Keep an unused bare
import 'octane'tree-shakeable.
TanStack Start client hydration
src/default-entry/client.js initializes hydration-event capture, starts the router, and hydrates the application entirely through evaluation. Before #633, a production consumer importing that entry only for its effects lost the entire bootstrap.
The standard production plugin uses the client module as a direct entrypoint, so this does not claim that normal production applications currently fail; the defect affects bundled bare-import/custom-integration semantics.
- Preserve
./src/default-entry/client.jsthrough a narrow allowlist. - Execute a production-bundled bootstrap and assert synchronous event capture, router startup, and asynchronous hydration of the correct container/component/router.
- Keep an unused bare
import '@octanejs/tanstack-start'tree-shakeable. - Add patch changesets for both published packages.
- Audited and fixed private Lynx/Rspeedy worklet and main-thread initialization purity in perf: finish production bundle reachability follow-ups #653; narrow allowlists preserve both built-in worklet registrations and the install → authored entry → ready bootstrap order while unused package roots still tree-shake.
Workstream 3: specialize CLI-generated disposable application roots
Completed in #648 (merge commit d275405d, 2026-08-08): both octane init and octane create now generate compiler-proven chained disposable SPA roots. The canonical reachability harness builds and executes the exact generated entry and complete landing page, including its documentation links and scoped stylesheet. An identical-production-build, identical-DOM-oracle comparison measured 118,268 -> 78,369 raw bytes, 39,247 -> 27,115 gzip bytes (12,132 bytes / 30.9% smaller), and 34,253 -> 24,045 Brotli bytes. Validation passed 256 targeted tests, 28 executable production builds, and 84 committed size guards; reusable/HMR roots and Rspack's fail-closed behavior remain unchanged.
Before #648, packages/cli/src/commands/init/templates.js generated:
const root = createRoot(document.getElementById('root')!);
root.render(App);The existing production specialization recognizes only:
createRoot(document.getElementById('root')!).render(App);The original normalized Vite investigation measured 39,428 -> 23,400 gzip bytes, saving 16,028 gzip bytes. The complete, actual generated CLI landing-page scenario merged in #648 measures 39,247 -> 27,115 gzip bytes, saving 12,132 gzip bytes (30.9%).
- Generate the existing supported chained-root form for disposable SPA starters from both
octane initandoctane create. - Build and execute the exact generated SPA entry and complete landing page; prove specialization remains active, the generic root disappears, visible content/scoped styles survive, and raw/gzip/Brotli budgets remain enforced.
- Keep HMR-owned, cached, reused, or otherwise escaping roots on the generic public contract, with existing compiler and reusable-root regressions passing.
- Keep trusted Rspack/Rsbuild specialization separate and unimplemented; preserve intentionally fail-closed behavior, including the passing Rspack loader regression.
Workstream 4: remove SSR initialization roots
Completed in #638 (merge commit 136b0e3d, 2026-08-08): permanent-static metadata now belongs to a pure, Hydrate-owned exported initializer; the streaming swap script is constructed and memoized only when a response actually contains pending streaming boundaries; and both nested operations creating the SVG lowercase lookup are explicitly tree-shakeable. The merged production measurements reduced isolated hookSlots from 12,595 to 204 gzip bytes and buffered renderToString from 13,667 to 10,889 gzip bytes. Package-owned production regressions execute permanent-static/deferred Hydrate boundaries, mixed-case SVG/foreignObject, and repeated suspended streams. Fresh development/production verification passes 248 SSR, streaming, hydration, and SVG tests; the current canonical harness passes 28 executable production builds and all 84 size guards, including six committed SSR raw/gzip/Brotli guards.
Before #638, runtime.server.ts performed a standalone top-level Object.defineProperty(hydrate, '__octanePermanentStatic', ...). That observable module-evaluation effect retained both Hydrate implementations and much of the streaming/descriptor graph even for unrelated server exports.
#638 binds the installation to the exported Hydrate initializer so it remains when Hydrate is used and disappears when Hydrate is unused; it also isolates the streaming-only client-runtime string and makes the SVG lowercase-tag table tree-shakeable.
| Server export | Original audit gzip | Modeled Hydrate-only gzip | Modeled complete-fix gzip |
|---|---|---|---|
hookSlots |
12,556 | 1,518 | 194 |
escapeHtml |
12,541 | 1,579 | 269 |
renderToString |
13,637 | 11,408 | 10,867 |
renderToReadableStream |
16,718 | 14,563 | 14,565 |
prerender |
14,443 | 12,221 | 11,686 |
- Move the permanent-static property installation into a pure-annotated, Hydrate-owned exported initializer.
- Preserve the non-enumerable/non-writable/non-configurable private descriptor, explicit Hydrate imports, and executable permanent-static/deferred-boundary behavior.
- Construct and memoize the streaming client-runtime string only when an actual streaming response contains pending boundaries.
- Correctly pure-annotate both nested operations building the SVG lowercase-tag table while preserving mixed-case SVG and
foreignObjectbehavior. - Add production-bundled buffered, streaming, SVG/HTML namespace, permanent-static/deferred hydration, and minimal-server-import behavioral coverage plus six committed SSR raw/gzip/Brotli size guards.
Workstream 5: improve compiler-generated output
Completed in #638 (merge commit 136b0e3d, 2026-08-08): the production compiler now uses one-cell lifetime-invariant callback caches, retained-component delegated-event/scoped-style ownership, exact production template interning with preserved authored origins, and immutable-host binding-bag aliasing. Identical current-source counterfactuals measure real TodoMVC compiled output at 2,268 -> 2,082 gzip bytes (seven cache cells instead of 23) and Weather ForecastItem at 1,760 -> 1,675 gzip bytes (bag13/bag14 instead of bagOf). The merged PR also measured complete application savings of 186 gzip bytes for TodoMVC, 66 for Weather, 54 for js-framework, and 17 for chat. Fresh verification passes 1,100 compiler/callback/ref tests and all 88 applicable production-reachability/codegen guards; the 16-file codegen corpus measures 26,012 / 24,722 = 1.052x, below its 1.06x ceiling. The separate application-wide cross-framework ratio failures found during this audit are tracked below.
Lifetime-invariant callback caches
Before #638, compiler-generated TodoMVC callbacks used seven memo regions and 23 cache cells even though their dependencies were stable dispatchers or already-proven-invariant callbacks. The merged one-cell lifetime cache reduces 23 -> 7 cells; the original full-bundle prototype measured 24,729 -> 24,532 gzip bytes, and identical current-source component output measures 2,268 -> 2,082 gzip bytes.
- Reuse existing compiler invariant analysis to specialize only compiler-owned lifetime-invariant callbacks into one immediately published cache cell.
- Preserve authored explicit dependencies,
Object.is, closure identity, suspension replay, explicit-null behavior, and immediate publication through development/production behavioral coverage. - Measure real TodoMVC/chat/weather/js-framework application output and retain existing application interaction/update guards; generated cache hits allocate no callback/dependency array and add no helper call.
Component-owned delegated events
Before #638, the compiler aggregated delegated events at module scope. The production-bundle fixture contained an unused onAuxClick component and a retained onClick component; the unused template disappeared, but auxclick registration survived. Unique production events are now owned by their retained exported component.
An isolated event-free import measured 15,839 -> 2,455 gzip bytes when unrelated registration was removed. Real current Sonner imports save only 26-38 gzip bytes because other live code already retains the event graph.
- Assert unused
auxclickregistration disappears while retainedclicklistener registration and dispatched click behavior remain live. - Associate uniquely owned delegated and captured event registration with the retained component initializer.
- Preserve registration timing, capture/bubble behavior, HMR/development/profile fallbacks, authored origins, shared events, and actual listeners.
- Keep registration effectful inside a pure, component-owned initializer rather than incorrectly marking the registration call itself pure.
Component-owned scoped styles
The original audit fixture importing one unstyled component retained and injected 15 unrelated styles: 911 -> 309 gzip bytes app-only, or 16,287 -> 15,549 gzip bytes with runtime bundled. #638 now attaches safe scoped styles to their retained owning component; no published authored .tsrx module used this construct during the original audit.
- Associate scoped style injection with the owning retained component only when production ownership is proven safe.
- Preserve explicit global stylesheet effects, authored cascade/insertion ordering, SSR/hydration deduplication, and development/HMR fallbacks.
Identical template token interning
The original fixed 16-file compiler corpus contained 22 of 127 template tokens duplicating an existing same-module token. The merged production interning addresses an opportunity originally modeled at 1,333 raw bytes, 526 minified bytes, and 134 summed per-file gzip bytes while preserving all authored origins.
- Intern exact
(serialized HTML, namespace, fragment mode)tuples within each production module. - Preserve namespace/fragment-specific template identity, lazy parse caches, and hydration behavior.
- Preserve repeated authored source origins/source maps through aliases and disable interning for development, HMR, and profiling.
Binding-bag host aliasing
Before #638, the weather ForecastItem stored the same root element five times, producing a 17-field bag that spilled into bagOf. The merged immutable-host aliasing produces a 13-field bag using the existing shared bag13 helper.
-
Compiled component: 1,760 -> 1,675 gzip bytes.
-
Complete weather application: 34,727 -> 34,682 gzip bytes, a modest net 45-byte saving.
-
The corpus plus ForecastItem contains 18 redundant persisted host references.
-
Deduplicate proven-identical immutable planned host references inside compiler AST emission.
-
Preserve refs/ref manifests, host identity, hydration, controlled values, mount-failure/suspense cleanup atomicity, source maps, and trusted compiled-output fingerprints.
-
Verify real Weather component output improves 1,760 -> 1,675 gzip bytes, removes the generic
bagOffallback/four host fields, and introduces no runtime object, closure, or helper-call allocation.
Follow-up: restore full-application bundle-size guard health
An audit of current main under Node 26.4.0 found that node benchmarks/bench.mjs --quick --ratios bundle-size successfully builds every real framework/application fixture but fails 12 of its 20 committed cross-framework ratio guards. Examples include js-framework Octane/Ripple 1.79x > 1.47x, Octane/Solid 1.71x > 1.28x, and Octane/Svelte 1.30x > 1.03x; TodoMVC and chat app/total-byte guards also fail. The dedicated Workstream 5 compiler-output and executable-reachability suites remain green (88 guards), so these broader historical ceiling breaches are a separate issue rather than evidence that the merged compiler optimizations are missing.
- Reproduced 14, not 12, application bundle guard breaches under the supported Node 24 Bench toolchain; traced July-era ceilings against the already-committed August 8 snapshot, preserved all 20 transparent cross-framework comparisons, and added 36 strict application/framework/total raw/gzip/Brotli budgets in perf: finish production bundle reachability follow-ups #653. The pre-fix snapshot violates 18 of the new byte ceilings.
Lower-priority follow-ups
- Removed complete package-manifest retention from the public
versionexport in perf: finish production bundle reachability follow-ups #653: a manifest-derived generated literal stays synchronized through releasepnpm sync, package builds reject drift, and source/published production bundles shrink from 1,104 to 57 gzip bytes. - Documented
__OCTANE_PROFILE_ENABLED__=falsefor custom production esbuild integrations in perf: finish production bundle reachability follow-ups #653; executable normal/profile builds preserve their public DOM/devtools contracts while excluding the approximately 3.4 KB gzip optional profiling graph. - Investigated and explicitly descoped specialized public context/provider boundaries: the large graph is rooted by supported
.tsxdescriptor children and compiled/descriptor dialect-switch cleanup; deleting it would violate provider, cleanup, and hydration contracts. - Avoided broad
@__PURE__annotation sweeps; measured 16–24-byte minimal-import savings do not justify speculative annotations or changes to real application roots.
Validation and completion criteria
- Extend perf: add minimal-import bundle reachability budgets #631's executable production scenarios instead of creating a competing size harness.
- Compare both Vite/Rolldown and esbuild where metadata or reachability is involved.
- Keep all existing raw/gzip/Brotli budgets green or intentionally ratchet improved budgets.
- Include positive tests proving required compiler registration and hydration startup (fix: preserve side-effect-only bootstrap entrypoints #633), listeners and globals (fix(bindings): classify production bundle side effects #637), and injected scoped CSS (perf(cli): specialize disposable SPA starter roots #648) actually execute.
- Include negative tests proving unrelated exports, runtime modules, and package roots continue to disappear.
- Verified browser, SSR, hydration, and runtime throughput: 10,988 complete dev/prod core tests, 337 Lynx/Rspeedy tests, 144 deterministic Node 24 guards, Node 26 compatibility, and six-framework real-Chromium weather updates all pass for perf: finish production bundle reachability follow-ups #653.
- Kept workstreams independently reviewable across fix: preserve side-effect-only bootstrap entrypoints #633, fix(bindings): classify production bundle side effects #637, perf: reduce core runtime and compiled application bundles #638, perf(cli): specialize disposable SPA starter roots #648, and perf: finish production bundle reachability follow-ups #653; the final merged PR referenced this umbrella without prematurely closing it.
Provenance
Investigated, measured, and filed by an AI coding agent on behalf of the maintainer.
Final completion PR (#653)
Merged #653 completes the remaining bootstrap, runtime, packaging, profiling, and benchmark-guard work.
- Optional transition bookkeeping now stays behind the existing lazy capability: normalized framework gzip improves by 524 B (rows), 527 B (TodoMVC), and 541 B (chat); applications that actually use transitions retain their full semantics.
- Full production application bytes improve from 23,802 → 23,280 (rows), 24,680 → 24,153 (TodoMVC), and 25,311 → 24,767 (chat) under Node 24.
- All 20 comparative application guards remain; 36 additional aligned same-run byte ceilings independently protect every app, framework, and total across raw, gzip, and Brotli.
- Validation: full
pnpm format:check, fullpnpm typecheck, 10,988 Octane dev/prod tests, 337 private-package tests, 144/144 deterministic bundle/codegen guards, 56/56 Node 26 application guards, and 3/3 real-browser weather guards. - Public context/provider specialization and broad purity sweeps were investigated and explicitly rejected because their proposed gains would either break supported behavior or be negligible.
All tracked workstreams are complete. The final PR merged on 2026-08-08 as commit 1c44117b3b12.
Activity
[-]Preserve side-effect-only bootstrap entrypoints during production bundling[/-][+]Track bundle size, tree shaking, bootstrap side effects, SSR, and compiled output[/+]domgan-oai commentedon Aug 8, 2026
Completed by merged PR #653 (1c44117). All tracked bundle-size, tree-shaking, bootstrap, SSR, compiler, profiling, and validation workstreams are complete or explicitly resolved.