From f4eaf416be1a54c0f9cd72847fdc0c5a77c05c03 Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Fri, 25 Sep 2026 01:38:33 +0530 Subject: [PATCH] fix(build): serve stable aliases for lazy plugin runtimes --- bun.lock | 2 +- packages/cli/package.json | 2 +- packages/cli/src/build.ts | 7 +++++++ packages/cli/test/plugin-runtime-production.test.ts | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bun.lock b/bun.lock index 2ebd5dc2..67c02f66 100644 --- a/bun.lock +++ b/bun.lock @@ -322,7 +322,7 @@ }, "packages/cli": { "name": "@wrnexus/cli", - "version": "0.8.71", + "version": "0.8.72", "bin": { "wrnexus": "src/index.ts", }, diff --git a/packages/cli/package.json b/packages/cli/package.json index 3d1c3280..a9d9ab49 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/cli", - "version": "0.8.71", + "version": "0.8.72", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/cli/src/build.ts b/packages/cli/src/build.ts index a6ec229d..9cfde366 100644 --- a/packages/cli/src/build.ts +++ b/packages/cli/src/build.ts @@ -1053,6 +1053,13 @@ async function emitPluginAssets( immutable: true, }); // The emitted runtime is served from its content-addressed public path. + // Lazy runtime imports use stable plugin URLs, just as in development. + // Keep that alias revalidatable while the HTML uses the immutable URL. + const stablePath = runtime.publicPath ?? `/__wrnexus/assets/${safeAssetName(runtime.id)}.js`; + if (stablePath !== publicPath) { + assets.push({ id: runtime.id, publicPath: stablePath, file, + contentType: "text/javascript; charset=utf-8", runtime: true, immutable: false }); + } // Keep an empty source marker so @wrnexus/plugin can normalize this // already-emitted descriptor during production HTML rendering without // trying to resolve the original build-time source on the deploy host. diff --git a/packages/cli/test/plugin-runtime-production.test.ts b/packages/cli/test/plugin-runtime-production.test.ts index 096d9f05..4b997122 100644 --- a/packages/cli/test/plugin-runtime-production.test.ts +++ b/packages/cli/test/plugin-runtime-production.test.ts @@ -83,6 +83,10 @@ export default { const asset = await fetch(`http://127.0.0.1:${port}${assetPath}`); expect(asset.status).toBe(200); expect(await asset.text()).toContain("window.__runtimeFixture = true"); + const lazyAsset = await fetch(`http://127.0.0.1:${port}/__wrnexus/assets/runtime-fixture.js`); + expect(lazyAsset.status).toBe(200); + expect(await lazyAsset.text()).toContain("window.__runtimeFixture = true"); + expect(lazyAsset.headers.get("cache-control") ?? "").not.toContain("immutable"); } finally { proc.kill(); await proc.exited;