fix(dev-server): isolate generated cache per process
This commit is contained in:
@@ -272,7 +272,11 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
|
|||||||
|
|
||||||
const pluginContributions = await pluginRunner.contributions();
|
const pluginContributions = await pluginRunner.contributions();
|
||||||
const virtualModules = new Map<string, string>();
|
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 });
|
mkdirSync(virtualDir, { recursive: true });
|
||||||
for (const [index, module] of pluginContributions.virtualModules.entries()) {
|
for (const [index, module] of pluginContributions.virtualModules.entries()) {
|
||||||
const output = join(virtualDir, `plugin-${index}.ts`);
|
const output = join(virtualDir, `plugin-${index}.ts`);
|
||||||
@@ -327,12 +331,13 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
|
|||||||
|
|
||||||
resetDevCache({
|
resetDevCache({
|
||||||
rootDir: appRoot,
|
rootDir: appRoot,
|
||||||
|
cacheDir,
|
||||||
enabled: process.env.WRNEXUS_PRESERVE_CACHE !== "1",
|
enabled: process.env.WRNEXUS_PRESERVE_CACHE !== "1",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Compile every `.wrn` into ONE cache dir at the project root, instead of a
|
// 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).
|
// `.wrnexus/` next to each source file (and inside node_modules UI dirs).
|
||||||
setCompileCacheDir(join(appRoot, ".wrnexus"));
|
setCompileCacheDir(cacheDir);
|
||||||
const theme = resolveThemeConfig(opts.theme);
|
const theme = resolveThemeConfig(opts.theme);
|
||||||
const uiStylesPath = uiCssPath();
|
const uiStylesPath = uiCssPath();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user