Skip to content

Commit 01ceb65

Browse files
committed
Use readJson again so they can all be replaced at the same time
1 parent 747e769 commit 01ceb65

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/compiler/moduleSpecifiers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import {
9090
pathIsBareSpecifier,
9191
pathIsRelative,
9292
PropertyAccessExpression,
93+
readJson,
9394
removeExtension,
9495
removeFileExtension,
9596
removeSuffix,
@@ -907,11 +908,11 @@ function tryGetModuleNameFromPackageJsonImports(moduleFileName: string, sourceDi
907908
}
908909
const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json");
909910
const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath);
910-
if (typeof cachedPackageJson !== "object" && cachedPackageJson !== undefined || !host.fileExists(packageJsonPath)) {
911+
if (typeof cachedPackageJson !== "object" && cachedPackageJson !== undefined) {
911912
return undefined;
912913
}
913-
const packageJsonContent = cachedPackageJson?.contents.packageJsonContent || JSON.parse(host.readFile(packageJsonPath)!);
914-
const imports = packageJsonContent?.imports;
914+
const packageJsonContent = cachedPackageJson?.contents.packageJsonContent || readJson(packageJsonPath, host as { readFile(path: string): string | undefined; });
915+
const imports = (packageJsonContent as any).imports;
915916
if (!imports) {
916917
return undefined;
917918
}

0 commit comments

Comments
 (0)