Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourceMap support #7

Open
cdagli opened this issue May 18, 2018 · 2 comments
Open

sourceMap support #7

cdagli opened this issue May 18, 2018 · 2 comments

Comments

@cdagli
Copy link

cdagli commented May 18, 2018

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?

@duffman
Copy link
Owner

duffman commented Jun 4, 2018

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

@lukas1994
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants