Skip to content

Commit

Permalink
Use readJson again so they can all be replaced at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown committed Aug 17, 2023
1 parent 747e769 commit 01ceb65
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import {
pathIsBareSpecifier,
pathIsRelative,
PropertyAccessExpression,
readJson,
removeExtension,
removeFileExtension,
removeSuffix,
Expand Down Expand Up @@ -907,11 +908,11 @@ function tryGetModuleNameFromPackageJsonImports(moduleFileName: string, sourceDi
}
const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json");
const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath);
if (typeof cachedPackageJson !== "object" && cachedPackageJson !== undefined || !host.fileExists(packageJsonPath)) {
if (typeof cachedPackageJson !== "object" && cachedPackageJson !== undefined) {
return undefined;
}
const packageJsonContent = cachedPackageJson?.contents.packageJsonContent || JSON.parse(host.readFile(packageJsonPath)!);
const imports = packageJsonContent?.imports;
const packageJsonContent = cachedPackageJson?.contents.packageJsonContent || readJson(packageJsonPath, host as { readFile(path: string): string | undefined; });
const imports = (packageJsonContent as any).imports;
if (!imports) {
return undefined;
}
Expand Down

0 comments on commit 01ceb65

Please sign in to comment.