sokra / source-map-visualization

Just a simple hacky visualisation of SourceMaps
http://sokra.github.io/source-map-visualization
628 stars 77 forks source link

Extend of mappings on column level in the original source #29

Open mutech opened 6 years ago

mutech commented 6 years ago

First: Thanks guys, this tool is extremely helpful!

In this example here (generated and two original sources):

generated:

[B][2]

source1:

A[BC]

source2:

1[23]

The mapping of "B" and "2" both exceed to the end of the respective original source files (in the visualisation tool).

Is this display correct? If not, then this is the issue here.

If this is correct, how can I create a mapping that limits the extend? What I tried is to add a mapping from the first character following (f.e.) B to the end of the source line: B[]2 -> ABC[] and B2[] -> 123[], but that did't work.

It's probably clearer with a real example

    emit("one\n\ttwo\nthree\n");

//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbmZpZy54dHAiLCJvcmlnaW5hbC54dHAiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ3FDLElBQ0csTUNGeEMsR0RLbUUsRUFDUSxFQ0wxRSxHRElrRSxFQ0huRSxLREdtRSxFQUY3QiIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VzQ29udGVudCI6WyI8JUBbZGF0YTpkaWN0aW9uYXJ5JT5cbjwlQFtbZGF0YTprZXlWYWx1ZVBhaXIga2V5PVwiaW5kZW50XCIlPiAgICA8JUBdXSU+XG48JUBbW2RhdGE6a2V5VmFsdWVQYWlyIGtleT1cInN0YXJ0RW1pdFwiJT5lbWl0KFwiPCVAXV0lPlxuPCVAW1tkYXRhOmtleVZhbHVlUGFpciBrZXk9XCJlbmRFbWl0XCIlPlwiKTtcbjwlQF1dJT5cbjwlQFtbZGF0YTprZXlWYWx1ZVBhaXIga2V5PVwiY29kZWdlbi5qYXZhc2NyaXB0LmxpbmVFbmRpbmdzWydcXG4nXVwiJT5cXG48JUBdXSU+XG48JUBbW2RhdGE6a2V5VmFsdWVQYWlyIGtleT1cImNvZGVnZW4uamF2YXNjcmlwdC5lc2NhcGVkU3RyaW5nTWFwcGluZ1snXHQnXVwiJT5cXHQ8JUBdXSU+XG48JUBdJT5cbiIsIm9uZVxuXHR0d29cbnRocmVlXG4iXX0=

The rationale of all this is that I want to be able to edit the generated source and update the original based on source maps. And that while keeping the source maps compliant to browser requirements.

mutech commented 6 years ago

Well actually what I tried didn't work because I made a mistake.

This mapping works (visually), except for the fact that the trailing part in the original source is still mapped (again visually).