Skip to content

Do not create multiple sourceFile to single outputFile with project redirect as the output file is included by default#30721

Merged
sheetalkamat merged 3 commits intomasterfrom
amdOut
Apr 3, 2019
Merged

Do not create multiple sourceFile to single outputFile with project redirect as the output file is included by default#30721
sheetalkamat merged 3 commits intomasterfrom
amdOut

Conversation

@sheetalkamat
Copy link
Member

Fixes #30591

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

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) {
Copy link
Member

Choose a reason for hiding this comment

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

What is refFile in this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

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;
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

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

@sheetalkamat sheetalkamat merged commit 5869662 into master Apr 3, 2019
@sheetalkamat sheetalkamat deleted the amdOut branch April 3, 2019 17:39
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants