duffman/tspath

sourceMap support

cdagli opened this issue · 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?

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

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