Process package.json exports with auto-import provider#47092
Process package.json exports with auto-import provider#47092andrewbranch merged 12 commits intomicrosoft:mainfrom
Conversation
| //// { "dependencies": { "mylib": "file:packages/mylib" } } | ||
|
|
||
| // @Filename: /packages/mylib/package.json | ||
| //// { "name": "mylib", "version": "1.0.0" } |
There was a problem hiding this comment.
The diff between this test and autoImportProvider7.ts demonstrates a bug fixed by no longer using resolveTypeReferenceDirective:
- //// { "name": "mylib", "version": "1.0.0", "main": "index.js", "types": "index" }
+ //// { "name": "mylib", "version": "1.0.0" }The test previously needed "types": "index" (required to have no extension) to work, due to a quirk of type reference directive resolution.
| } | ||
| } | ||
|
|
||
| return packageJsonInfo.resolvedEntrypoints = entrypoints || false; |
There was a problem hiding this comment.
Calling this function caches its results on the PackageJsonInfo, which itself is stored in the PackageJsonInfoCache which is part of the ModuleResolutionCache—open to suggestions for a cleaner place to put this if there are objections.
68f312c to
f18e95d
Compare
sandersn
left a comment
There was a problem hiding this comment.
I read over the changes and didn't come up with anything but some style comments. If you need another reviewer I'll need a background explanation for the code (again -- I think you explained it all to me last year or so).
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Significantly changes the package.json auto-import provider’s resolution process. Previously it used
resolveTypeReferenceDirectivewith a fallback totryResolveJsModulefor JS projects. UsingresolveTypeReferenceDirectivewas close but not quite right, so this fixes a couple straight up bugs, and also gives us the opportunity to pull in all files specifically referenced by an export map so those can be offered as auto-imports too. (Files matching a pattern export aren’t pulled in.)Fixes #47009