Open History to see the last commit
1import * as NodeModule from "node:module";
2import * as Effect from "effect/Effect";
3import * as Schema from "effect/Schema";
4
5class CompileCacheFlushError extends Schema.TaggedError<CompileCacheFlushError>()(
6 "CompileCacheFlushError",
7 { cause: Schema.Defect() },
8) {
9 override get message(): string {
10 return "Could not flush the module compile cache.";
11 }
12}
13
14// Windows force-kills on quit; persist the cache after startup.
15export const flushCompileCache = Effect.try({
16 try: () => {
17 if (!Reflect.get(globalThis, Symbol.for("t3code.preparedServerCache"))) {
18 NodeModule.flushCompileCache();
19 }
20 },
21 catch: (cause) => new CompileCacheFlushError({ cause }),
22}).pipe(Effect.ignore);