Skip to content

Added initial support for sourcemaps#452

Merged
Perryvw merged 14 commits intomasterfrom
source-maps
Apr 2, 2019
Merged

Added initial support for sourcemaps#452
Perryvw merged 14 commits intomasterfrom
source-maps

Conversation

@lolleko
Copy link
Copy Markdown
Member

@lolleko lolleko commented Feb 25, 2019

Closes #237

Sourcemap implementation using Mozillas source map lib (https://github.com/mozilla/source-map). The high-level SourceNode API is used in this draft.

This adds a second runtime dependency, but I think implementing our own version really isn't worth it.
Particularly the part where we would have to write our own Base64 VLQ encoder.

TODOs

  • Discuss the implementation (dependencies...)
  • Address TODOs in code
  • Cleanup API (LuaPrinter & LuaTranspiler)
  • Figure out a way to test this
  • Add some tests
  • Figure out if we can support inlineSourceMaps?

@lolleko lolleko added this to the 1.0.0 milestone Feb 25, 2019
@lolleko lolleko requested review from Perryvw and tomblind February 25, 2019 22:18
@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Feb 26, 2019

I think the "Clean up APIs" point probably deserves its own PR, I think for now it might be nicest if we just always generate and return the source map from the printer (if that's possible?) and then let whatever is calling it (in the current case the LuaTransformer) choose to emit it or not.

We can then look at cleaning up the API together with the rest of the project.

@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Feb 27, 2019

It might also be a nice idea to define type SourceChunk = string | SourceNode and use that instead of string | SourceNode every time.

Perryvw and others added 7 commits March 6, 2019 11:58
* Made some adjustments to source maps

* Fixed tests

* Removed tsOriginal field from AST nodes
# Conflicts:
#	src/LuaTransformer.ts
#	src/lualib/StringReplace.ts
# Conflicts:
#	package-lock.json
#	src/LuaPrinter.ts
#	test/compiler/watchmode.spec.ts
* Added override for traceback

* Improved sourcemap override

* Removed obsolete argument

* put traceback override at start of the file after headers

* changed 2 underscore identifiers

* Added test for sourceMapTraceback

* don't enforce prettier linting

* use debug.getinfo for file names

* Trying to diagnose test issue

* No longer check filename in sourcemap test

* Another stab at fixing tests
@Perryvw Perryvw marked this pull request as ready for review March 31, 2019 19:10
@Perryvw Perryvw merged commit ed5bcd7 into master Apr 2, 2019
@Perryvw Perryvw deleted the source-maps branch April 2, 2019 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants