process: add lineLength to source-map-cache
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Problem
I realized when integrating source-map functionality with coverage that we're missing a piece of information necessary to support tools like ts-node:
- V8's coverage implementation is based on absolute byte offset, whereas Source Map V3 is based on line/column offset.
- when code is transpiled in memory (using hooks like
require.extensions
) we lack enough information to translate from bytes to lines/columns.
we end up with a bad reports that look like this, due to missing information:
Solution
If we track the line lengths of the source file that source maps were extracted from, this provides enough information to remap from byte offset to line/column offset.
I've introduced an additional value into the cache, lineLengths
, to facilitate this.
we can now generate the following report: