( specifier: string, from: string )
| 402 | // t3-env's presets-arktype: none where it can't load arktype, and the specifier |
| 403 | // where its modules can't be read |
| 404 | export const modulesLoadingArktype = ( |
| 405 | specifier: string, |
| 406 | from: string |
| 407 | ): string[] => { |
| 408 | const name = packageNameOf(specifier) |
| 409 | if (!dependsOnArktype(name, from)) return [] |
| 410 | if (arktypeEntries.includes(name)) return [specifier] |
| 411 | const host = (nodeHost ??= createNodeHost()) |
| 412 | const entry = host.resolve(specifier, join(from, "_")) |
| 413 | if (!entry) return [specifier] |
| 414 | const modules = new Set<string>() |
| 415 | const seen = new Set<string>() |
| 416 | const read = (file: string) => { |
| 417 | if (seen.has(file)) return |
| 418 | seen.add(file) |
| 419 | for (const [, imported] of (host.readFile(file) ?? "").matchAll( |
| 420 | importOrComputed |
| 421 | )) { |
| 422 | if (!imported || arktypeEntries.includes(packageNameOf(imported))) |
| 423 | modules.add(file) |
| 424 | else { |
| 425 | const resolved = host.resolve(imported, file) |
| 426 | if (resolved) read(resolved) |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | read(entry) |
| 431 | return [...modules] |
| 432 | } |
| 433 | |
| 434 | export const packageRootOf = ( |
| 435 | name: string, |
no test coverage detected