Skip to content
Source
Sign inSign up

warm-dep-cache.ts

23 lines991 Bytes

1// @effect-diagnostics nodeBuiltinImport:off - plain Node script that dev-runner spawns on a cold cache.
2/**
3 * The cache cannot be shared between worktrees: Vite's config hash includes
4 * the absolute project root, so each worktree must warm its own.
5 */
6import * as NodePath from "node:path";
7import * as NodeURL from "node:url";
8​
9import { optimizeDeps, resolveConfig } from "vite";
10​
11const webRoot = NodePath.dirname(NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)));
12​
13const configStart = performance.now();
14const config = await resolveConfig({ root: webRoot, logLevel: "error" }, "serve");
15if (process.env.T3CODE_STARTUP_PROFILE_DIR) {
16 performance.measure("web.warmDepCache.resolveConfig", { start: configStart });
18const optimizeStart = performance.now();
19await optimizeDeps(config);
20if (process.env.T3CODE_STARTUP_PROFILE_DIR) {
21 performance.measure("web.warmDepCache.optimizeDeps", { start: optimizeStart });
23console.log("[warm-dep-cache] web dependency cache is warm");