merge-source-map icon indicating copy to clipboard operation
merge-source-map copied to clipboard

Missing original mappings

Open ddsol opened this issue 7 years ago • 0 comments

Say I have a file like this:

function myFunc(name1, name2) {
  console.log(name1, name2);
}

The first transform does full JS processing and makes sure to add each code point to the map. (| is start of a mapping)

function myFunc(a, b){console.log(a, b)}
|1:0            |  |  |2:2        |  | |3:0

The second transform is a simple replace that doesn't care that it's JavaScript and just replaces console.log with myLogger.

function myFunc(a, b){myLogger(a, b)}
|1:0                  |1:22   |1:33

The second map has only 3 mappings, but the one before it has 7. Also, the first map has information about the names used.

Using merge-source-map, the resulting map has only 3 mappings as well:

[{
  originalLine: 1,
  originalColumn: 0
  ...
},{
  originalLine: 2,
  originalColumn: 0
  ...
},{
  originalLine: 2,
  originalColumn: 2:13
  ...
}]

It should be possible to take all the original mappings, and add them to the map as well, and I think it might be a worthwhile addition.

ddsol avatar May 04 '18 01:05 ddsol