-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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 an option to whitelist certain packages as "can use the exports map directly" #14404
Comments
I don't think we're adding an option like this for the forseeable future, but we have also talked about removing the incorrect resolve altogether ( |
I don't suppose the |
Yeah it's classed as a breaking change as it's likely to cause small resolving issues for existing libraries. It's implemented as a heuristic so it works with some library, and removing it means causing some of these libraries to not work, so we can't do this in v4. |
Understandable. Is there an estimated timeline for v5? |
Should be around mid-October, but we're also watching the next Rollup major release, so that may change slightly. |
@bluwy I had a look at the milestone for v5 but couldn't see anything that mentioned removing the exports map heuristic. Is this issue going to be addressed in v5? |
Ah sorry about that. I forgot to add this to the milestone. We're close to the stable release now, but I'll put this on the milestone for now and will try to check if it works out for the ecosystem. It shouldn't be a big change. |
Description
According to this comment in the vite sourcecode, even if the exports map has a valid entry, it'll refuse to use it if it exists alongside the legacy fields, and if the exports map entry ends in
.mjs
.Assuming this behaviour is still necessary for some packages, it still breaks for others.
For example:
bwip-js
The exports map is thoroughly defined, but they need to define the legacy fields for backwards-compatibility for older codebases.
However, the legacy fields aren't sufficient enough to support ESM (as there's no legacy method for defining browser + esm + types), so they only support CJS via the legacy fields.
Packages like
bwip-js
should use theexports
map where possible.Suggested solution
In order to maintain the existing behaviour for packages that need it, there's two potential solutions
Both of these solutions would solve my particular use-case, but ultimately, the vite team would need to decide which is best for vite itself
Alternative
resolve.alias
to manually specify the resolution path tonode_modules/bwip-js/dist/bwip-js.mjs
browser
field inbwip-js
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: