-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature request: add import/require information in plugin OnResolveArgs #879
Comments
Makes sense. This is already available internally so exposing this is straightforward. Here's what will be in the next release (from the release notes):
|
FYI this was just published as version 0.8.52. |
Thanks! |
Currently in the
onResolve
hook of a plugin, we don't have information on whether the request was made via ESM import or CJS require. This information, however, is somewhat important when resolving Node dependencies, especially those with explicit sub pathexports
definitions.Take @babel/runtime as an example: it defines exports for all its helpers, e.g.
It probably does this because it wants to allow users to do both
Without the esm vs. cjs information though, the plugin
onResolve
hook can only guess which one it should resolve to. In the case for Vite, it will prefer ESM entries, so it resolves to the mjs version which, when required, fails to run because the helper is the default export and needs to be accessed asfoo.default
.Since esbuild seems to allow the mix of ESM and CJS, it would be beneficial to somehow expose that information to plugins sp that resolvers can properly resolve conditional exports.
The text was updated successfully, but these errors were encountered: