release: WRNexusJS 0.8.3
Quality / quality (ubuntu-latest) (push) Failing after 12m9s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-03 19:47:30 +05:30
parent e8f630f12d
commit 4cebacadfe
156 changed files with 2608 additions and 473 deletions
@@ -0,0 +1,90 @@
import { expect, test } from "bun:test";
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
compileWireArtifactsAsync,
setCompileCacheDir,
setCompileImportOptions,
} from "../src/pipeline.ts";
test("development browser artifacts bundle local client imports", async () => {
const root = mkdtempSync(join(tmpdir(), "wrnexus-client-bundle-"));
const app = join(root, "app");
const cache = join(root, ".wrnexus");
mkdirSync(app, { recursive: true });
writeFileSync(join(app, "helper.ts"), "export function save(value: unknown) { return value; }\n");
const page = join(app, "settings.wrn");
writeFileSync(
page,
`import { save } from "./helper.ts"
page Settings {
state { value = 1 }
functions { client function persist() { return save(value) } }
view { <button @click='persist()'>Save</button> }
}`,
);
try {
setCompileCacheDir(cache);
const artifacts = await compileWireArtifactsAsync(page);
const browser = readFileSync(artifacts.browser, "utf8");
expect(browser).toContain("wrnexus-client-bundled");
expect(browser).not.toContain("file://");
expect(browser).not.toContain('from "./helper.ts"');
} finally {
setCompileCacheDir(null);
rmSync(root, { recursive: true, force: true });
}
});
test("development browser artifacts bundle configured alias imports", async () => {
const root = mkdtempSync(join(tmpdir(), "wrnexus-client-alias-bundle-"));
const app = join(root, "app");
const cache = join(root, ".wrnexus");
mkdirSync(join(app, "client"), { recursive: true });
writeFileSync(
join(app, "client", "storage.ts"),
"export function persist(value: unknown) { return value; }\n",
);
const page = join(app, "settings.wrn");
writeFileSync(
page,
`import { persist } from "~/client/storage.ts"
page Settings {
state { value = 1 }
functions { client function save() { return persist(value) } }
view { <button @click='save()'>Save</button> }
}`,
);
try {
setCompileCacheDir(cache);
setCompileImportOptions(root, {
mode: "explicit",
aliases: { "~": "./app" },
autoImport: false,
});
const artifacts = await compileWireArtifactsAsync(page);
const browser = readFileSync(artifacts.browser, "utf8");
expect(browser).toContain("wrnexus-client-bundled");
expect(browser).not.toContain("~/client/storage.ts");
expect(browser).not.toContain("file://");
mkdirSync(join(root, "alternate", "client"), { recursive: true });
writeFileSync(
join(root, "alternate", "client", "storage.ts"),
"export function persist(value: unknown) { return value; }\n",
);
setCompileImportOptions(root, {
mode: "explicit",
aliases: { "~": "./alternate" },
autoImport: false,
});
const changed = await compileWireArtifactsAsync(page);
expect(changed.browser).not.toBe(artifacts.browser);
} finally {
setCompileCacheDir(null);
rmSync(root, { recursive: true, force: true });
}
});
@@ -62,7 +62,9 @@ test("production streams request regions into the build-time static shell", asyn
test("normal production output remains free of development HMR", async () => {
const handlers = createProductionHandlers(manifest, {});
const response = await handlers.fetch(new Request("http://localhost/"), server);
expect(await (response as Response).text()).not.toContain("/__wrnexus/hmr");
const html = await (response as Response).text();
expect(html).not.toContain("/__wrnexus/hmr");
expect(html).toContain('data-wrn-route-params="{}"');
});
test("production client-load endpoint returns only the requested named result", async () => {
@@ -121,3 +123,43 @@ test("production prefers fast gzip for dynamic HTML and cached Brotli for immuta
)) as Response;
expect(head.headers.get("content-encoding")).toBeNull();
});
test("client-load preserves the active route query string", async () => {
const queryManifest: ProdManifest = {
...manifest,
pages: [
...manifest.pages,
{
raw: "/query",
mod: {
default: () => "<main>Query page</main>",
__wrnexusClientLoad: async (ctx: { url: URL }) => ({
identity: ctx.url.searchParams.get("as"),
}),
},
},
],
};
const handlers = createProductionHandlers(queryManifest, {});
const response = (await handlers.fetch(
new Request(
"http://localhost/__wrnexus/client-load?route=%2Fquery&search=%3Fas%3Drohan&name=identity",
),
server,
)) as Response;
expect(response.status).toBe(200);
expect(await response.json()).toEqual({ data: "rohan" });
});
test("production serves generated WRN browser modules from the client directory", async () => {
const directory = mkdtempSync(join(tmpdir(), "wrnexus-client-modules-"));
writeFileSync(join(directory, "settings-abc123.mjs"), "export const ready = true;\n");
const handlers = createProductionHandlers(manifest, { clientModulesDir: directory });
const response = (await handlers.fetch(
new Request("http://localhost/__wrnexus/client/settings-abc123.mjs"),
server,
)) as Response;
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toContain("text/javascript");
expect(await response.text()).toContain("ready = true");
});