| 54 | // node_modules/.cache/ark-units, where a build resolves them and Turbopack |
| 55 | // doesn't deny them as it does .next |
| 56 | const nodeModulesOf = (root: string): string | undefined => { |
| 57 | let cacheOnly: string | undefined |
| 58 | for (let dir = root; ; dir = dirname(dir)) { |
| 59 | const modules = join(dir, "node_modules") |
| 60 | if (existsSync(modules)) { |
| 61 | // skip a node_modules created only for .cache/ark-programs so warm builds |
| 62 | // keep resolving the same package-manager node_modules as cold builds |
| 63 | if (readdirSync(modules).some(name => name !== ".cache")) return modules |
| 64 | cacheOnly ??= modules |
| 65 | } |
| 66 | if (dir === dirname(dir)) return cacheOnly |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | export const isProgramUnit = (id: string): boolean => |
| 71 | /[/\\]node_modules[/\\]\.cache[/\\]ark-units[/\\]/.test(id) |