// Dev-boot regression guard (2026-10-12 round10 class): a source-level import // of a public-dir /vendor/ asset with a cache-bust query ("?v=...") broke every // Vite dev page with an error overlay while the production build stayed green. // This test boots the real dev server and pins the contract from three sides: // the entry pipeline is healthy, the movi loader never routes /vendor assets // through the module pipeline in DEV, and the prod cache-bust URL — if anyone // re-imports it from source — is exactly the shape the pipeline rejects. import { test } from "node:test"; import assert from "node:assert/strict"; import { createServer } from "vite"; test("vite dev boots and keeps the movi loader off the module pipeline", async () => { const server = await createServer({ root: process.cwd(), logLevel: "error", server: { host: "127.0.0.1", port: 0 }, // Discovering dependencies to pre-bundle keeps close() waiting under node --test, which // then never finishes (Node 24/26) or fails the test (Node 22). optimizeDeps: { noDiscovery: true }, }); await server.listen(); try { const origin = new URL(server.resolvedUrls.local[0]).origin; // 1) The dev transform pipeline itself is healthy on the app entry. const entry = await server.transformRequest("/src/main.tsx"); assert.ok(entry, "dev server must transform the app entry module"); // 2) The real loader module, executed in DEV mode, must emit a query-less // /vendor URL: dev serves public assets as static files only, and a // query defeats the static resolver (the round10 overlay break). const movi = await server.ssrLoadModule("/src/lib/movi-player.ts"); assert.ok(movi.MOVI_ELEMENT_CACHE_BUST, "cache-bust marker must stay defined"); assert.equal( new URL(movi.MOVI_ELEMENT_JS_URL, origin).search, "", "DEV movi URL must not carry a cache-bust query (round10 regression class)", ); // 3) That DEV URL must be fetchable as a plain static asset (script-tag path). const asset = await fetch(`${origin}${movi.MOVI_ELEMENT_JS_URL}`); assert.equal(asset.status, 200, "dev server must statically serve the movi element script"); assert.ok((await asset.arrayBuffer()).byteLength > 0, "dev asset response must complete"); // 4) Negative control — the prod-shaped URL is exactly what the module // pipeline rejects; this is why importing /vendor assets from source is // forbidden in dev and the loader uses a script tag there instead. await assert.rejects( server.transformRequest( `/vendor/movi-player-${movi.MOVI_VERSION}/element.slim.js?v=${movi.MOVI_ELEMENT_CACHE_BUST}`, ), /Failed to load url/, "module pipeline must keep refusing /vendor assets (documented break class)", ); // 5) The shell page itself still responds. const index = await fetch(`${origin}/`); assert.equal(index.status, 200, "dev server must serve the app shell"); await index.text(); } finally { await server.close(); } });