Adds /__wrnexus/islands.js (the bootstrap) and the /__wrnexus/island/ prefix (mount runtime, island bundles, shared chunks) to all three serving paths. Dev reuses the browserArtifactPaths registry pattern from pipeline.ts. Prod mirrors the clientModulesDir handler, including its filename allowlist, so island names cannot escape the output directory. The bootstrap is inert without a data-wrn-island marker, so island-free pages still download nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
26 lines
956 B
TypeScript
26 lines
956 B
TypeScript
import { expect, test } from "bun:test";
|
|
import { getIslandRuntime } from "../src/runtime-source.ts";
|
|
|
|
test("emits a runtime that bails out when no island markers exist", () => {
|
|
const source = getIslandRuntime(false);
|
|
expect(source).toContain("data-wrn-island");
|
|
expect(source).toContain("/__wrnexus/island/");
|
|
});
|
|
|
|
test("registers a navigation hook so islands unmount on route change", () => {
|
|
expect(getIslandRuntime(false)).toContain("__wrnexusUnmountIslands");
|
|
});
|
|
|
|
test("never references react-dom/server", () => {
|
|
expect(getIslandRuntime(true)).not.toContain("react-dom/server");
|
|
});
|
|
|
|
test("threads the development flag into the mount options", () => {
|
|
expect(getIslandRuntime(true)).toContain("development: true");
|
|
expect(getIslandRuntime(false)).toContain("development: false");
|
|
});
|
|
|
|
test("encodes the island name before using it as a URL path segment", () => {
|
|
expect(getIslandRuntime(false)).toContain("encodeURIComponent");
|
|
});
|