Skip to content

Commit

Permalink
Remove bundledPackageName from release 4.1 (#41536)
Browse files Browse the repository at this point in the history
* Merge release 4-1

* Remove unused tests
  • Loading branch information
Orta Therox authored Nov 15, 2020
1 parent 612c19d commit c12cc53
Show file tree
Hide file tree
Showing 103 changed files with 54 additions and 674 deletions.
4 changes: 1 addition & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4360,7 +4360,6 @@ namespace ts {
getProjectReferenceRedirect: fileName => host.getProjectReferenceRedirect(fileName),
isSourceOfProjectReferenceRedirect: fileName => host.isSourceOfProjectReferenceRedirect(fileName),
fileExists: fileName => host.fileExists(fileName),
getCompilerOptions: () => host.getCompilerOptions()
} : undefined },
encounteredError: false,
visitedTypes: undefined,
Expand Down Expand Up @@ -6015,8 +6014,7 @@ namespace ts {
const resolverHost = {
getCanonicalFileName,
getCurrentDirectory: () => context.tracker.moduleResolverHost!.getCurrentDirectory(),
getCommonSourceDirectory: () => context.tracker.moduleResolverHost!.getCommonSourceDirectory(),
getCompilerOptions: () => context.tracker.moduleResolverHost!.getCompilerOptions()
getCommonSourceDirectory: () => context.tracker.moduleResolverHost!.getCommonSourceDirectory()
};
const newName = getResolvedExternalModuleName(resolverHost, targetFile);
return factory.createStringLiteral(newName);
Expand Down
7 changes: 0 additions & 7 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1031,13 +1031,6 @@ namespace ts {
category: Diagnostics.Advanced_Options,
description: Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
},
{
name: "bundledPackageName",
type: "string",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations,
},

{
name: "keyofStringsOnly",
Expand Down
8 changes: 0 additions & 8 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,6 @@
"category": "Error",
"code": 1389
},
"Provides a root package name when using outFile with declarations.": {
"category": "Message",
"code": 1390
},
"The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.": {
"category": "Error",
"code": 1391
},
"The types of '{0}' are incompatible between these types.": {
"category": "Error",
"code": 2200
Expand Down
7 changes: 3 additions & 4 deletions src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace ts.moduleSpecifiers {
}

function getLocalModuleSpecifier(moduleFileName: string, { getCanonicalFileName, sourceDirectory }: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, { ending, relativePreference }: Preferences): string {
const { baseUrl, paths, rootDirs, bundledPackageName } = compilerOptions;
const { baseUrl, paths, rootDirs } = compilerOptions;

const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
Expand All @@ -171,9 +171,8 @@ namespace ts.moduleSpecifiers {
return relativePath;
}

const bundledPkgReference = bundledPackageName ? combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl;
const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions);
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths);
const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
const nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
if (!nonRelative) {
return relativePath;
Expand Down
5 changes: 0 additions & 5 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3224,11 +3224,6 @@ namespace ts {
}
}

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

if (options.resolveJsonModule) {
if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) {
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
Expand Down
2 changes: 0 additions & 2 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5729,7 +5729,6 @@ namespace ts {
/** An error if set - this should only go through the -b pipeline and not actually be observed */
/*@internal*/
build?: boolean;
bundledPackageName?: string;
charset?: string;
checkJs?: boolean;
/* @internal */ configFilePath?: string;
Expand Down Expand Up @@ -7857,7 +7856,6 @@ namespace ts {
readonly redirectTargetsMap: RedirectTargetsMap;
getProjectReferenceRedirect(fileName: string): string | undefined;
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
getCompilerOptions(): CompilerOptions;
}

// Note: this used to be deprecated in our public API, but is still used internally
Expand Down
12 changes: 1 addition & 11 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4069,7 +4069,6 @@ namespace ts {
getCanonicalFileName(p: string): string;
getCommonSourceDirectory(): string;
getCurrentDirectory(): string;
getCompilerOptions(): CompilerOptions;
}

export function getResolvedExternalModuleName(host: ResolveModuleNameResolutionHost, file: SourceFile, referenceFile?: SourceFile): string {
Expand All @@ -4093,16 +4092,7 @@ namespace ts {
const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
const relativePath = getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
const extensionless = removeFileExtension(relativePath);
if (referencePath) {
return ensurePathIsNonModuleName(extensionless);
}
const options = host.getCompilerOptions();
const rootPkgName = options.bundledPackageName || "";
const newPath = combinePaths(rootPkgName, extensionless);
if (rootPkgName && getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeJs && endsWith(newPath, "/index")) {
return newPath.slice(0, newPath.length - "/index".length);
}
return newPath;
return referencePath ? ensurePathIsNonModuleName(extensionless) : extensionless;
}

export function getOwnEmitOutputFilePath(fileName: string, host: EmitHost, extension: string) {
Expand Down
3 changes: 1 addition & 2 deletions src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1786,8 +1786,7 @@ namespace ts {
getSourceFiles: () => program.getSourceFiles(),
redirectTargetsMap: program.redirectTargetsMap,
getProjectReferenceRedirect: fileName => program.getProjectReferenceRedirect(fileName),
isSourceOfProjectReferenceRedirect: fileName => program.isSourceOfProjectReferenceRedirect(fileName),
getCompilerOptions: () => program.getCompilerOptions()
isSourceOfProjectReferenceRedirect: fileName => program.isSourceOfProjectReferenceRedirect(fileName)
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace ts {
"compilerOptions": {
"composite": true,
"outFile": "common.js",
"bundledPackageName": "common"
},
"include": ["nominal.js"]
}`,
Expand All @@ -121,7 +121,7 @@ namespace ts {
"compilerOptions": {
"composite": true,
"outFile": "sub-project.js",
"bundledPackageName": "sub"
},
"references": [
{ "path": "../common", "prepend": true }
Expand All @@ -146,7 +146,7 @@ namespace ts {
"compilerOptions": {
"composite": true,
"outFile": "sub-project-2.js",
"bundledPackageName": "sub-2"
},
"references": [
{ "path": "../sub-project", "prepend": true }
Expand Down
4 changes: 1 addition & 3 deletions src/testRunner/unittests/tsbuild/outFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,7 @@ ${internal} enum internalEnum { a, b, c }`);
declarationMap: true,
skipDefaultLibCheck: true,
sourceMap: true,
outFile: "./bin/first-output.js",
bundledPackageName: "first"
outFile: "./bin/first-output.js"
},
files: [sources[Project.first][Source.ts][Part.one]]
}));
Expand All @@ -671,7 +670,6 @@ ${internal} enum internalEnum { a, b, c }`);
stripInternal: true,
sourceMap: true,
outFile: "./thirdjs/output/third-output.js",
bundledPackageName: "third"
},
references: [{ path: "../first", prepend: true }],
files: [sources[Project.third][Source.ts][Part.one]]
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/tsbuild/watchMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,13 @@ export class someClass2 { }`),
const coreTsConfig: File = {
path: core[0].path,
content: JSON.stringify({
compilerOptions: { composite: true, declaration: true, outFile: "index.js", bundledPackageName: "core" }
compilerOptions: { composite: true, declaration: true, outFile: "index.js" }
})
};
const logicTsConfig: File = {
path: logic[0].path,
content: JSON.stringify({
compilerOptions: { composite: true, declaration: true, outFile: "index.js", bundledPackageName: "logic" },
compilerOptions: { composite: true, declaration: true, outFile: "index.js" },
references: [{ path: "../core", prepend: true }]
})
};
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/tsserver/projectReferenceErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ let x: string = 10;`
};
const dependencyConfig: File = {
path: `${dependecyLocation}/tsconfig.json`,
content: JSON.stringify({ compilerOptions: { composite: true, outFile: "../dependency.js", bundledPackageName: "dep" } })
content: JSON.stringify({ compilerOptions: { composite: true, outFile: "../dependency.js" } })
};
const usageTs: File = {
path: `${usageLocation}/usage.ts`,
Expand All @@ -205,7 +205,7 @@ fnErr();
const usageConfig: File = {
path: `${usageLocation}/tsconfig.json`,
content: JSON.stringify({
compilerOptions: { composite: true, outFile: "../usage.js", bundledPackageName: "usage" },
compilerOptions: { composite: true, outFile: "../usage.js" },
references: [{ path: "../dependency" }]
})
};
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,6 @@ declare namespace ts {
allowUnusedLabels?: boolean;
alwaysStrict?: boolean;
baseUrl?: string;
bundledPackageName?: string;
charset?: string;
checkJs?: boolean;
declaration?: boolean;
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,6 @@ declare namespace ts {
allowUnusedLabels?: boolean;
alwaysStrict?: boolean;
baseUrl?: string;
bundledPackageName?: string;
charset?: string;
checkJs?: boolean;
declaration?: boolean;
Expand Down
30 changes: 0 additions & 30 deletions tests/baselines/reference/bundledDtsLateExportRenaming.errors.txt

This file was deleted.

51 changes: 0 additions & 51 deletions tests/baselines/reference/bundledDtsLateExportRenaming.js

This file was deleted.

This file was deleted.

50 changes: 0 additions & 50 deletions tests/baselines/reference/bundledNodeDTSFailsWithOutFlag.js

This file was deleted.

Loading

0 comments on commit c12cc53

Please sign in to comment.