




















@@ -197,6 +197,36 @@ describe("runtime postbuild static assets", () => {
197197);
198198});
199199200+it("rewrites gateway shutdown imports to stable runtime aliases", async () => {
201+const rootDir = createTempDir("openclaw-runtime-postbuild-");
202+const distDir = path.join(rootDir, "dist");
203+await fs.mkdir(distDir, { recursive: true });
204+await fs.writeFile(
205+path.join(distDir, "server-close.runtime-AbCd1234.js"),
206+"export const close = true;\n",
207+"utf8",
208+);
209+await fs.writeFile(
210+path.join(distDir, "server.impl-OldHash.js"),
211+[
212+'const closeModule = () => import("./server-close.runtime-AbCd1234.js");',
213+'const ordinaryChunk = () => import("./server-close-OldHash.js");',
214+"",
215+].join("\n"),
216+"utf8",
217+);
218+219+rewriteRootRuntimeImportsToStableAliases({ rootDir });
220+221+expect(await fs.readFile(path.join(distDir, "server.impl-OldHash.js"), "utf8")).toBe(
222+[
223+'const closeModule = () => import("./server-close.runtime.js");',
224+'const ordinaryChunk = () => import("./server-close-OldHash.js");',
225+"",
226+].join("\n"),
227+);
228+});
229+200230it("keeps hashed imports when a stable runtime alias would collide", async () => {
201231const rootDir = createTempDir("openclaw-runtime-postbuild-");
202232const distDir = path.join(rootDir, "dist");
@@ -274,6 +304,26 @@ describe("runtime postbuild static assets", () => {
274304).toBe('export * from "./runtime-plugins.runtime.js";\n');
275305});
276306307+it("writes compatibility aliases for previous gateway shutdown chunk names", async () => {
308+const rootDir = createTempDir("openclaw-runtime-postbuild-");
309+const distDir = path.join(rootDir, "dist");
310+await fs.mkdir(distDir, { recursive: true });
311+await fs.writeFile(
312+path.join(distDir, "server-close.runtime.js"),
313+'export * from "./server-close.runtime-NewHash.js";\n',
314+"utf8",
315+);
316+317+writeLegacyRootRuntimeCompatAliases({ rootDir });
318+319+expect(await fs.readFile(path.join(distDir, "server-close-DsVPJDIx.js"), "utf8")).toBe(
320+'export * from "./server-close.runtime.js";\n',
321+);
322+expect(await fs.readFile(path.join(distDir, "server-close-DvAvfgr8.js"), "utf8")).toBe(
323+'export * from "./server-close.runtime.js";\n',
324+);
325+});
326+277327it("writes legacy CLI exit compatibility chunks", async () => {
278328const rootDir = createTempDir("openclaw-runtime-postbuild-");
279329此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。