You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CJS output's sourceMappingURL and map file field point at the ESM map name #71
When emitting the CJS build, the .cjs / .d.cts files keep the //# sourceMappingURL= comment from the original TS emit, so they reference *.js.map / *.d.ts.map instead of their own *.cjs.map / *.d.cts.map. The companion map files also carry the wrong "file" field (the .js / .d.ts name).
Because the ESM and CJS maps have different mappings, every CJS consumer — Node --enable-source-maps, source-map-support, ts-node/tsx, Jest/Mocha, IDE "go to definition" — resolves to the wrong map and misreports positions.
In compile.js, the host.writeFile hook renames the output path (.js→.cjs, etc.) but writes data unmodified, so the in-file sourceMappingURL comment and the map "file" field still reference the original names.
Fix
When renaming, also rewrite the contents — the sourceMappingURL comment in .cjs/.d.cts, and the "file" field in .cjs.map/.d.cts.map.
Activity
pullfrog commentedon Jun 24, 2026
michi: start colinhacks#71
T1: rewrite sourceMappingURL comment and map file field on rename (co…
T2: add regression test for CJS source map references (colinhacks#71)
T3: regenerate fixtures with corrected CJS source map references (col…
T4: anchor sourceMappingURL rewrite to end-of-file (colinhacks#71)