( specifier: string, importer: SourceModule, isValueImport?: () => boolean )
| 1281 | } |
| 1282 | |
| 1283 | resolve( |
| 1284 | specifier: string, |
| 1285 | importer: SourceModule, |
| 1286 | isValueImport?: () => boolean |
| 1287 | ): ImportTarget | SourceModule { |
| 1288 | if (specifier in arktypeNamespacesBySpecifier) { |
| 1289 | return { |
| 1290 | kind: "arktypeNamespace", |
| 1291 | specifier, |
| 1292 | value: arktypeNamespacesBySpecifier[specifier] |
| 1293 | } |
| 1294 | } |
| 1295 | const id = this.host.resolve(specifier, importer.id, isValueImport) |
| 1296 | if (!id) { |
| 1297 | return { |
| 1298 | kind: "unresolved", |
| 1299 | message: `\`${specifier}\` cannot be resolved from ${importer.path}` |
| 1300 | } |
| 1301 | } |
| 1302 | if (!this.isFollowed(id)) { |
| 1303 | // one defining Types, so the fix is to precompile it with the program |
| 1304 | const [, name] = dependencyOf(id) ?? [] |
| 1305 | return { |
| 1306 | kind: "package", |
| 1307 | message: |
| 1308 | !name || !this.importsArktype(id) || this.readsOnlyRuntime(id) ? |
| 1309 | `\`${specifier}\` is a package the build does not read` |
| 1310 | : this.leavesDependencies ? |
| 1311 | `\`${specifier}\` is a package ark emit leaves to Node, though ${specifier === name ? "it" : name} imports arktype` |
| 1312 | : `\`${specifier}\` is a package the build does not read, though ${specifier === name ? "it" : name} imports arktype` |
| 1313 | } |
| 1314 | } |
| 1315 | const imports = (this.importsById[importer.id] ??= []) |
| 1316 | if (!imports.includes(id)) imports.push(id) |
| 1317 | this.modulesById[id] ??= this.load(id, specifier) |
| 1318 | return this.modulesById[id] |
| 1319 | } |
| 1320 | |
| 1321 | // e.g. @hono/arktype-validator, reading only `type.errors` |
| 1322 | readsOnlyRuntime(file: string): boolean { |
no test coverage detected