diff --git a/compiler/test/node.mjs b/compiler/test/node.mjs
index 15984a05..da2c0070 100644
--- a/compiler/test/node.mjs
+++ b/compiler/test/node.mjs
@@ -1,9 +1,10 @@
// The Node-API build loads on this platform and compiles a program for every target: what CI checks on each binary
-// before it is published. Usage: node test/node.mjs (after `npm run build`)
+// before it is published. Then the Vite front end's cache over it (vite.mjs).
+// Usage: node test/node.mjs (after `npm run build`)
import { createRequire } from "node:module";
-import { fileURLToPath } from "node:url";
+import { fileURLToPath, pathToFileURL } from "node:url";
import path from "node:path";
-import { mkdtempSync, writeFileSync } from "node:fs";
+import { mkdtempSync, renameSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
const { app } = createRequire(import.meta.url)("../index.js");
@@ -36,4 +37,27 @@ const code = Object.values(rel.modules ?? {}).map(m => m.code).join("\n");
const relOk = !rel.error && !rel.diagnostics && /from "\.\/util\.js"/.test(code) && !/from "\.\/api"/.test(code);
if (!relOk) fail++;
console.log(`${relOk ? "✓" : "✗"} a relative JS import stays an ES import${relOk ? "" : `: ${JSON.stringify(rel).slice(0, 300)}`}`);
+// the Vite front end (vite.mjs) does not keep a failed build: a program that failed on an import compiles once the import
+// is back (#84). The diagnostic names the importer and a rename keeps the file's mtime, so nothing it stamped changes
+const { default: rx } = await import(pathToFileURL(fileURLToPath(new URL("../vite.mjs", import.meta.url))).href);
+const root = mkdtempSync(path.join(tmpdir(), "rx-recover-"));
+const main = path.join(root, "main.rx"), part = path.join(root, "part.rx"), away = path.join(root, "part.away");
+writeFileSync(main, 'import { Part } from "./part.rx"\n\nexport default component App() {\n \n}\n');
+writeFileSync(part, 'export component Part(props: { label: string }) {\n {props.label}\n}\n');
+const ctx = (id, moduleId) => ({ id, moduleId, root, solid: { generate: "dom" }, addWatchFile() {} });
+const entry = front => front.compile("", ctx(main, main)).code, dep = front => front.compile("", ctx(part, `${part}?rx-dep`)).code;
+const lost = compile => { try { compile(); } catch (e) { return /main\.rx:\d+(:\d+)?: error MODULE_NOT_FOUND/.test(e.message); } return false; };
+let recovered;
+try {
+ const warm = rx(), want = { entry: entry(warm), dep: dep(warm) };
+ renameSync(part, away); const failed = lost(() => entry(warm)); renameSync(away, part);
+ if (!failed) throw new Error("a missing import is not MODULE_NOT_FOUND at its importer");
+ if (entry(warm) !== want.entry || dep(warm) !== want.dep) throw new Error("the program compiled after its import came back differs from the first");
+ // and a program whose first compile failed, then asked for by its dependency (the cold path)
+ const cold = rx();
+ renameSync(part, away); lost(() => entry(cold)); renameSync(away, part);
+ if (dep(cold) !== want.dep) throw new Error("the dependency of a program that had failed differs from the first");
+} catch (e) { recovered = e.message.split("\n")[0]; }
+if (recovered) fail++;
+console.log(`${recovered ? "✗" : "✓"} the Vite front end compiles a program again once its missing import is back${recovered ? `: ${recovered}` : ""}`);
process.exit(fail ? 1 : 0);
diff --git a/compiler/vite.mjs b/compiler/vite.mjs
index ed6f0275..423da87a 100644
--- a/compiler/vite.mjs
+++ b/compiler/vite.mjs
@@ -65,7 +65,8 @@ export default function rx() {
function build(entry, target, moduleName, spa) {
const key = `${entry}\0${target}\0${moduleName}\0${spa}`;
const prior = builds.get(key);
- if (prior && fresh(prior)) return prior;
+ // a failed build's stamps miss what it failed to find (MO-6 names the importer), so it is never reused
+ if (prior?.out.modules && fresh(prior)) return prior;
const out = JSON.parse(app(entry, target, moduleName, spa));
if (out.modules) out.modules = Object.fromEntries(Object.entries(out.modules).map(([p, m]) => [path.resolve(p), m]));
const files = out.modules ? Object.keys(out.modules) : out.diagnostics ? [...new Set([entry, ...out.diagnostics.map(d => d.file)])] : [entry];