7 Commits

  • Merge pull request #359 from tirth8205/fix/import-resolver-nodenext-rewrite
    fix(extract-import-map): apply NodeNext .js→.ts rewrite (#294)
  • Merge pull request #346 from tirth8205/perf/understand-pipeline
    perf(understand): parallelise file I/O in compute-batches + extract-import-map (#76)
  • fix(extract-import-map): preserve deterministic stderr order across concurrent loaders
    Addresses the regression flagged by ZebangCheng on #346: under the
    parallelised `buildResolutionContext`, `loadTsConfigs` /
    `loadGoModules` / `loadPhpAutoloads` ran concurrently but each wrote
    warnings to stderr inline as it iterated read results, so a fixture
    with both a malformed `tsconfig.json` and a malformed `composer.json`
    could emit `composer, tsconfig` instead of the pre-PR `tsconfig,
    composer` depending on I/O timing.
    
    Each loader now buffers its warnings into a returned array and the
    caller drains them in canonical order (tsconfig → go → php) after
    `Promise.all`, restoring byte-identical stderr output. Added a
    regression test that fixtures both malformed configs and asserts the
    tsconfig warning precedes the composer warning in stderr.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
  • Merge branch 'main' into fix/import-resolver-nodenext-rewrite
    Resolve conflict in tests/skill/understand/test_extract_import_map.test.mjs
    by keeping both new test groups — they cover independent fixes that should
    coexist:
      - upstream #214: tsconfig path-alias targets with leading "./"
      - this PR  #294: NodeNext .js → .ts rewrite for ESM TypeScript imports
    
    The extract-import-map.mjs script auto-merged cleanly; both fixes are
    already present in the merged source.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
  • fix(extract-import-map): apply NodeNext .js→.ts rewrite (#294)
    Fixes the silent near-edgeless-graph regression on any modern ESM
    TypeScript project. Reported in #294 with full repro + root-cause
    analysis.
    
    ### Why this matters
    
    Under `moduleResolution: NodeNext` (or `Node16` / `Bundler` with
    explicit extensions — the default for new TS-ESM projects since 2023),
    TypeScript does NOT rewrite import specifiers during compilation:
    
      // src/index.ts — real, idiomatic NodeNext source
      import { x } from './config.js';   // on disk: config.ts
    
    Before this fix, `probeWithExtensions` only tried APPENDING extensions
    to the import specifier:
    
      './config.js' → not in fileSet
      './config.js.ts', './config.js.tsx', './config.js.js', ... → all miss
      → returns null → edge dropped at merge as dangling
    
    Net result on the reporter's repro: a knowledge graph with hundreds of
    file nodes and almost no `imports` edges between them — silently
    removing exactly the dependency structure the graph is meant to show.
    
    ### Fix
    
    New `NODENEXT_REWRITES` table maps each compiled-output extension to
    the TypeScript source extensions that could have produced it:
    
      .js   → [.ts, .tsx, .js, .jsx]
      .jsx  → [.tsx, .jsx]
      .mjs  → [.mts, .mjs, .ts]
      .cjs  → [.cts, .cjs, .ts]
    
    `probeWithExtensions` now applies the rewrite when the import already
    ends with one of these extensions and no such file exists on disk. The
    rewrite runs BEFORE the legacy append-extensions loop — otherwise
    `./foo.js` would generate the nonsense candidate `foo.js.ts` and the
    append loop would never reach the actual `foo.ts`.
    
    ### Disambiguation
    
    If both `config.ts` and `config.js` exist on disk (rare, but possible
    during a partial migration), `import './config.js'` still resolves to
    the .js — that's an exact-disk match and what NodeNext compilation
    actually does. The rewrite only kicks in when the .js doesn't exist.
    
    ### Tests
    
    6 new tests in `test_extract_import_map.test.mjs`:
    - The main #294 case (`.js → .ts`)
    - `.jsx → .tsx` and `.mjs → .mts` rewrites
    - Disambiguation when both `.ts` and `.js` exist on disk
    - Pure-JS projects still work (real `.js → .js` imports)
    - Historical no-extension probes unaffected
    - Missing files still return null (rewrite can't invent targets)
    
    Total: 202 tests passing (was 196).
    
    Closes #294
  • Merge pull request #204 from Lum1104/feat/semantic-batching-and-output-chunking
    fix(#159): semantic batching + bundled importMap + Phase 1 speedup