release: WRNexusJS 0.8.0
Quality / quality (ubuntu-latest) (push) Failing after 21s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-02 23:18:51 +05:30
parent 87507edf59
commit 586a6db8ff
625 changed files with 243608 additions and 11210 deletions
+61 -1
View File
@@ -2,7 +2,67 @@ import { expect, test } from "bun:test";
import { mkdtempSync, rmSync, utimesSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { invalidateModule, loadModule, setCompileCacheDir } from "../src/pipeline.ts";
import {
compileWireArtifacts,
compileWireArtifactsAsync,
getWrnCompileMetrics,
invalidateModule,
loadModule,
resetWrnCompileMetrics,
setCompileCacheDir,
setDevCompilerPipeline,
} from "../src/pipeline.ts";
test("development compilation awaits plugin AST and code transforms", async () => {
const root = mkdtempSync(join(tmpdir(), "wrnexus-plugin-pipeline-"));
const file = join(root, "page.wrn");
let astTransformed = false;
setCompileCacheDir(join(root, ".wrnexus"));
setDevCompilerPipeline({
async transformAst(ast) {
await Promise.resolve();
astTransformed = true;
return ast;
},
async transformCode(code) {
await Promise.resolve();
return `${code}\nexport const pluginTransformed = true;\n`;
},
virtualModules: new Map(),
});
try {
writeFileSync(file, "page Home { view { <h1>Plugin</h1> } }\n");
const artifact = await compileWireArtifactsAsync(file);
expect(astTransformed).toBeTrue();
expect((await import(artifact.main)).pluginTransformed).toBeTrue();
} finally {
setDevCompilerPipeline(null);
rmSync(root, { recursive: true, force: true });
}
});
test("WRN compilation exposes cache hit, miss, timing, and error metrics", () => {
const root = mkdtempSync(join(tmpdir(), "wrnexus-cache-metrics-"));
const file = join(root, "page.wrn");
setCompileCacheDir(join(root, ".wrnexus"));
resetWrnCompileMetrics();
try {
writeFileSync(file, "page Home { view { <h1>Metrics</h1> } }\n");
compileWireArtifacts(file);
compileWireArtifacts(file);
writeFileSync(file, "page Broken { view { <h1> } }\n");
expect(() => compileWireArtifacts(file)).toThrow();
expect(getWrnCompileMetrics()).toMatchObject({
hits: 1,
misses: 2,
compilations: 1,
errors: 1,
});
expect(getWrnCompileMetrics().totalDurationMs).toBeGreaterThanOrEqual(0);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("invalidateModule loads changed server modules without restarting the process", async () => {
const root = mkdtempSync(join(tmpdir(), "wrnexus-hmr-"));