Repository navigation
fix(compiler): rebase composition asset paths from the file read and charge what they add - #8166
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 63 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (2)
|
terencecho
left a comment
There was a problem hiding this comment.
Reviewed pinned head 429a981. No blocker found.
The producer supplies the project-relative file resolved by the same resolver used to read the mount, so query/fragment text no longer becomes a rebase prefix. Rebased growth flows through the shared parser callback for attributes/srcset, styles/CSS, and hoisted script/link/import-map references. Mounted and direct-entry rewrites use the render's existing budget; a refusal propagates before subsequent references are assembled. The preview bundler keeps its existing literal-path behavior. The documented conservative extra stylesheet charge is unchanged in direction.
Validation: full workspace build passed after retrying one SIGTERM. 16 parser tests, 270 core inliner/bundler tests, 23 producer size-limit tests and 196 compiler tests passed (505 total). Removing the parser charge breaks the new per-reference accounting test; restoring the raw source prefix breaks the query-path regression; disabling entry charging breaks the entry limit case; disabling mounted-path charging breaks the mount limit case. Restoring all source/build artifacts makes the parser and all three new integration cases pass again. No temporary changes remain.
The required fails-without-the-fix line is present. CI has 79 successes, 11 skipped and three still running, with no failed checks when reviewed. No end-to-end render was performed.
— tai (automated review)
…thin the size limit
…charge what they add A mount's references now rebase from the project file the render read for it, so a query or fragment in data-composition-src no longer lengthens every rebased path. Every byte a rebased reference adds, including the entry file's own rebase, is charged to the render's expansion budget as it is produced.
429a981 to
38cf4d9
Compare
terencecho
left a comment
There was a problem hiding this comment.
Re-pinned at 38cf4d9 after rebasing onto main 3b79b18, the merged #8152 commit. No blocker found in the rebase.
Range-diff shows the compiler-fix commit unchanged. Core inliner and parser implementation/test files have identical final contents to approved 429a981. I checked the resolved test-file conflict rather than relying only on the commit summary: the entire asset-path describe block is byte-identical to the approved block, and the remainder equals the merged font-test base plus the existing mkdirSync/dirname import additions. Both describe blocks, including their closing braces, are preserved independently.
The previous full build, 505 focused tests and four failing-without-the-fix checks carry forward; no tests or build were rerun for this content-verified rebase. The required fails-without-the-fix line remains. CI is running with 52 successes, eight skipped and 26 in progress, with no failed checks when reviewed.
— tai (automated review)
What
When a render inlines a mounted composition, the relative paths inside it are rebased from the folder of the file the render actually read, and every byte that rebasing adds counts toward the render's size limit, including the rebase of an entry file that sits in a subfolder.
Why
The rebase prefix came from the raw
data-composition-srcattribute. A query or fragment in it (scene.html?<long text with slashes>) still names the same small file, because the file lookup drops it, but the text up to its last/became part of every rebased path. Even without that, a composition in a deep real folder multiplies every short../xreference (asrcsetcandidate can be 6 bytes) by the folder's length. Nothing counted those bytes, so a small project could make the compile build gigabytes of strings.Related work
Builds on #8147 and #8144: uses the same
CompositionExpansionBudgetand the inliner's existingchargeEmittedcallback. No second budget.How
rewriteAssetPath(parsers) takes an optionalchargecallback and reports what each rebased reference adds over the authored one. Every rebase goes through it: attributes,srcsetcandidates, inline styles and CSSurl()(viarewriteAssetPaths,rewriteInlineStyleAssetUrlsandrewriteCssAssetUrls, which pass it on), plus hoisted link and script URLs and import-map addresses in the inliner. A charge that throws stops the rewrite at that reference, before more strings are built.resolveFilePath(src): the project-relative fileresolveHtmlread. It rebases from that path instead of the attribute. The producer fills it fromresolveCompositionFile, the same function that reads the mount, so the two cannot disagree. The preview bundler reads the attribute as a literal path already, so it passes nothing and keeps today's behaviour (a folder really namedscenes%20#still works;htmlBundler.test.tscovers it).srcthroughchargeEmitted; the producer's entry-file rebase now runs after the render's budget is created and charges it too.Test plan
fails without the fix:
htmlCompiler.sizeLimit.test.ts"rebases from the mounted file, not a query in its src" (the query text lands in every rebased path), "refuses a mount in a deep folder whose rebased references add up past the limit" and "refuses an entry file in a deep folder ..." (both compile with no refusal on main);rewriteSubCompPaths.test.ts"reports what each rebased reference adds, for every rewrite path" (no charge on main).One mutation per behaviour, each turning its test red and restored (with parsers and core rebuilt, since producer loads their built output): the inliner rebasing from the raw attribute, no charge in
rewriteAssetPath, and an entry-file charge that does nothing.New size-limit tests passed 3 runs in a row (about 0.55 s each for the deep-folder cases).
parsers
src1583 passed, coresrc/compiler702 passed, producerhtmlCompiler.sizeLimit.test.ts23 andhtmlCompiler.test.ts196 passed.tsc --noEmitclean for parsers, core and producer; oxfmt, oxlint andfallow auditclean.Unit tests added/updated
Manual testing performed (no end-to-end render)
Documentation updated (if applicable): no docs change
Comments follow CONTRIBUTING.md "Comments"