42 lines
2.0 KiB
JavaScript
42 lines
2.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { dirname, relative, resolve, sep } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { resolveConfig } from "vite";
|
|
|
|
const webuiRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
|
|
function contains(parent, candidate) {
|
|
const suffix = relative(parent, candidate);
|
|
return suffix === "" || (!suffix.startsWith(`..${sep}`) && suffix !== ".." && !suffix.startsWith(sep));
|
|
}
|
|
|
|
// Resolve the real Vite configurations without creating a server, optimizing
|
|
// dependencies, or changing any existing development/browser-test cache.
|
|
const app = await resolveConfig({
|
|
root: webuiRoot,
|
|
configFile: resolve(webuiRoot, "vite.config.ts")
|
|
}, "serve");
|
|
const conformance = await resolveConfig({
|
|
root: webuiRoot,
|
|
configFile: resolve(webuiRoot, "vite.conformance.config.ts")
|
|
}, "serve");
|
|
|
|
assert.notEqual(app.cacheDir, conformance.cacheDir,
|
|
"Browser conformance must never replace the running application's optimized dependencies.");
|
|
assert.ok(!contains(app.cacheDir, conformance.cacheDir) && !contains(conformance.cacheDir, app.cacheDir),
|
|
"Neither cache may own the other cache's directory: optimizer cleanup must remain isolated.");
|
|
assert.equal(dirname(app.cacheDir), dirname(conformance.cacheDir),
|
|
"Product and conformance use explicit sibling cache directories.");
|
|
assert.ok(contains(resolve(webuiRoot, "node_modules"), app.cacheDir),
|
|
"The application cache remains generated local dependency state.");
|
|
assert.ok(contains(resolve(webuiRoot, "node_modules"), conformance.cacheDir),
|
|
"The conformance cache remains generated local dependency state.");
|
|
assert.ok(app.optimizeDeps.include.includes("@xyflow/react"),
|
|
"Lazy Workflow and Dataflow graph imports are prebundled before their first visit.");
|
|
assert.ok(app.optimizeDeps.include.includes("read-excel-file/browser"),
|
|
"Deferred spreadsheet imports remain prebundled.");
|
|
assert.ok(app.optimizeDeps.include.includes("@tiptap/react"),
|
|
"Deferred rich-text editors remain prebundled.");
|
|
|
|
console.log("Vite product/conformance dependency-cache isolation passed.");
|