Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodeModule from "node:module";
3import * as NodeOS from "node:os";
4import * as NodePath from "node:path";
5import { enablePreparedServerCache } from "../../../scripts/lib/server-compile-cache.ts";
6
7// Linux /tmp is shared; macOS and Windows temp dirs are per user.
8// AppImage mounts change paths each launch, so Node's path-keyed cache would miss and accumulate copies.
9try {
10 if (!process.env.APPIMAGE || process.env.ELECTRON_RUN_AS_NODE === "1") {
11 const cacheRoot =
12 // oxlint-disable-next-line t3code/no-global-process-runtime -- Loads before any Effect runtime.
13 process.platform === "linux"
14 ? process.env.XDG_CACHE_HOME || NodePath.join(NodeOS.homedir(), ".cache")
15 : NodeOS.tmpdir();
16 const directory = NodePath.join(cacheRoot, "t3code", "compile-cache");
17 const prepared =
18 process.env.ELECTRON_RUN_AS_NODE === "1" &&
19 enablePreparedServerCache(process.argv[1] ?? "", directory);
20 if (!prepared && !process.env.APPIMAGE) {
21 NodeModule.enableCompileCache(directory);
22 }
23 }
24} catch {}