mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Handle more places where package direcroy is converted to canonical file path (#50740)
* Add test for node16 resolution with package json lookup making casing incorrect * Handle more places where package direcroy is converted to canonical file path
This commit is contained in:
@@ -849,7 +849,7 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
export function getImpliedNodeFormatForFileWorker(
|
||||
fileName: Path,
|
||||
fileName: string,
|
||||
packageJsonInfoCache: PackageJsonInfoCache | undefined,
|
||||
host: ModuleResolutionHost,
|
||||
options: CompilerOptions,
|
||||
@@ -870,7 +870,7 @@ namespace ts {
|
||||
state.failedLookupLocations = packageJsonLocations;
|
||||
state.affectingLocations = packageJsonLocations;
|
||||
const packageJsonScope = getPackageScopeForPath(fileName, state);
|
||||
const impliedNodeFormat = packageJsonScope?.packageJsonContent.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS;
|
||||
const impliedNodeFormat = packageJsonScope?.contents.packageJsonContent.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS;
|
||||
return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
|
||||
}
|
||||
}
|
||||
@@ -2834,7 +2834,7 @@ namespace ts {
|
||||
// It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
|
||||
// and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
|
||||
// to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
|
||||
const result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache?.getPackageJsonInfoCache(), host, options);
|
||||
const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache?.getPackageJsonInfoCache(), host, options);
|
||||
const languageVersion = getEmitScriptTarget(options);
|
||||
const setExternalModuleIndicator = getSetExternalModuleIndicator(options);
|
||||
return typeof result === "object" ?
|
||||
|
||||
Reference in New Issue
Block a user