-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add auto-import for the package.json
imports
field
#55015
Merged
andrewbranch
merged 34 commits into
microsoft:main
from
emmatown:auto-import-package-json-imports
Dec 21, 2023
Merged
Add auto-import for the package.json
imports
field
#55015
andrewbranch
merged 34 commits into
microsoft:main
from
emmatown:auto-import-package-json-imports
Dec 21, 2023
+2,298
−69
Commits on Jul 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 7c0fef4 - Browse repository at this point
Copy the full SHA 7c0fef4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 60ec33b - Browse repository at this point
Copy the full SHA 60ec33bView commit details
Commits on Aug 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for faef5fd - Browse repository at this point
Copy the full SHA faef5fdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1d49909 - Browse repository at this point
Copy the full SHA 1d49909View commit details -
diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 4dcf24ea4b..d6022afe4b 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -90,7 +90,6 @@ import { pathIsBareSpecifier, pathIsRelative, PropertyAccessExpression, - readJson, removeExtension, removeFileExtension, removeSuffix, @@ -894,11 +893,11 @@ function tryGetModuleNameFromPackageJsonImports(moduleFileName: string, sourceDi } const packageJsonPath = combinePaths(ancestorDirectoryWithPackageJson, "package.json"); const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath); - if (typeof cachedPackageJson !== "object" && cachedPackageJson !== undefined) { + if (typeof cachedPackageJson !== "object" && cachedPackageJson !== undefined || !host.fileExists(packageJsonPath)) { return undefined; } - const packageJsonContent = cachedPackageJson?.contents.packageJsonContent || readJson(packageJsonPath, host as { readFile(fileName: string): string | undefined }); - const imports = (packageJsonContent as any).imports; + const packageJsonContent = cachedPackageJson?.contents.packageJsonContent || JSON.parse(host.readFile(packageJsonPath)!); + const imports = packageJsonContent?.imports; if (!imports) { return undefined; }
Configuration menu - View commit details
-
Copy full SHA for 4e676a3 - Browse repository at this point
Copy the full SHA 4e676a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 747e769 - Browse repository at this point
Copy the full SHA 747e769View commit details
Commits on Aug 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 01ceb65 - Browse repository at this point
Copy the full SHA 01ceb65View commit details
Commits on Sep 11, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 864b9a3 - Browse repository at this point
Copy the full SHA 864b9a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for d0407a9 - Browse repository at this point
Copy the full SHA d0407a9View commit details
Commits on Oct 10, 2023
-
Configuration menu - View commit details
-
Copy full SHA for e092943 - Browse repository at this point
Copy the full SHA e092943View commit details -
Revert "Use readJson again so they can all be replaced at the same time"
This reverts commit 01ceb65.
Configuration menu - View commit details
-
Copy full SHA for 8f781c5 - Browse repository at this point
Copy the full SHA 8f781c5View commit details -
Configuration menu - View commit details
-
Copy full SHA for a2aa5ae - Browse repository at this point
Copy the full SHA a2aa5aeView commit details
Commits on Oct 30, 2023
-
Configuration menu - View commit details
-
Copy full SHA for eaa8e2e - Browse repository at this point
Copy the full SHA eaa8e2eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 051239b - Browse repository at this point
Copy the full SHA 051239bView commit details -
Configuration menu - View commit details
-
Copy full SHA for b3c5ca4 - Browse repository at this point
Copy the full SHA b3c5ca4View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea67766 - Browse repository at this point
Copy the full SHA ea67766View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7abf4a2 - Browse repository at this point
Copy the full SHA 7abf4a2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6a72a51 - Browse repository at this point
Copy the full SHA 6a72a51View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9903d72 - Browse repository at this point
Copy the full SHA 9903d72View commit details
Commits on Oct 31, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9e2df94 - Browse repository at this point
Copy the full SHA 9e2df94View commit details -
Configuration menu - View commit details
-
Copy full SHA for c4df857 - Browse repository at this point
Copy the full SHA c4df857View commit details -
Configuration menu - View commit details
-
Copy full SHA for 566e543 - Browse repository at this point
Copy the full SHA 566e543View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1f9f214 - Browse repository at this point
Copy the full SHA 1f9f214View commit details
Commits on Nov 15, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 7a5c164 - Browse repository at this point
Copy the full SHA 7a5c164View commit details -
Configuration menu - View commit details
-
Copy full SHA for 45194b2 - Browse repository at this point
Copy the full SHA 45194b2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8f2d0c3 - Browse repository at this point
Copy the full SHA 8f2d0c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8bef690 - Browse repository at this point
Copy the full SHA 8bef690View commit details -
Configuration menu - View commit details
-
Copy full SHA for cd84162 - Browse repository at this point
Copy the full SHA cd84162View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8d68392 - Browse repository at this point
Copy the full SHA 8d68392View commit details
Commits on Nov 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for a9634ed - Browse repository at this point
Copy the full SHA a9634edView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7f52af2 - Browse repository at this point
Copy the full SHA 7f52af2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4aab191 - Browse repository at this point
Copy the full SHA 4aab191View commit details
Commits on Dec 21, 2023
-
Configuration menu - View commit details
-
Copy full SHA for c435528 - Browse repository at this point
Copy the full SHA c435528View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4f29d3a - Browse repository at this point
Copy the full SHA 4f29d3aView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.