Skip to content

Incremental compilation in watch mode - #488

Merged
Perryvw merged 7 commits into
TypeScriptToLua:masterfrom
TheLartians:incremental-compilation
Mar 21, 2019
Merged

Incremental compilation in watch mode#488
Perryvw merged 7 commits into
TypeScriptToLua:masterfrom
TheLartians:incremental-compilation

Conversation

@TheLartians

@TheLartians TheLartians commented Mar 18, 2019

Copy link
Copy Markdown
Contributor

For large projects, this reduces compilation time dramatically in watch mode, as only files actually affected by recent changes are transpiled and emitted.

Update: Now also processes transpiler errors in watch mode.

@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.

I still want to test this out (will probably be tomorrow), but looks good!

Comment thread src/LuaTranspiler.ts
// Graciously handle transpilation errors
console.error("Encountered error parsing file: " + exception.message);
console.error(`${sourceFile.fileName} (${1 + pos.line},${pos.character})\n${exception.stack}`);
return 1;

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.

Might be nice to make these constants or an enum.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, though we should probably discuss error codes and general error handling of tstl in a separate PR.

@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.

Noticed a dodgy cast that shouldn't be too hard to handle properly, otherwise seems to work fine!

Comment thread src/Compiler.ts Outdated
while (true) {
const currentFile = program.getSemanticDiagnosticsOfNextAffectedFile();
if (!currentFile) { break; }
const fileStatus = transpiler.emitSourceFile(currentFile.affected as ts.SourceFile);

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.

currentFile has type ts.SourceFile | ts.Program, you should explicitly handle both cases using ts.isSourceFile(currentFile), and program.getSourceFiles() to transpile all sourceFiles in a program, in case one is returned.

@Perryvw
Perryvw merged commit c4a387a into TypeScriptToLua:master Mar 21, 2019
@TheLartians
TheLartians deleted the incremental-compilation branch March 21, 2019 22:36
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