test(06-05): failing guidance-surface suite GS1-GS7 — five-slot banner, list row states, gantry blink, sanctioned-innerHTML + copy gates (RED)
- Node-side ?raw loader twin so tests exercise the committed glyph strings verbatim - banner/list behavioral cases via the minimal document fake (theme.test pattern)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* glyph-raw-loader.mjs — the Node-side twin of Vite's `?raw` import suffix.
|
||||
* ----------------------------------------------------------------------------
|
||||
* glyphs.ts imports the committed SVGs with Vite's `?raw` (the single-source
|
||||
* law). Plain Node cannot load .svg modules, so the guidance-surface suite
|
||||
* registers this `load` hook (node:module register) before its dynamic
|
||||
* imports: any specifier ending in `?raw` resolves to the real file on disk
|
||||
* and exports its text as the module default — byte-identical to what Vite
|
||||
* ships, so the tests exercise the SAME glyph strings the app renders.
|
||||
* The hook only intercepts `?raw` specifiers; every other import falls
|
||||
* through to the default loader (type stripping included).
|
||||
*/
|
||||
import { readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (url.endsWith("?raw")) {
|
||||
const content = readFileSync(fileURLToPath(new URL(url)), "utf8");
|
||||
return {
|
||||
format: "module",
|
||||
source: `export default ${JSON.stringify(content)};\n`,
|
||||
shortCircuit: true,
|
||||
};
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
Reference in New Issue
Block a user