Repository navigation
Description
Description
A bundle that exports only createRoot retains HTML normalization used by setHTML's hydration-adoption branch, even though that bundle does not include hydrateRoot or the HydrationCapability class. This adds avoidable work to the client-only renderer graph.
Reproduction
With Node 26.4.0, install [email protected] and [email protected], then run this as an .mjs file from the package directory:
import { build } from 'esbuild';
import { gzipSync } from 'node:zlib';
const result = await build({
stdin: {
contents: "export { createRoot } from 'octane';",
resolveDir: process.cwd(),
sourcefile: 'probe-entry.ts',
},
bundle: true,
write: false,
format: 'esm',
platform: 'browser',
target: 'es2022',
minify: true,
treeShaking: true,
define: {
__OCTANE_PROFILE_ENABLED__: 'false',
'process.env.NODE_ENV': '"production"',
},
});
const bytes = result.outputFiles[0].contents;
console.log({ minified: bytes.length, gzip: gzipSync(bytes, { level: 9 }).length });The published package produced 199,687 minified bytes and 63,906 gzip bytes in this probe. setHTML still reaches the hydration-only HTML/script normalization branch via activeHydration(), despite the capability constructor being absent from the closed bundle.
Possible direction
An experimental extraction of that adoption branch into a HydrationCapability method, following the approach in #1637, produced 198,970 minified bytes and 63,662 gzip bytes in the same root-only probe. The hydrateRoot-only bundle increased by 59 minified / 38 gzip bytes. Basic client mount/update and server-node adoption controls passed, but this is only a proof of direction: mixed roots, deferred hydration, script behavior, rollback, and split-chunk cases still need regression coverage before adopting a change.
The larger hydrateRoot graph remains necessary for applications that actually hydrate; this report is specifically about client-only bundles.
Follow-up on an extraction prototype
Against main 3754039d, with Node 24.19.0, Vite 8.1.5, and esbuild 0.28.1, moving the branch into the existing hydration capability reduced the reusable client-root esbuild fixture from 202,644 to 201,943 minified bytes (65,087 to 64,839 gzip). However, the Vite hydration-only fixture increased from 175,021 to 175,795 minified bytes (55,506 to 55,768 gzip), exceeding its existing size budget. The extraction retains normalization for hydration bundles that do not use raw HTML, so it is not a complete fix.
Focused hydration and script-normalization tests passed in development and production, but they do not resolve that size tradeoff. The hydration rewrite in #1784 is also changing this path; any candidate should be remeasured and validated against its eventual implementation.
Activity
test(bench): gate createRoot-only bundles on retaining no hydration code
wip(hydration): ship no hydration code to clients that only call crea…
o-alexandrov commentedon Oct 6, 2026
Measured the proposed extraction on
main(8aeb6c0e5) with the repository's own gate,benchmarks/bundle-size/run-minimal.mjs(Vite 8 scenarios), before deciding whether to open a PR. Part of #1801.HydrationCapabilitymethodroot-static(createRoot)hydrate-rootdeferred-hydrationWhy:
hydrate-rootanddeferred-hydrationdo not usedangerouslySetInnerHTML, so onmainsetHTMLand the normalization helpers are shaken out of them. As a class method the helpers become reachable fromHydrationCapabilityitself, so every hydrating bundle pays them whether or not it uses raw HTML. The esbuild probe in the description (+38 gz forhydrateRoot) understates this under Vite/oxc.So this moves bytes from client-only apps that use raw HTML to every hydrating app, and it would raise two committed budgets. I'm not opening a PR for it. A fix that saves bytes in both directions needs the branch to be reachable only when both hydration and
setHTMLare in the graph, for example a compiler-emitted hydration variant of the raw-HTML write, rather than a capability method.The regression test I wrote for the adoption path (equivalent spelling
<b >same</b >adopts the server node without a warning, then updates apply) is still useful for whoever takes this; it fails when normalization or theDANGER_HTML_VALUEbookkeeping is skipped.fix(octane): handle hydration mismatches like React 19 (boundary/root…
fix(octane): project a hydrated form control's client value like Reac…