feat(islands): serve the island runtime in dev, prod, and static builds
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>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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");
|
||||
});
|
||||
Reference in New Issue
Block a user