(source)
| 343 | } |
| 344 | |
| 345 | function parseImports(source) { |
| 346 | const map = new Map() |
| 347 | |
| 348 | for (const match of source.matchAll( |
| 349 | /^import\s+([A-Za-z_$][\w$]*)\s+from\s+'(\.\/commands\/[^']+)'/gm, |
| 350 | )) { |
| 351 | map.set(match[1], { specifier: match[2], gate: 'always', importKind: 'default' }) |
| 352 | } |
| 353 | |
| 354 | for (const match of source.matchAll( |
| 355 | /^import\s+\{([^}]+)\}\s+from\s+'(\.\/commands\/[^']+)'/gm, |
| 356 | )) { |
| 357 | const names = match[1] |
| 358 | .split(',') |
| 359 | .map(s => s.trim()) |
| 360 | .filter(Boolean) |
| 361 | .map(s => s.split(/\s+as\s+/)[0].trim()) |
| 362 | for (const name of names) { |
| 363 | map.set(name, { specifier: match[2], gate: 'always', importKind: 'named' }) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | for (const match of source.matchAll( |
| 368 | /^import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s+from\s+'(\.\/commands\/[^']+)'/gm, |
| 369 | )) { |
| 370 | map.set(match[1], { specifier: match[3], gate: 'always', importKind: 'default' }) |
| 371 | const names = match[2] |
| 372 | .split(',') |
| 373 | .map(s => s.trim()) |
| 374 | .filter(Boolean) |
| 375 | .map(s => s.split(/\s+as\s+/)[0].trim()) |
| 376 | for (const name of names) { |
| 377 | map.set(name, { specifier: match[3], gate: 'always', importKind: 'named' }) |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | return map |
| 382 | } |
| 383 | |
| 384 | function parseRelativeImports(source) { |
| 385 | const map = new Map() |
no test coverage detected