fix(cli): invalidate client modules when bundled dependencies change
Quality / quality (ubuntu-latest) (push) Canceled after 0s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-10-01 22:17:11 +05:30
1 parent 62d1dd8bf3
commit ed1d3a59cf
4 files changed
+34 -3

No files matched your search

+8 -1
View File
@@ -344,7 +344,14 @@ export async function runBuild(appRoot: string): Promise<void> {
`WRN-CLIENT-BUNDLE: failed to bundle ${file}\n${browserResult.logs.map(String).join("\n")}`,
);
}
writeFileSync(clientOut, await browserResult.outputs[0]!.text(), "utf8");
// Cache identity must cover bundled dependencies, not only the .wrn source.
// Otherwise a renderer/package update reuses an immutable browser URL.
const browserSource = await browserResult.outputs[0]!.text();
const bundleHash = createHash("sha256").update(browserSource).digest("hex").slice(0, 16);
const bundledClientOut = join(clientModulesDir, `${clientStem}-${bundleHash}.mjs`);
writeFileSync(bundledClientOut, browserSource, "utf8");
clientFiles.set(file, bundledClientOut);
writeFileSync(out, code.replaceAll(clientUrl, `/__wrnexus/client/${basename(bundledClientOut)}`), "utf8");
rmSync(clientEntry, { force: true });
} catch (error) {
compiledFiles.delete(file);