@exodus/stasis 1.0.0-beta.13 → 1.0.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +5 -1
  2. package/bin/stasis.js +191 -149
  3. package/package.json +31 -7
  4. package/src/audit.js +224 -90
  5. package/src/babel.js +44 -37
  6. package/src/bundle-reader.js +24 -4
  7. package/src/cmd/build.js +218 -8
  8. package/src/cmd/bundle-options.js +31 -25
  9. package/src/cmd/bundle.js +1147 -311
  10. package/src/cmd/github-bundle.js +17 -9
  11. package/src/cmd/output.js +10 -3
  12. package/src/cmd/tokens.js +73 -0
  13. package/src/define.js +5 -0
  14. package/src/diff.js +2 -2
  15. package/src/flow.js +42 -0
  16. package/src/installed-commits.js +4 -2
  17. package/src/loaders/bash.js +2 -27
  18. package/src/loaders/cargo.js +6 -6
  19. package/src/loaders/foundry.js +4 -6
  20. package/src/loaders/paths.js +4 -15
  21. package/src/loaders/php.js +3 -5
  22. package/src/loaders/rust.js +19 -39
  23. package/src/loaders/solidity-ownership.js +4 -15
  24. package/src/loaders/solidity.js +4 -67
  25. package/src/metro-assets.js +65 -0
  26. package/src/metro-resolver.js +76 -123
  27. package/src/parse.js +7 -3
  28. package/src/resolve-fields.js +133 -366
  29. package/src/resolve-node.js +9 -7
  30. package/src/resolve-typescript.js +102 -30
  31. package/src/scan.js +154 -54
  32. package/src/sixel.js +333 -0
  33. package/src/table.js +116 -0
  34. package/src/validate-notes.d.ts +18 -0
  35. package/src/validate-notes.js +66 -0
  36. package/src/validate.d.ts +132 -0
  37. package/src/validate.js +1349 -0
  38. package/src/vfs-bundle/entries.js +5 -2
  39. package/src/vfs-bundle/github.js +68 -19
  40. package/src/vfs-bundle/glob.js +420 -0
  41. package/src/vfs-bundle/lazy.js +128 -0
  42. package/src/vfs-bundle/prisma.js +102 -29
  43. package/src/vfs-bundle/tree.js +238 -75
  44. package/src/vfs-bundle/yarnclean.js +100 -0
  45. package/src/vfs-bundle.js +16 -7
  46. package/src/why.js +9 -7
package/src/scan.js CHANGED
@@ -3,10 +3,12 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
3
3
  import { createRequire, isBuiltin } from 'node:module'
4
4
  import assert from 'node:assert/strict'
5
5
  import { packageType } from '@exodus/stasis-core/bundle-util'
6
- import { classifyExtension, classifyFormat, isTypeDeclaration, relativeEscapes } from '@exodus/stasis-core/util'
6
+ import { classifyExtension, classifyFormat, isTypeDeclaration, nestedMap, relativeEscapes } from '@exodus/stasis-core/util'
7
7
  import { inNodeModules, resolveTypescriptFallback, typescriptSiblings } from './resolve-typescript.js'
8
8
  import { branchFolder, parseDefine } from './define.js'
9
9
  import { diskHost } from '@exodus/stasis-core/host'
10
+ import { untouchedMemo } from './vfs-bundle/lazy.js'
11
+ import { FLOW_EXTS, hasFlowPragma, stripFlowTypes } from './flow.js'
10
12
 
11
13
  // Static require/import graph walker: parses source, never loads or executes user code.
12
14
  // Dynamic specifiers (`require(name)`, `import('./'+x)`) are recorded as unresolved. With
@@ -16,41 +18,35 @@ import { diskHost } from '@exodus/stasis-core/host'
16
18
  // -- e.g. a package whose React Native entry is src/index.tsx -- is parsed and carried like any .ts.
17
19
  const SCRIPT_EXTS = new Set(['.js', '.cjs', '.mjs', '.ts', '.cts', '.mts', '.jsx', '.tsx'])
18
20
  const RESOLVABLE_EXTS = new Set([...SCRIPT_EXTS, '.json'])
21
+ // Whether a file of extension `ext` (`.mjs`) is code a bundle carries as such.
22
+ export const isResolvableExt = (ext) => RESOLVABLE_EXTS.has(ext)
19
23
  // The extensions whose name can't tell whether they hold JSX, parsed with JSX enabled only under
20
24
  // `jsx` (React Native's JSX-in-.js convention). Excludes the .ts family: TypeScript's `<T>`
21
25
  // generics collide with JSX, so tsc/oxc reserve JSX for .tsx — JSX-in-TS belongs in a .tsx file.
22
26
  const JSX_EXTS = new Set(['.js', '.cjs', '.mjs'])
23
27
 
24
- // Flow type syntax lives in the JS (non-TS) family; oxc parses TS natively, and running
25
- // flow-remove-types over a .ts/.tsx file would corrupt TS-only constructs, so --flow only strips
26
- // these. .jsx is included (it's JS + JSX, and can carry Flow types like .js); .tsx is not (it's
27
- // TypeScript). flow-remove-types preserves JSX, so a stripped .jsx re-parses under lang:jsx.
28
- const FLOW_EXTS = new Set(['.js', '.cjs', '.mjs', '.jsx'])
29
28
  const TS_EXTS = new Set(['.ts', '.cts', '.mts', '.tsx'])
30
29
 
31
- // Required lazily so non-JS bundlers don't load the native oxc parser.
30
+ // Required lazily so non-JS bundlers don't load the native oxc parser. Its parseSync hands each AST
31
+ // over by raw transfer where the platform takes it (oxc's rawTransferSupported), read from the
32
+ // parser's own buffer, rather than as JSON, which takes longer to parse than the source did.
32
33
  let _parser
33
34
  export function getParser() {
34
- _parser ??= createRequire(import.meta.url)('oxc-parser')
35
+ if (_parser === undefined) {
36
+ const oxc = createRequire(import.meta.url)('oxc-parser')
37
+ _parser = oxc.rawTransferSupported() ? { ...oxc, parseSync: (file, source, options) => oxc.parseSync(file, source, { experimentalRawTransfer: true, ...options }) } : oxc
38
+ }
35
39
  return _parser
36
40
  }
37
41
 
38
- // flow-remove-types is stasis's own dependency, resolved from stasis itself (never from the project
39
- // being bundled) and loaded lazily, only under --flow: it strips Flow type syntax down to plain JS
40
- // before oxc (which parses JS/TS, not Flow) sees it.
41
- let _flowRemoveTypes
42
- function getFlowRemoveTypes() {
43
- _flowRemoveTypes ??= createRequire(import.meta.url)('flow-remove-types')
44
- return _flowRemoveTypes
45
- }
46
42
 
47
43
  // classifyFormat is the shared name->format authority (static and runtime bundles must agree); it
48
44
  // returns null for the .js/.ts family whose module system comes from package.json `type` (null =
49
45
  // detect from syntax, signaled up as null).
50
- function formatForFile(file, host) {
46
+ function formatForFile(file, host, kept) {
51
47
  const format = classifyFormat(file)
52
48
  if (format != null) return format
53
- const type = packageType(file, host)
49
+ const type = packageType(file, host, kept)
54
50
  if (type === null) return null
55
51
  return `${type}${extname(file) === '.ts' ? '-typescript' : ''}`
56
52
  }
@@ -122,14 +118,15 @@ function findCallSpecifiers(ast, push, fold = null) {
122
118
  // (`import type { A }` and `import { type A }` yield identical all-isType entries, and
123
119
  // `export {} from` yields no entry at all), so the statements are read off the AST, where
124
120
  // importKind/exportKind carry it. `defines` (parseDefine's) leave out the calls in branches they
125
- // keep from running; static import statements are never in one.
126
- function collectSpecifiers(program, defines = new Map()) {
121
+ // keep from running; static import statements are never in one. `typesOnly(node)`, where given,
122
+ // leaves out a statement it holds lists types alone (see listsTypesOnly).
123
+ function collectSpecifiers(program, defines = new Map(), typesOnly = () => false) {
127
124
  const specs = []
128
125
  for (const node of program.body) {
129
126
  if (node.type === 'ImportDeclaration') {
130
- if (node.importKind !== 'type') specs.push({ kind: 'import', spec: node.source.value })
127
+ if (node.importKind !== 'type' && !typesOnly(node)) specs.push({ kind: 'import', spec: node.source.value })
131
128
  } else if (node.type === 'ExportNamedDeclaration') {
132
- if (node.source != null && node.exportKind !== 'type') specs.push({ kind: 'export-from', spec: node.source.value })
129
+ if (node.source != null && node.exportKind !== 'type' && !typesOnly(node)) specs.push({ kind: 'export-from', spec: node.source.value })
133
130
  } else if (node.type === 'ExportAllDeclaration') {
134
131
  if (node.exportKind !== 'type') specs.push({ kind: 'export-from', spec: node.source.value })
135
132
  }
@@ -175,10 +172,29 @@ export function importsTypescriptByOutputName(entries, host = diskHost) {
175
172
  return targets.length > 0 && targets.every((target) => host.stat(target) === null && mapsTo(target))
176
173
  }
177
174
 
175
+ const TYPE_KINDS = new Set(['type', 'typeof'])
176
+
177
+ // Whether the import or re-export statement `node` lists specifiers, every one an inline type
178
+ // (`import { type A, typeof B } from`, `export { type C } from`), which Babel's Flow and TypeScript
179
+ // transforms erase whole, as Metro builds (Node keeps one, as `import {} from`). A file --flow
180
+ // stripped has lost them, blanked to whitespace in place in its `strippedSource`, so there the
181
+ // statement lists types alone where it reads otherwise in its `source` (a comment in it stays);
182
+ // a statement written with none (`import {} from`) lists no types. The Metro plugin's transformer
183
+ // draws the same line (typesOnly).
184
+ function listsTypesOnly(node, { source, strippedSource }) {
185
+ const specifiers = node.specifiers ?? []
186
+ if (specifiers.length > 0) return specifiers.every((specifier) => TYPE_KINDS.has(specifier.importKind ?? specifier.exportKind))
187
+ return strippedSource !== null && source.slice(node.start, node.end) !== strippedSource.slice(node.start, node.end)
188
+ }
189
+
178
190
  function condKey(set) {
179
191
  return [...set].join(', ')
180
192
  }
181
193
 
194
+ // How many files the scans parsed, and with a `memo` (#scanKept) resolved again from a parse kept,
195
+ // and took as kept, all told: what a build is reported by (EXODUS_STASIS_DEBUG).
196
+ export const scanCounts = { parsed: 0, resolved: 0, replayed: 0 }
197
+
182
198
  export class Scan {
183
199
  files = new Map()
184
200
  imports = new Map()
@@ -191,7 +207,7 @@ export class Scan {
191
207
  // (`empty` = a browser/react-native `false` redirect) and owns builtin handling when set.
192
208
  // `jsx` opts the .js/.cjs/.mjs family into JSX syntax (React Native's JSX-in-.js convention);
193
209
  // off by default because oxc, like tsc, only auto-enables JSX for .jsx/.tsx by extension.
194
- // `flow`: strip Flow type syntax from JS-family sources before parsing (see #scanFile).
210
+ // `flow`: strip Flow type syntax from JS-family sources, as Metro's Babel does (see parseFile).
195
211
  // `typescript`: retry a failed resolution with tsc's mapping (see #typescriptResolve), with
196
212
  // `typescriptPaths` (a tsconfig paths matcher; see resolveTypescriptFallback) adding tsconfig alias support; only consulted
197
213
  // on the built-in (Node) resolver -- a custom `resolve` owns its own TS handling. Without it, the
@@ -204,7 +220,13 @@ export class Scan {
204
220
  // `host`: the filesystem the walk reads and resolves through (@exodus/stasis-core/host).
205
221
  // `define` (each global name -> its value, see define.js): a require()/import() in a branch they
206
222
  // keep from running (`if (__DEV__)` under `{ __DEV__: false }`) is no edge.
207
- constructor({ conditions = [], resolve = null, jsx = false, flow = false, typescript = false, typescriptPaths = null, typescriptResolve = null, resources = new Set(), define, host = diskHost } = {}) {
223
+ // `babel`: the files are built through Babel (Metro), whose Flow and TypeScript transforms erase an
224
+ // import or re-export listing types alone (`import { type A } from`), so it's no edge either, but
225
+ // in a TypeScript file `keepsTypeImports(file)` holds Babel keeps them for (its transform's
226
+ // `onlyRemoveTypeImports`, as --babel reads the project's config); Flow's erases them always.
227
+ // `memo`: what scans before this one, with these options, read of each file, and where to keep
228
+ // what this one reads (see #scanKept).
229
+ constructor({ conditions = [], resolve = null, jsx = false, flow = false, typescript = false, typescriptPaths = null, typescriptResolve = null, resources = new Set(), define, babel = false, keepsTypeImports = null, host = diskHost, memo = null } = {}) {
208
230
  this.extraConditions = [...conditions]
209
231
  this.customResolve = resolve
210
232
  this.typescriptResolve = typescriptResolve
@@ -214,9 +236,17 @@ export class Scan {
214
236
  this.typescriptPaths = typescriptPaths
215
237
  this.resources = resources
216
238
  this.defines = parseDefine('scan', define)
239
+ this.babel = babel
240
+ this.keepsTypeImports = keepsTypeImports
217
241
  this.host = host
242
+ this.memo = memo
243
+ this.#types = untouchedMemo(host.touches, { retouch: host.retouch })
218
244
  }
219
245
 
246
+ // The `type` of each package.json the files scanned are under, read once (formatForFile's), as
247
+ // a host's own reads are kept (vfs-bundle/lazy.js's untouchedMemo).
248
+ #types
249
+
220
250
  // A reached file whose extension/filename is in the --resources allowlist: carried as an opaque
221
251
  // resource (bytes only, no parse, no edges), not rejected as "a source bundle can't carry".
222
252
  // classifyExtension returns 'resource' only for non-code names in the allowlist, so this never
@@ -234,14 +264,75 @@ export class Scan {
234
264
  this.entries.add(url)
235
265
  queue.push(url)
236
266
  }
237
- while (queue.length > 0) {
238
- const url = queue.shift()
267
+ // FIFO by an index, not shift(): the queue holds every edge's target, and shift() copies a large one.
268
+ for (let head = 0; head < queue.length; head++) {
269
+ const url = queue[head]
239
270
  if (this.files.has(url)) continue
240
- this.#scanFile(url, queue)
271
+ if (this.memo === null) {
272
+ scanCounts.parsed++
273
+ this.#scanFile(url, queue)
274
+ } else {
275
+ this.#scanKept(url, queue)
276
+ }
241
277
  }
242
278
  return this
243
279
  }
244
280
 
281
+ // The parse of the file being scanned a scan before kept (#scanKept), and the parse of it made here.
282
+ #reparse
283
+ #parse
284
+
285
+ // With a `memo` (url -> what a scan read of it, kept across the rounds a lazy tree is read in,
286
+ // vfs-bundle/lazy.js): a file a scan before kept is taken as it read it, what it found and queued
287
+ // and the warnings it gave alike. One scanned here is kept where reading it touched no package not
288
+ // unpacked yet (`host.touches()` counts each such read, through a host that caches nothing such a
289
+ // read reads), so read what the full tree holds: the next scan reads only the files that did, and
290
+ // those it reaches. Of one that did, its parse is kept alone, which is the file's whatever the tree
291
+ // holds, or of that, what it imports (#scanFile): the next scan resolves its imports again, but
292
+ // parses it no more.
293
+ #scanKept(url, queue) {
294
+ const kept = this.memo.get(url)
295
+ scanCounts[kept?.queued !== undefined ? 'replayed' : kept?.parse === undefined ? 'parsed' : 'resolved'] += 1
296
+ if (kept?.queued !== undefined) {
297
+ this.files.set(url, kept.file)
298
+ for (const [key, specMap] of kept.imports) nestedMap(this.imports, key).set(url, specMap)
299
+ this.unresolved.push(...kept.unresolved)
300
+ this.parseErrors.push(...kept.parseErrors)
301
+ queue.push(...kept.queued)
302
+ for (const args of kept.warnings) console.warn(...args)
303
+ return
304
+ }
305
+ const touches = this.host.touches()
306
+ const at = { unresolved: this.unresolved.length, parseErrors: this.parseErrors.length, queue: queue.length }
307
+ // The scan of a file is synchronous: what console.warn is given meanwhile is the file's.
308
+ const warnings = []
309
+ const warn = console.warn
310
+ console.warn = (...args) => {
311
+ warnings.push(args)
312
+ warn.apply(console, args)
313
+ }
314
+ this.#reparse = kept?.parse
315
+ this.#parse = undefined
316
+ try {
317
+ this.#scanFile(url, queue)
318
+ } finally {
319
+ console.warn = warn
320
+ this.#reparse = undefined
321
+ }
322
+ if (this.host.touches() !== touches) {
323
+ if (this.#parse !== undefined) this.memo.set(url, { parse: this.#parse })
324
+ return
325
+ }
326
+ this.memo.set(url, {
327
+ file: this.files.get(url),
328
+ imports: [...this.imports].filter(([, byParent]) => byParent.has(url)).map(([key, byParent]) => [key, byParent.get(url)]),
329
+ unresolved: this.unresolved.slice(at.unresolved),
330
+ parseErrors: this.parseErrors.slice(at.parseErrors),
331
+ queued: queue.slice(at.queue),
332
+ warnings,
333
+ })
334
+ }
335
+
245
336
  // Node's resolver: must match the runtime resolver's condition set (omitting one resolves
246
337
  // `exports`-gated packages to a different file) AND its order: the recorded key must equal the
247
338
  // runtime hooks' string for exact lookups. Extras go where Node puts user conditions in each set.
@@ -294,18 +385,15 @@ export class Scan {
294
385
  return hit == null ? null : pathToFileURL(hit).toString()
295
386
  }
296
387
 
297
- // Strip Flow type syntax to plain JS via stasis's flow-remove-types (loaded lazily). Only invoked
298
- // as a parse fallback (see #scanFile), so plain-JS files never reach it. Returns the rewritten
299
- // source, or null when the transform itself fails on this file -- the caller then keeps oxc's
300
- // original parse error.
301
- #stripFlow(src, file) {
302
- const flowRemoveTypes = getFlowRemoveTypes()
388
+ // Strip Flow type syntax to plain JS (flow.js's stripFlowTypes): of a file marked `@flow`, or as a
389
+ // parse fallback (see parseFile), so plain-JS files never reach it. Returns the rewritten source, or
390
+ // null when the transform itself fails on this file -- the caller then keeps oxc's original parse,
391
+ // saying so where that failed (`failed`).
392
+ #stripFlow(src, file, failed) {
303
393
  try {
304
- // `all: true` ignores the @flow/@noflow pragma (RN sources mix both); the transform blanks
305
- // types with whitespace, so byte offsets and every import specifier are preserved.
306
- return flowRemoveTypes(src, { all: true }).toString()
394
+ return stripFlowTypes(src)
307
395
  } catch (cause) {
308
- console.warn(`[stasis] --flow: could not strip Flow types from ${file}; leaving it to oxc (${cause.message})`)
396
+ if (failed) console.warn(`[stasis] --flow: could not strip Flow types from ${file}; leaving it to oxc (${cause.message})`)
309
397
  return null
310
398
  }
311
399
  }
@@ -317,7 +405,7 @@ export class Scan {
317
405
  parseFile(file) {
318
406
  const ext = extname(file)
319
407
  // declared === null: typeless package; Node decides .js/.ts by syntax, resolved after parse.
320
- const declared = formatForFile(file, this.host)
408
+ const declared = formatForFile(file, this.host, this.#types)
321
409
  const src = this.host.readFile(file).toString('utf8')
322
410
 
323
411
  // Resolve the parser outside the try: a missing oxc-parser is an env error, not this
@@ -378,14 +466,18 @@ export class Scan {
378
466
  } catch { /* keep the script parse and its recorded errors */ }
379
467
  }
380
468
 
381
- // --flow: oxc parses JS/TS but not Flow, so a Flow-typed .js/.cjs/.mjs file lands here with
382
- // parse errors. Only now -- after a raw oxc parse actually failed -- strip Flow types and
383
- // re-parse, so plain-JS files never pay the transform cost. Only the parse input is rewritten;
469
+ // --flow: oxc parses JS/TS but not Flow, so a Flow-typed .js/.cjs/.mjs/.jsx file lands here
470
+ // with parse errors. Strip Flow types and re-parse as Metro's Babel reads the file: one marked
471
+ // `@flow` (hasFlowPragma) is Flow, stripped whether or not oxc parses it as it is (where
472
+ // `f<T>(x)` is a comparison, not Flow's call), as Babel parses it with hermes-parser; any other
473
+ // only now, after a raw oxc parse actually failed, as Babel's own Flow parser takes annotations
474
+ // in any file, so plain-JS files never pay the transform cost. Only the parse input is rewritten;
384
475
  // the bundle stores the pristine on-disk source (State/buildResolvedJsBundle re-read it), so
385
- // attestation still covers the real bytes. A clean re-parse replaces the errored one; otherwise
476
+ // attestation still covers the real bytes. A clean re-parse replaces the original one; otherwise
386
477
  // we keep the original result so a genuine (non-Flow) parse error still surfaces.
387
- if (errors.length > 0 && this.flow && FLOW_EXTS.has(ext)) {
388
- const flowSrc = this.#stripFlow(src, file)
478
+ let strippedSource = null
479
+ if (this.flow && FLOW_EXTS.has(ext) && (errors.length > 0 || hasFlowPragma(src))) {
480
+ const flowSrc = this.#stripFlow(src, file, errors.length > 0)
389
481
  if (flowSrc !== null) {
390
482
  try {
391
483
  const asFlow = parser.parseSync(file, flowSrc, parseOptions(baseSourceType))
@@ -393,12 +485,14 @@ export class Scan {
393
485
  parsed = asFlow
394
486
  format = declared ?? detectedFormat(parsed)
395
487
  errors = []
488
+ strippedSource = flowSrc
396
489
  }
397
490
  } catch { /* keep the original parse + its errors */ }
398
491
  }
399
492
  }
400
493
 
401
- return { format, parsed, errors }
494
+ // `source`, and `strippedSource` where `parsed` is of its Flow-stripped form, for listsTypesOnly.
495
+ return { format, parsed, errors, source: src, strippedSource }
402
496
  }
403
497
 
404
498
  #scanFile(url, queue) {
@@ -420,7 +514,8 @@ export class Scan {
420
514
  return
421
515
  }
422
516
 
423
- const result = this.parseFile(file)
517
+ const result = this.#reparse ?? this.parseFile(file)
518
+ this.#parse = result
424
519
  if (result.crash !== undefined) {
425
520
  this.#recordParseError(url, result.declared, result.crash, false)
426
521
  return
@@ -435,11 +530,20 @@ export class Scan {
435
530
  this.#recordParseError(url, format, parseError, true)
436
531
  return
437
532
  }
438
- // Script (CJS) files: oxc's recovered AST still yields the require()/import() edges — salvage them.
533
+ // Script (CJS) files: walk on through oxc's recovered AST, so a scan reports the rest of the
534
+ // graph's errors too; the parse error itself fails a bundle (analyzeScanner).
439
535
  this.parseErrors.push({ url, format, message: parseError, recovered: true })
440
536
  }
441
537
 
442
- const specs = collectSpecifiers(parsed.program, this.defines)
538
+ const typesErased = () => result.strippedSource !== null || !this.keepsTypeImports?.(file)
539
+ let { specs } = result
540
+ if (specs === undefined) {
541
+ const touches = this.memo === null ? 0 : this.host.touches()
542
+ specs = collectSpecifiers(parsed.program, this.defines, this.babel ? (node) => listsTypesOnly(node, result) && typesErased() : undefined)
543
+ // What a scan keeps of a file whose reading touched a package not unpacked yet (#scanKept): of
544
+ // its parse, what it imports, where finding that touched none, the parse itself let go.
545
+ if (this.memo !== null && this.host.touches() === touches) this.#parse = { format, errors, specs }
546
+ }
443
547
 
444
548
  // The edge KIND picks the resolution context, not the parent's format: createRequire()d
445
549
  // require() inside ESM resolves under REQUIRE conditions, literal import() inside CJS under
@@ -450,8 +554,7 @@ export class Scan {
450
554
  const specMaps = new Map() // condition key -> specifier -> child URL
451
555
  const addChild = (s, key, childURL, childPath) => {
452
556
  edges.push({ ...s, child: childURL })
453
- if (!specMaps.has(key)) specMaps.set(key, new Map())
454
- specMaps.get(key).set(s.spec, childURL)
557
+ nestedMap(specMaps, key).set(s.spec, childURL)
455
558
  if (RESOLVABLE_EXTS.has(extname(childPath)) || this.#isResource(childPath)) queue.push(childURL)
456
559
  }
457
560
  // Records the file --typescript would land the miss on too (typescriptURL), resolved as the miss was.
@@ -504,10 +607,7 @@ export class Scan {
504
607
  addChild(s, key, pathToFileURL(childPath).toString(), childPath)
505
608
  }
506
609
 
507
- for (const [key, specMap] of specMaps) {
508
- if (!this.imports.has(key)) this.imports.set(key, new Map())
509
- this.imports.get(key).set(url, specMap)
510
- }
610
+ for (const [key, specMap] of specMaps) nestedMap(this.imports, key).set(url, specMap)
511
611
  this.files.set(url, parseError ? { format, edges, parseError } : { format, edges })
512
612
  }
513
613