fix(dev-server): isolate generated cache per process

This commit is contained in:
2026-08-09 12:56:11 +05:30
parent 504d065003
commit e4502f2437
+7 -2
View File
@@ -272,7 +272,11 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
const pluginContributions = await pluginRunner.contributions();
const virtualModules = new Map<string, string>();
const virtualDir = join(appRoot, ".wrnexus", "virtual");
// A live dev server and a test process can share an app root. Keeping the
// generated artifacts in a process-specific directory prevents a test boot
// from deleting the running server's client modules.
const cacheDir = join(appRoot, `.wrnexus-${process.pid}`);
const virtualDir = join(cacheDir, "virtual");
mkdirSync(virtualDir, { recursive: true });
for (const [index, module] of pluginContributions.virtualModules.entries()) {
const output = join(virtualDir, `plugin-${index}.ts`);
@@ -327,12 +331,13 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
resetDevCache({
rootDir: appRoot,
cacheDir,
enabled: process.env.WRNEXUS_PRESERVE_CACHE !== "1",
});
// Compile every `.wrn` into ONE cache dir at the project root, instead of a
// `.wrnexus/` next to each source file (and inside node_modules UI dirs).
setCompileCacheDir(join(appRoot, ".wrnexus"));
setCompileCacheDir(cacheDir);
const theme = resolveThemeConfig(opts.theme);
const uiStylesPath = uiCssPath();