fix(core): consolidate external asset and dependency preservation (#2410)

## Summary

- preserve external SVG fragment references during bundling
- preserve external module scripts and serve `.mjs` with a JavaScript MIME type
- retain template-head stylesheets when mounting sub-compositions
- add regression coverage across compiler runtime and file-server paths

Consolidates and replaces #2390, #2297, and #2375.

## Verification

- core compiler/runtime tests: 89 passed
- producer file-server tests: 48 passed
- core, producer, engine, and CLI typechecks passed
- `git diff --check`
This commit is contained in:
Miguel Ángel
2026-07-14 21:55:51 -04:00
committed by GitHub
parent 5d3a7404fa
commit 7382fabab9
12 changed files with 364 additions and 13 deletions
@@ -315,6 +315,24 @@ describe("parseRangeHeader", () => {
});
describe("createFileServer", () => {
it("serves ES modules with a JavaScript MIME type", async () => {
const projectDir = mkdtempSync(join(tmpdir(), "hf-file-server-mjs-"));
try {
writeEmptyIndex(projectDir);
writeFileSync(join(projectDir, "scene.mjs"), "export const scene = true;");
const server = await createFileServer({ projectDir, preHeadScripts: [], headScripts: [] });
try {
const response = await fetch(`${server.url}/scene.mjs`);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe("application/javascript; charset=utf-8");
} finally {
server.close();
}
} finally {
rmSync(projectDir, { recursive: true, force: true });
}
});
async function expectInjectedRenderFps(
fps: Parameters<typeof createFileServer>[0]["fps"],
expected: {
@@ -79,6 +79,7 @@ const MIME_TYPES: Record<string, string> = {
".html": "text/html; charset=utf-8",
".css": "text/css; charset=utf-8",
".js": "application/javascript; charset=utf-8",
".mjs": "application/javascript; charset=utf-8",
".json": "application/json; charset=utf-8",
".cube": "text/plain; charset=utf-8",
".png": "image/png",