fix(core): extract head styles/scripts in bundler for non-template sub-comps

Same bug as the runtime and producer fixes, but in the bundler
used by the studio preview. The bundler's sub-composition
inlining parsed only body.innerHTML for non-template
sub-compositions, dropping all <head> styles and scripts.

This is why the iris-wipe showed black in the studio preview —
the scene backgrounds and GSAP CDN script were in <head>.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Miguel Ángel
2026-04-07 14:54:26 +00:00
committed by Miguel Ángel
co-authored by Claude Opus 4.6
parent df2cf47d20
commit f8efac291f
+16
View File
@@ -440,6 +440,22 @@ export async function bundleToSingleHtml(
? contentDoc.querySelector(`[data-composition-id="${compId}"]`)
: contentDoc.querySelector("[data-composition-id]");
// When a sub-composition is a full HTML document (no <template>), styles
// and scripts in <head> are not part of contentDoc (which only has body
// content). Extract them so backgrounds, positioning, fonts, and library
// scripts (e.g. GSAP CDN) are not silently dropped.
if (!contentRoot && compDoc.head) {
for (const s of [...compDoc.head.querySelectorAll("style")]) {
compStyleChunks.push(rewriteCssAssetUrls(s.textContent || "", src));
}
for (const s of [...compDoc.head.querySelectorAll("script")]) {
const externalSrc = (s.getAttribute("src") || "").trim();
if (externalSrc && !compExternalScriptSrcs.includes(externalSrc)) {
compExternalScriptSrcs.push(externalSrc);
}
}
}
for (const s of [...contentDoc.querySelectorAll("style")]) {
compStyleChunks.push(rewriteCssAssetUrls(s.textContent || "", src));
s.remove();