30 lines
866 B
JavaScript
30 lines
866 B
JavaScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const routerSource = readFileSync(new URL("../src/router/index.js", import.meta.url), "utf8");
|
|
|
|
assert.doesNotMatch(
|
|
routerSource,
|
|
/import\s+\w+View\s+from\s+"..\/views\/[^"]+\.vue";/,
|
|
"router should not statically import view components into the initial bundle"
|
|
);
|
|
|
|
assert.match(
|
|
routerSource,
|
|
/import\.meta\.glob\("\.\.\/views\/\*\.vue"\)/,
|
|
"router should register lazy view modules with Vite import.meta.glob"
|
|
);
|
|
|
|
for (const viewName of [
|
|
"LoginView",
|
|
"DashboardView",
|
|
"InventoryLedgerView",
|
|
"PurchaseOrderView",
|
|
"ProductionLedgerView",
|
|
"SystemPermissionView"
|
|
]) {
|
|
assert.match(routerSource, new RegExp(`component:\\s*view\\("${viewName}"\\)`), `${viewName} route should use lazy view loader`);
|
|
}
|
|
|
|
console.log("router lazy loading static checks passed");
|