fix(build): serve stable aliases for lazy plugin runtimes
This commit is contained in:
1 parent
ab0a4ff27d
commit
f4eaf416be
4 files changed
+13
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/cli",
|
||||
"version": "0.8.71",
|
||||
"version": "0.8.72",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user