Skip to content

Fixes bundle mode with enabled sourceMapTraceback#1110

Merged
Perryvw merged 7 commits into
TypeScriptToLua:masterfrom
Toliak:master
Sep 8, 2021
Merged

Fixes bundle mode with enabled sourceMapTraceback#1110
Perryvw merged 7 commits into
TypeScriptToLua:masterfrom
Toliak:master

Conversation

@Toliak

@Toliak Toliak commented Aug 28, 2021

Copy link
Copy Markdown
Contributor

See #1109 for details

Toliak and others added 2 commits August 28, 2021 14:19
- Join code chunk, due to its correctness and existness

@Perryvw Perryvw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would expect to see at least one test added to verify this actually fixes the problem.

Comment thread src/transpilation/bundle.ts
@Toliak

Toliak commented Aug 31, 2021

Copy link
Copy Markdown
Contributor Author

Main changes

  • __TS__originalTraceback is able to save two types of source maps.
    First type is default: Record<number, number> lua line is being mapped into TS line.
    The second type is: Record<number, { line : number, file: string }: lua line is mapped into TS line and source file name.
    The first type has been already applied to single file compilation. And I have applied the second type for bundle compilation. The reason -- in bundle mode runtime Lua should know about target file (because bundle filename != source file)
  • I have added printStackTraceBundleOverride function into bundle.ts. This function generates the second type of source map.
  • LuaPrinter's method printFile will not generate {#SourceMapTraceback} in bundle mode anymore. Because Source Map Traceback should be constructed for the whole bundled file
  • getBundleResult function inserts the traceback before the entryPoint

Misc changes

  • Moved {#SourceMapTraceback} magic-macro-string into a static field sourceMapTracebackPlaceholder of LuaPrinter class
  • Haven't touched sourceMapNode in moduleSourceNode (because it is not necessary)
  • Moved helpful lineAndColumnOf from test\unit\printer\sourcemaps.spec.ts into test\unit\printer\utils.ts

Tests coverage

  • Moved default bundle test into bundle/bundle-two-files
  • Tested source map generation with bundle/bundle-source-maps test
  • Both tests are located in test\transpile\bundle.spec.ts and wrapped into describe

@Toliak Toliak requested a review from Perryvw August 31, 2021 16:45
@Perryvw Perryvw merged commit 09c8f0f into TypeScriptToLua:master Sep 8, 2021
sanikoyes pushed a commit to sanikoyes/TypeScriptToLua that referenced this pull request Sep 24, 2021
* TypeScriptToLua#1109 In Progress

- Join code chunk, due to its correctness and existness

* Removed unused `sourceMapNode`

* Provided SourceMapTraceBack for bundled files (TypeScriptToLua#1109)

* Moved helpful function `lineAndColumnOf` into utils.ts file

* Covered bundling with source map traceback (TypeScriptToLua#1109)

* Removed unnecessary comments
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

Successfully merging this pull request may close these issues.

2 participants