ReviewOS

also looking at this

stacks/bun-plugin-auto-imports

fix: resolve generated export collisions consistently

#1186
Merged chris wants to merge codex/runtime-export-collisions into main
3 files +107 -5
9 days ago

Summary

A repeated exported name made the generated function index invalid, disabling every auto-import when it was loaded. Repeated overload signatures, re-exports and overlapping scan directories could all trigger it.

caller directory order -> sorted files -> first registered name
  -> runtime index and returned metadata
  -> globals injection and standalone declarations

Use the existing auto-import context precedence consistently across these generators. The runtime index records different-file collisions in comments naming the selected and skipped files. Winning default exports also receive standalone value declarations.

Evidence

  • Before: the real Drone barrel failed with 19 duplicate exports; a minimal generated artifact reproduced the parse failure. The first review also found a missing winning-default declaration, reproduced with a separate failing assertion.
  • After: the generated artifact builds/imports and its globals resolve the correct overload/default/fallback functions. TypeScript 7 compiles a separate generated declaration consumer with the owned interface and overload types.
  • Full native suite: 130 pass, 0 fail, 247 assertions. Non-incremental types, pickier and the native build pass. Candidate-source generation/import against Drone's actual function tree selects 1,791 exports and loads 1,050 runtime exports without modifying installed packages.

Merge Danger

First registration already governs transformed auto-imports. This applies the same deterministic precedence to generated output; ambiguous helpers can still be imported explicitly from their own modules. Existing module-specifier callbacks are retained.

Closes #1185

3 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.