Refactor transpilation pipeline#885
Merged
Perryvw merged 8 commits intoTypeScriptToLua:masterfrom Jul 13, 2020
Merged
Conversation
Perryvw
reviewed
Jul 5, 2020
| const file = util | ||
| .testFunction(code) | ||
| .setOptions({ inlineSourceMap: true }) | ||
| .disableSemanticCheck() // TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. |
Member
There was a problem hiding this comment.
Couldn't we just add sourceMap: false to the setOptions call?
Contributor
Author
There was a problem hiding this comment.
file.luaSourceMap (which is used for comparison with inlined source map content) is parsed from generated .map file. Previously it did work because TranspiledFile.sourceMap property existed even without sourceMap: true option
Member
There was a problem hiding this comment.
Could you add this reasoning to the comment here? (ie 'We need the source map to compare to for the test')
|
|
||
| const configFileName = path.resolve(__dirname, "src/lualib/tsconfig.json"); | ||
| const { emitResult, diagnostics } = tstl.transpileProject(configFileName); | ||
| emitResult.forEach(({ name, text }) => ts.sys.writeFile(name, text)); |
Member
There was a problem hiding this comment.
This is no longer emitted? Doesn't this break lualib inlining?
Contributor
Author
There was a problem hiding this comment.
transpileProject now emits files itself (unless writeFile callback parameter is provided)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
That's a preparation for #432 and #653. The outline of changes done:
Transpilerclass, which should be used instead oftranspile. The reason for making it a class is that it also would take care of the emitted files state. That would be useful since with New module resolution and Compilation structure #432 we don't want to emit all referenced .lua files every single cycle.transpile,Transpilertakes care of both transpiling and emitting. This is needed, because some emitted files may have no known sources (we actually already have that with bundle files), so a concept ofTranspiledFiledoesn't work here.TranspiledFileconcept there, we'll either have to return a list of generic{ fileName, text }objects or takewriteFilecallback. I have chosen the second approach to be symmetric withprogram.emit.Changelog:
transpileFilesandtranspileProject) now write transpiled files by default. This behavior can be changed by providing awriteFilecallback, similarly to TypeScript'sprogram.emit.transpileandemitTranspiledFilesfunctions have been replaced with theTranspilerclass. See documentation for usage examples.declarationDiroption not being respected.