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:
ClintchizandClaude Opus 5 committed 2026-08-18 15:28:10 +05:30
1 parent 06df9d66ae
commit a184f1a3be
10 files changed
+135 -12

No files matched your search

+11
View File
@@ -25,6 +25,7 @@ import {
getNavRuntime,
getRealtimeRuntime,
} from "@wrnexus/csr";
import { getIslandRuntime } from "@wrnexus/react/runtime";
import {
loadEnv,
resolveProfile,
@@ -99,6 +100,7 @@ export interface ProdOptions {
controllersPath?: string;
/** Absolute directory containing bundled per-WRN browser modules. */
clientModulesDir?: string;
islandsDir?: string;
/** Absolute path to the pre-built theme stylesheet (`theme.css`). */
themePath?: string;
/** Pre-built active theme/accent stylesheets, loaded on demand. */
@@ -341,6 +343,15 @@ function createProdAssetServer(opts: ProdOptions): AssetServer {
}
return serveFile(join(opts.clientModulesDir, name), JS_HEADERS);
}
if (pathname.startsWith("/__wrnexus/island/")) {
const name = pathname.slice("/__wrnexus/island/".length);
if (!opts.islandsDir || !/^[A-Za-z0-9._-]+\.js$/.test(name)) {
return new Response("Not Found", { status: 404 });
}
return serveFile(join(opts.islandsDir, name), JS_HEADERS);
}
if (pathname === "/__wrnexus/islands.js")
return new Response(getIslandRuntime(), { headers: JS_HEADERS });
if (pathname === "/__wrnexus/reactive.js") {
if (opts.reactivePath) {
const file = Bun.file(opts.reactivePath);