mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Never create redirect for sourceFiles that get emitted to single output file
Fixes #30591
This commit is contained in:
+17
-6
@@ -2266,8 +2266,13 @@ namespace ts {
|
||||
|
||||
let redirectedPath: Path | undefined;
|
||||
if (refFile) {
|
||||
const redirect = getProjectReferenceRedirect(fileName);
|
||||
if (redirect) {
|
||||
const redirectProject = getProjectReferenceRedirectProject(fileName);
|
||||
if (redirectProject) {
|
||||
if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) {
|
||||
// Shouldnt create many to 1 mapping file in --out scenario
|
||||
return undefined;
|
||||
}
|
||||
const redirect = getProjectReferenceOutputName(redirectProject, fileName);
|
||||
fileName = redirect;
|
||||
// Once we start redirecting to a file, we can potentially come back to it
|
||||
// via a back-reference from another file in the .d.ts folder. If that happens we'll
|
||||
@@ -2364,6 +2369,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getProjectReferenceRedirect(fileName: string): string | undefined {
|
||||
const referencedProject = getProjectReferenceRedirectProject(fileName);
|
||||
return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
|
||||
}
|
||||
|
||||
function getProjectReferenceRedirectProject(fileName: string) {
|
||||
// Ignore dts or any of the non ts files
|
||||
if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts) || !fileExtensionIsOneOf(fileName, supportedTSExtensions)) {
|
||||
return undefined;
|
||||
@@ -2371,10 +2381,11 @@ namespace ts {
|
||||
|
||||
// If this file is produced by a referenced project, we need to rewrite it to
|
||||
// look in the output folder of the referenced project rather than the input
|
||||
const referencedProject = getResolvedProjectReferenceToRedirect(fileName);
|
||||
if (!referencedProject) {
|
||||
return undefined;
|
||||
}
|
||||
return getResolvedProjectReferenceToRedirect(fileName);
|
||||
}
|
||||
|
||||
|
||||
function getProjectReferenceOutputName(referencedProject: ResolvedProjectReference, fileName: string) {
|
||||
const out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out;
|
||||
return out ?
|
||||
changeExtension(out, Extension.Dts) :
|
||||
|
||||
@@ -233,7 +233,14 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
],
|
||||
lastProjectOutputJs: outputFiles[project.app][ext.js],
|
||||
initialBuild: {
|
||||
modifyFs
|
||||
modifyFs,
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/lib/tsconfig.json", "src/app/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/lib/tsconfig.json", "src/module.js"],
|
||||
[Diagnostics.Building_project_0, sources[project.lib][source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/app/tsconfig.json", "src/app/module.js"],
|
||||
[Diagnostics.Building_project_0, sources[project.app][source.config]],
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
...libOutputFile,
|
||||
|
||||
Reference in New Issue
Block a user