Fixes the issue with emit where in same file is emitted multiple times #19306
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.
Before this change, all the affected files list was emitted and the file write callback was used to ensure we mark duplicate source files that would result in computing same output file (eg with --out) The issue with this was that writeFileCallback doesn't list
.d.ts
files as computing to same output files, yet emit with that file as sourceFile emits the same --out file. This means whenever there are multiple d.ts files are present in affected file list, it would result in same file being emitted multiple times.The problem got worse since builder always created emit output in memory, which means till all the changed files are written to disk those huge strings and other data exists in memory. That means you can run out of memory pretty soon. (Resulting in #19253)
This fix deals with this by:
Apart from this another TODO and to think in future to see if we can ensure that emitter always emits just declaration file without doing any additional diagnostics/no emit checks. This would help in figuring out dependencies correctly. Right now in all these cases (for some reason emit is skipped) shape is assumed to be Skipped.
Fixes #19253