Skip to content

Preserve source maps through ESM specifier rewriting #213

Description

@woksin

Problem

The build rewrites relative ESM specifiers after TypeScript/Rollup emit so Node can load published modules directly. A pre-rewrite source map would be dishonest, so maps for rewritten modules are currently removed. Consumers consequently lose source-level debugging across much of the package.

Direction

Make the specifier rewrite source-map-aware rather than retaining stale mappings:

  • apply rewrites through a mapping-preserving transform;
  • compose the transform map with Rollup/TypeScript maps;
  • retain correct sourceMappingURL references;
  • verify sources, names, line/column mappings, and declaration maps from the packed archive;
  • keep direct Node ESM import behavior unchanged.

Acceptance criteria

  • Every emitted JavaScript file that declares a source map references an existing packed map.
  • Representative stack frames and breakpoints map to the correct TypeScript source line/column.
  • Rewritten import/export/dynamic-import/import-type specifiers remain Node-loadable.
  • A planted stale/pre-rewrite map fails the package gate.
  • Archive budgets are reviewed after map restoration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions