Do not create multiple sourceFile to single outputFile with project redirect as the output file is included by default#30721
Conversation
…g using --build mode
…ed project with --out Test for #30591
andrewbranch
left a comment
There was a problem hiding this comment.
Left comments just to try to get a deeper understanding of this part of the compiler.
| @@ -2266,8 +2266,13 @@ namespace ts { | |||
|
|
|||
| let redirectedPath: Path | undefined; | |||
| if (refFile) { | |||
There was a problem hiding this comment.
What is refFile in this function?
There was a problem hiding this comment.
refFile is normally passed in if its trying to resolve imports/ or reference directives etc. thats the file in which import exists and hence the file is being added. The root files passed to program, when processed have refile as undefined.
| if (redirectProject) { | ||
| if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { | ||
| // Shouldnt create many to 1 mapping file in --out scenario | ||
| return undefined; |
There was a problem hiding this comment.
Trying to see if I understand:
Normally, if you call findSourceFile for say subproject/a.ts which is part of a referenced project, you'd return (after updating caches) the source file for subproject/a.d.ts. But if that referenced project has an outFile option, there won't be a subproject/a.d.ts, there will be a single concatenated definition file, let's say subproject/built.d.ts.
So you return early here because subproject/built.d.ts has already been processed, and doing it again causes problems. That makes sense to me, but why not return the SourceFile for subproject/built.d.ts?
There was a problem hiding this comment.
You do not want to return subproject/built.d.ts because normally file is 1:1 mapping and breaking that could lead to more severe breaks down the line somewhere. Technically there is no single file with subproject/a.ts but its mix of multiple files in subproject
Fixes #30591