Skip to content

process: initial SourceMap support via NODE_V8_COVERAGE

Rodrigo Muino Tomonari requested to merge github/fork/bcoe/source-map into master

Adds support for caching source maps when they're observed in footer of script file, and outputting them to the coverage directory if NODE_V8_COVERAGE is enabled.

This is seen as an initial step towards more thorough support for source maps inside Node.js itself.

Goal of this PR

Get it to the point where upstream tooling can detect source maps, even in the cases where they've been inserted by custom loaders or require.extensions.

Future Work (outside the scope of this PR)

  1. expose source maps through an API, so that tooling can interact with them programmatically, e.g., fetching a SourceMap, or applying a SourceMap to a line/column position.
  2. apply source maps to Node.js' annotations of error objects.
  3. work with V8 folks towards adding source map support into V8 itself; with some of the functionality in Node.js (e.g., caching the source maps) and some of the functionality in V8 (e.g., having correct stack traces).
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

CC: @schuay, @snehasi (I've left some tests blank and I think this would be a great starting point for some of the work we're doing in the mentorship program).

Remaining Work
  • discuss future API direction (pull together design doc?).
    • I don't think I'll be able to write a design document up for a few weeks, but I think this initial implementation is a step in the right direction.
  • make sure collecting source-maps isn't a major performance regression for coverage.
  • add support for base64 encoded data URIs.

Merge request reports

Loading