Skip to content

perf(cli): specialize disposable SPA starter roots - #648

Merged
trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/632-cli-disposable-root-specialization
Aug 8, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/632-cli-disposable-root-specialization

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Generate the existing disposable chained-root form for SPA applications created by both octane init and octane create.
  • Build and execute the actual generated entry and complete landing-page template through the existing production reachability harness, preserving rendered content, documentation links, and scoped styles.
  • Reduce the generated SPA from 118,268 to 78,369 raw bytes, 39,247 to 27,115 gzip bytes (12,132 bytes / 30.9% smaller), and 34,253 to 24,045 Brotli bytes under the same production build and behavioral oracle.
  • Add committed raw/gzip/Brotli budgets and a patch changeset for @octanejs/cli.

References #632 (Workstream 3); other roadmap work remains open.

Why

The SPA starter previously assigned createRoot(...) to a variable before calling render. That root does not escape, but the existing production compiler intentionally specializes only a directly chained, compiler-proven disposable root. The starter therefore retained the complete generic reusable-root implementation unnecessarily. Changing the generated entry to the already supported chained form fixes the missed optimization without changing the compiler or runtime.

Changes

  • Update the single shared SPA template used by both public scaffolding commands.
  • Add regressions proving both commands emit the disposable public starter form.
  • Add an executable production scenario sourced directly from the actual CLI entry and complete generated SPA component; assert the landing page, heading, four documentation links, quick-start URL, and injected scoped stylesheet.
  • Verify the specialized root remains reachable and the generic reusable-root API does not; keep the existing reusable-root scenario unchanged.
  • Extend the existing benchmark to 28 production builds and 84 enforced raw/gzip/Brotli guards without introducing duplicate fixtures or new dependencies.

Validation

  • pnpm format:check
  • pnpm typecheck (repository-wide; scoped and complete CLI-package checks below passed)
  • pnpm test (repository-wide; 256 relevant targeted tests below passed)
  • pnpm sync
  • pnpm format:files:check .changeset/cli-disposable-root-specialization.md benchmarks/README.md benchmarks/baselines/ratios.json benchmarks/bundle-size/minimal-budgets.json benchmarks/bundle-size/run-minimal.mjs benchmarks/bundle-size/verify-reachability.mjs packages/cli/src/commands/init/templates.js packages/cli/tests/create.test.js packages/cli/tests/init.test.js
  • pnpm typecheck:files packages/cli/src/commands/init/templates.js
  • ./node_modules/.bin/tsgo --noEmit -p packages/cli/tsconfig.typecheck.json
  • ./node_modules/.bin/vitest run --project cli --project create-octane --reporter=dot --silent=passed-only — 163 tests.
  • ./node_modules/.bin/vitest run packages/octane/tests/compiler/bundler-compiler.test.ts packages/octane/tests/external-hook-slot.test.ts --project octane --reporter=dot --silent=passed-only — 76 tests, including HMR, escaped/reused roots, and trusted compiled-output proof.
  • ./node_modules/.bin/vitest run packages/rspack-plugin-octane/tests/loader.integration.test.ts --project rspack-plugin --reporter=dot --silent=passed-only — 17 tests, including Rspack's fail-closed generic-root behavior.
  • node benchmarks/bench.mjs --quick --ratios bundle-reachability — 28 executable production builds / 84 passing size guards.
  • pnpm changeset:check
  • node scripts/generate-scaffold-manifest.mjs --check
  • node scripts/generate-cli-data.mjs --check

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

Note

Low Risk
Only the disposable SPA starter template and benchmark/test wiring change; reusable, HMR, and escaping roots keep their existing contracts.

Overview
SPA scaffolds from octane init and octane create now emit a chained mount (createRoot(...).render(App)) instead of assigning the root to a variable first. That matches the shape the production compiler already specializes, so new apps can drop the generic reusable-root path from the bundle without changing compiler or runtime behavior for roots that are actually reused.

Regression coverage adds a cli-spa-starter bundle-reachability scenario that builds from the real clientEntry and appComponent('spa') templates (no duplicate fixtures), checks the landing page in jsdom, and asserts __createVoidRoot is present while createRoot is not. Committed raw/gzip/brotli budgets and three new ratio guards extend the suite to 28 builds / 84 byte guards; docs and a patch changeset for @octanejs/cli are included.

Reviewed by Cursor Bugbot for commit d74cb17. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Aug 8, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review August 8, 2026 20:06
@trueadm
trueadm merged commit d275405 into octanejs:main Aug 8, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants