Repository navigation
perf(compiler): drop DOM walks to nodes nothing reads - #4714
Conversation
- Positional ids are handed out before the compiler knows whether a child's insert needs a marker. A text node ahead of an appended expression got `var _el$3 = _el$2.firstChild` that nothing read. - Minifiers keep the read, since it could be a getter. - Both compilers now drop a `firstChild` or `nextSibling` walk when no later statement reads its node. - Client gzip on the repo's examples changes by 0 to -24 B. Hydrating builds do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e938536 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
… (#4718) * chore(size): batch re-record after #4714, #4711 and #4717 Live page floor 40.66 -> 40.71 KB (minified unchanged; #4717 measured without #4714). Compiled live recorded minified +2 B, renderToString +13 B. Measured over next @ 46a72c0, matching size job 128670072096. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE * chore(size): re-measure the batch over #4719 Live page floor 40.68 KB (122,849 B), compiled live 44.79 KB (131,098 B), measured over next @ 9c66532. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE --------- Co-authored-by: Claude <noreply@anthropic.com>
DOM output no longer declares positional walks to nodes that nothing reads. These walks shipped as bare property reads such as
_el$2.firstChild;, because a minifier keeps a read that could be a getter.Changes
prune_unused_walksinpackages/compiler/src/dom/element.rsdrops avar x = y.firstChildory.nextSiblingdeclaration when no later statement readsx.pruneUnusedWalksinpackages/babel-plugin/src/dom/template.tsdoes the same, so both compilers emit equal output.Example,
<h1>User : {name()}</h1>:Proof
packages/compiler:cargo test,cargo clippy -- -D warningsandvitest runpass (6880 tests), including Babel parity.packages/babel-plugin:pnpm testpasses (414 tests).packages/web: client, server and hydration suites pass (1556, 1905 and 712 tests). These compile through the Babel plugin, so they run the pruned output.Cost
Client gzip of the Vite builds of the repo's 13 examples, against the same base:
effectcanvastodoshackernews-spanotessolid-optimizer(debates/v0.5.0/evidence/unused-walks-solid-examples.txt). Its own examples show -7 to -43 B.Risk
firstChildornextSiblingread. No later statement of the same template root may read its name. A wrong drop would show up as aReferenceErrorin the web suites, and none happened.🤖 Generated with Claude Code