fix(cli): invalidate client modules when bundled dependencies change
This commit is contained in:
1 parent
62d1dd8bf3
commit
ed1d3a59cf
4 files changed
+34
-3
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user