tspath icon indicating copy to clipboard operation
tspath copied to clipboard

sourceMap support

Open cdagli opened this issue 7 years ago • 2 comments

Hello,

Seems like tspath makes slight modifications in the generated code and that breaks the compability with the previously generated source maps.

Is there a way to only modify the require and imports and not to touch the rest. Would that work?

cdagli avatar May 18 '18 11:05 cdagli

Hi there, sorry for the late response! Technically it´s possible of course, however, that would be a major task, let me describe how it works when TSPath is generating new paths in your JavaScript files.

The raw JavaScript file is read from disk and fed into a Script parser which generates an Abstract Syntax Tree, that makes it very easy to navigate the source and find the imports that will be updated, when the imports have been updated the AST is fed to an ECMAScript Generator which generates a new JavaScript file, the process is very similar to WebPack and similar tools.

So, the entire file is "re-generated", the alternative to this would be some kind of string matching with RegExp to find the imports and update that specific line, since that would be a "hacky" way to do it, it´s not a direction I wanna take TSPath, however, let´s figure out how to fix this :)

Could you please provide me with some examples of "broken" source maps, exactly what is it that breaks?

the alternative to this would be some kind of string
is using a Script parser

using a ECMAScript code generator

duffman avatar Jun 04 '18 20:06 duffman

for me the translated code is kindof minified (all newlines are removed) which makes debugging hard did you find a solution @cdagli ?

lukas1994 avatar Nov 06 '19 09:11 lukas1994