fix(ci): preserve imported dist chunks after install

This commit is contained in:
Peter Steinberger
2026-04-29 01:12:59 +01:00
parent 054b2e1b7e
commit 03b1731d0f
5 changed files with 110 additions and 4 deletions

View File

@@ -401,6 +401,28 @@ describe("bundled plugin postinstall", () => {
await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
});
it("keeps imported dist chunks even when inventory is stale", async () => {
const packageRoot = await createTempDirAsync("openclaw-packaged-install-import-");
const entryFile = path.join(packageRoot, "dist", "cli", "run-main.js");
const importedChunk = path.join(packageRoot, "dist", "memory-state-CcqRgDZU.js");
const staleFile = path.join(packageRoot, "dist", "memory-state-old.js");
await fs.mkdir(path.dirname(entryFile), { recursive: true });
await fs.writeFile(entryFile, 'await import("../memory-state-CcqRgDZU.js");\n');
await writePackageDistInventory(packageRoot);
await fs.writeFile(importedChunk, "export {};\n");
await fs.writeFile(staleFile, "export {};\n");
expect(
pruneInstalledPackageDist({
packageRoot,
log: { log: vi.fn(), warn: vi.fn() },
}),
).toEqual(["dist/memory-state-old.js"]);
await expect(fs.stat(importedChunk)).resolves.toBeTruthy();
await expect(fs.stat(staleFile)).rejects.toMatchObject({ code: "ENOENT" });
});
it("prunes stale private QA files without restoring compat sidecars", async () => {
const packageRoot = await createTempDirAsync("openclaw-packaged-install-qa-compat-");
const currentFile = path.join(packageRoot, "dist", "entry.js");