-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Process package.json exports with auto-import provider #47092
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
Process package.json exports with auto-import provider #47092
Conversation
//// { "dependencies": { "mylib": "file:packages/mylib" } } | ||
|
||
// @Filename: /packages/mylib/package.json | ||
//// { "name": "mylib", "version": "1.0.0" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Significantly changes the package.json auto-import provider’s resolution process. Previously it used
resolveTypeReferenceDirective
with a fallback totryResolveJsModule
for JS projects. UsingresolveTypeReferenceDirective
was 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