Skip to content

Commit 00a9459

Browse files
Orta TheroxZzzen
authored andcommitted
Reverts microsoft#39277 removing bundledPackageName (microsoft#41499)
* Reverts microsoft#39277 * Bring back modeyule resolution for the test runner
1 parent 83bd953 commit 00a9459

File tree

102 files changed

+235
-422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+235
-422
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4395,7 +4395,6 @@ namespace ts {
43954395
getProjectReferenceRedirect: fileName => host.getProjectReferenceRedirect(fileName),
43964396
isSourceOfProjectReferenceRedirect: fileName => host.isSourceOfProjectReferenceRedirect(fileName),
43974397
fileExists: fileName => host.fileExists(fileName),
4398-
getCompilerOptions: () => host.getCompilerOptions()
43994398
} : undefined },
44004399
encounteredError: false,
44014400
visitedTypes: undefined,
@@ -6106,8 +6105,7 @@ namespace ts {
61066105
const resolverHost = {
61076106
getCanonicalFileName,
61086107
getCurrentDirectory: () => context.tracker.moduleResolverHost!.getCurrentDirectory(),
6109-
getCommonSourceDirectory: () => context.tracker.moduleResolverHost!.getCommonSourceDirectory(),
6110-
getCompilerOptions: () => context.tracker.moduleResolverHost!.getCompilerOptions()
6108+
getCommonSourceDirectory: () => context.tracker.moduleResolverHost!.getCommonSourceDirectory()
61116109
};
61126110
const newName = getResolvedExternalModuleName(resolverHost, targetFile);
61136111
return factory.createStringLiteral(newName);

src/compiler/commandLineParser.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,13 +1070,6 @@ namespace ts {
10701070
category: Diagnostics.Advanced_Options,
10711071
description: Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
10721072
},
1073-
{
1074-
name: "bundledPackageName",
1075-
type: "string",
1076-
affectsEmit: true,
1077-
category: Diagnostics.Advanced_Options,
1078-
description: Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations,
1079-
},
10801073

10811074
{
10821075
name: "keyofStringsOnly",

src/compiler/moduleSpecifiers.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ namespace ts.moduleSpecifiers {
163163
}
164164

165165
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, { ending, relativePreference }: Preferences): string {
166-
const { baseUrl, paths, rootDirs, bundledPackageName } = compilerOptions;
166+
const { baseUrl, paths, rootDirs } = compilerOptions;
167167
const { sourceDirectory, getCanonicalFileName } = info;
168168

169169
const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
@@ -178,9 +178,8 @@ namespace ts.moduleSpecifiers {
178178
return relativePath;
179179
}
180180

181-
const bundledPkgReference = bundledPackageName ? combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl;
182-
const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions);
183-
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths);
181+
const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
182+
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
184183
const nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
185184
if (!nonRelative) {
186185
return relativePath;

src/compiler/program.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,11 +3180,6 @@ namespace ts {
31803180
}
31813181
}
31823182

3183-
// Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk
3184-
if (outputFile && getEmitDeclarations(options) && getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeJs && !options.bundledPackageName) {
3185-
createDiagnosticForOptionName(Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile");
3186-
}
3187-
31883183
if (options.resolveJsonModule) {
31893184
if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) {
31903185
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");

src/compiler/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5826,7 +5826,6 @@ namespace ts {
58265826
/** An error if set - this should only go through the -b pipeline and not actually be observed */
58275827
/*@internal*/
58285828
build?: boolean;
5829-
bundledPackageName?: string;
58305829
charset?: string;
58315830
checkJs?: boolean;
58325831
/* @internal */ configFilePath?: string;
@@ -7954,7 +7953,6 @@ namespace ts {
79547953
readonly redirectTargetsMap: RedirectTargetsMap;
79557954
getProjectReferenceRedirect(fileName: string): string | undefined;
79567955
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
7957-
getCompilerOptions(): CompilerOptions;
79587956
}
79597957

79607958
// Note: this used to be deprecated in our public API, but is still used internally

src/compiler/utilities.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,7 +4112,6 @@ namespace ts {
41124112
getCanonicalFileName(p: string): string;
41134113
getCommonSourceDirectory(): string;
41144114
getCurrentDirectory(): string;
4115-
getCompilerOptions(): CompilerOptions;
41164115
}
41174116

41184117
export function getResolvedExternalModuleName(host: ResolveModuleNameResolutionHost, file: SourceFile, referenceFile?: SourceFile): string {
@@ -4136,16 +4135,7 @@ namespace ts {
41364135
const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
41374136
const relativePath = getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
41384137
const extensionless = removeFileExtension(relativePath);
4139-
if (referencePath) {
4140-
return ensurePathIsNonModuleName(extensionless);
4141-
}
4142-
const options = host.getCompilerOptions();
4143-
const rootPkgName = options.bundledPackageName || "";
4144-
const newPath = combinePaths(rootPkgName, extensionless);
4145-
if (rootPkgName && getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeJs && endsWith(newPath, "/index")) {
4146-
return newPath.slice(0, newPath.length - "/index".length);
4147-
}
4148-
return newPath;
4138+
return referencePath ? ensurePathIsNonModuleName(extensionless) : extensionless;
41494139
}
41504140

41514141
export function getOwnEmitOutputFilePath(fileName: string, host: EmitHost, extension: string) {

src/services/utilities.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,6 @@ namespace ts {
18341834
redirectTargetsMap: program.redirectTargetsMap,
18351835
getProjectReferenceRedirect: fileName => program.getProjectReferenceRedirect(fileName),
18361836
isSourceOfProjectReferenceRedirect: fileName => program.isSourceOfProjectReferenceRedirect(fileName),
1837-
getCompilerOptions: () => program.getCompilerOptions(),
18381837
getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
18391838
};
18401839
}

src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ namespace ts {
105105
"compilerOptions": {
106106
"composite": true,
107107
"outFile": "common.js",
108-
"bundledPackageName": "common"
108+
109109
},
110110
"include": ["nominal.js"]
111111
}`,
@@ -121,7 +121,7 @@ namespace ts {
121121
"compilerOptions": {
122122
"composite": true,
123123
"outFile": "sub-project.js",
124-
"bundledPackageName": "sub"
124+
125125
},
126126
"references": [
127127
{ "path": "../common", "prepend": true }
@@ -146,7 +146,7 @@ namespace ts {
146146
"compilerOptions": {
147147
"composite": true,
148148
"outFile": "sub-project-2.js",
149-
"bundledPackageName": "sub-2"
149+
150150
},
151151
"references": [
152152
{ "path": "../sub-project", "prepend": true }

src/testRunner/unittests/tsbuild/outFile.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,7 @@ ${internal} enum internalEnum { a, b, c }`);
666666
declarationMap: true,
667667
skipDefaultLibCheck: true,
668668
sourceMap: true,
669-
outFile: "./bin/first-output.js",
670-
bundledPackageName: "first"
669+
outFile: "./bin/first-output.js"
671670
},
672671
files: [sources[Project.first][Source.ts][Part.one]]
673672
}));
@@ -679,7 +678,6 @@ ${internal} enum internalEnum { a, b, c }`);
679678
stripInternal: true,
680679
sourceMap: true,
681680
outFile: "./thirdjs/output/third-output.js",
682-
bundledPackageName: "third"
683681
},
684682
references: [{ path: "../first", prepend: true }],
685683
files: [sources[Project.third][Source.ts][Part.one]]

src/testRunner/unittests/tsbuild/watchMode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ export class someClass2 { }`),
326326
const coreTsConfig: File = {
327327
path: core[0].path,
328328
content: JSON.stringify({
329-
compilerOptions: { composite: true, declaration: true, outFile: "index.js", bundledPackageName: "core" }
329+
compilerOptions: { composite: true, declaration: true, outFile: "index.js" }
330330
})
331331
};
332332
const logicTsConfig: File = {
333333
path: logic[0].path,
334334
content: JSON.stringify({
335-
compilerOptions: { composite: true, declaration: true, outFile: "index.js", bundledPackageName: "logic" },
335+
compilerOptions: { composite: true, declaration: true, outFile: "index.js" },
336336
references: [{ path: "../core", prepend: true }]
337337
})
338338
};

0 commit comments

Comments
 (0)