From bb55c1ea7efb907da70c3d403b368c74241c8c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 18 Nov 2026 09:50:35 +0000 Subject: [PATCH] fix(compiler): rebase composition asset paths from the file read and charge what they add (#8166) * test(producer): a deep or query-stretched composition folder stays within the size limit * fix(compiler): rebase composition asset paths from the file read and 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. * test(producer): close the font embedding block after the rebase --- .../src/compiler/inlineSubCompositions.ts | 17 ++++-- .../parsers/src/rewriteSubCompPaths.test.ts | 33 +++++++++++ packages/parsers/src/rewriteSubCompPaths.ts | 19 +++++-- .../src/services/compositionSizeLimit.ts | 2 +- .../services/htmlCompiler.sizeLimit.test.ts | 56 ++++++++++++++++++- .../producer/src/services/htmlCompiler.ts | 28 +++++++++- 6 files changed, 140 insertions(+), 15 deletions(-) diff --git a/packages/core/src/compiler/inlineSubCompositions.ts b/packages/core/src/compiler/inlineSubCompositions.ts index b8fdc62503..7bebb8ccdf 100644 --- a/packages/core/src/compiler/inlineSubCompositions.ts +++ b/packages/core/src/compiler/inlineSubCompositions.ts @@ -216,6 +216,9 @@ export interface InlineSubCompositionsOptions { */ resolveHtml: (srcPath: string) => string | null; + /** The project-relative file `resolveHtml` read for a src; asset paths rebase from its folder. */ + resolveFilePath?: (srcPath: string) => string | null; + /** * Parse an HTML string into a Document. The returned object must expose * standard DOM APIs (querySelector, querySelectorAll, body, head, etc.). @@ -393,6 +396,7 @@ export function inlineSubCompositions( ): InlineSubCompositionsResult { const { resolveHtml, + resolveFilePath, parseHtml, hostIdentityMap, rewriteInlineStyles = false, @@ -564,11 +568,14 @@ export function inlineSubCompositions( warnUnknownEnumValues(innerRoot, mergedVariables, variablesCompId); } + const filePath = resolveFilePath?.(src) ?? src; + const chargeRebase = chargeEmitted && ((bytes: number) => chargeEmitted(src, bytes)); + // `` /