release: WRNexusJS 0.8.0
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
* `wrnexus build` generates an entry that statically imports every route and
|
||||
* component module and hands them here as a manifest. We rebuild the (cheap)
|
||||
* route-matching tables from the raw patterns and run the exact same request
|
||||
* runtime as dev — just with production error pages and no live-reload client.
|
||||
* runtime as dev. Normal preview/deploy output has no live-reload client; the
|
||||
* supervised `dev --production-runtime` mode can explicitly enable it.
|
||||
*/
|
||||
|
||||
import type { Middleware, Mode, SecurityConfig, SeoConfig } from "@wrnexus/core";
|
||||
@@ -16,7 +17,12 @@ import {
|
||||
type Route,
|
||||
type Router,
|
||||
} from "@wrnexus/router";
|
||||
import { getReactiveRuntime, getNavRuntime, getRealtimeRuntime } from "@wrnexus/csr";
|
||||
import {
|
||||
getActionRuntime,
|
||||
getReactiveRuntime,
|
||||
getNavRuntime,
|
||||
getRealtimeRuntime,
|
||||
} from "@wrnexus/csr";
|
||||
import {
|
||||
loadEnv,
|
||||
resolveProfile,
|
||||
@@ -43,6 +49,7 @@ import { realtimeBusFromConfig } from "./realtime-bus.ts";
|
||||
import { createHandlers, type AssetServer, type WsData } from "./runtime.ts";
|
||||
import { servePublicAsset } from "./public.ts";
|
||||
import type { ClientRuntimeDefinition } from "@wrnexus/plugin";
|
||||
import { HmrHub } from "./hmr.ts";
|
||||
|
||||
type RouteModule = Record<string, unknown>;
|
||||
|
||||
@@ -51,6 +58,8 @@ export interface ManifestRoute {
|
||||
raw: string;
|
||||
/** The statically-imported route module. */
|
||||
mod: RouteModule;
|
||||
/** Body shell precomputed by `wrnexus build` for a partial-static page. */
|
||||
staticShell?: string;
|
||||
}
|
||||
|
||||
export interface ProdManifest {
|
||||
@@ -139,6 +148,8 @@ export interface ProdOptions {
|
||||
port?: number;
|
||||
hostname?: string;
|
||||
maxBodyBytes?: number;
|
||||
/** Enable only for the CLI's supervised exact-production development mode. */
|
||||
developmentRuntime?: boolean;
|
||||
}
|
||||
|
||||
const MODE: Mode = "production";
|
||||
@@ -181,7 +192,10 @@ function buildProdRouter(manifest: ProdManifest): {
|
||||
const routes = entries.map((e): Route => {
|
||||
const { regex, paramNames } = compileRoutePattern(e.raw);
|
||||
// Use the raw pattern as a stable module key.
|
||||
modules.set(e.raw, e.mod);
|
||||
modules.set(
|
||||
e.raw,
|
||||
e.staticShell === undefined ? e.mod : { ...e.mod, __wrnexusStaticShell: e.staticShell },
|
||||
);
|
||||
return { raw: e.raw, file: e.raw, regex, paramNames };
|
||||
});
|
||||
return sortRoutes(routes);
|
||||
@@ -236,6 +250,8 @@ function createProdAssetServer(opts: ProdOptions): AssetServer {
|
||||
return new Response(getNavRuntime(), { headers: JS_HEADERS });
|
||||
if (pathname === "/__wrnexus/realtime.js")
|
||||
return new Response(getRealtimeRuntime(), { headers: JS_HEADERS });
|
||||
if (pathname === "/__wrnexus/actions.js")
|
||||
return new Response(getActionRuntime(), { headers: JS_HEADERS });
|
||||
if (pathname === "/__wrnexus/validate.js")
|
||||
return new Response(VALIDATE_RUNTIME, { headers: JS_HEADERS });
|
||||
if (pathname === "/__wrnexus/i18n.js")
|
||||
@@ -308,9 +324,11 @@ export function createProductionHandlers(
|
||||
return mod;
|
||||
};
|
||||
|
||||
const productionHmr = opts.developmentRuntime === true;
|
||||
const handlers = createHandlers({
|
||||
mode: MODE,
|
||||
hmr: false,
|
||||
hmr: productionHmr,
|
||||
hub: productionHmr ? new HmrHub() : undefined,
|
||||
router,
|
||||
loadModule,
|
||||
getMiddleware,
|
||||
|
||||
Reference in New Issue
Block a user