-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
cjs file extension is not supported in vite #2648
Comments
This comment has been minimized.
This comment has been minimized.
@nihalgonsalves But this is not in ssr. That issue has ssr label. |
I did some more reading, and this seems like the correct behaviour for module resolution. The algorithm will look for an Your package should always specify Here's the algorithm: https://nodejs.org/api/esm.html#esm_resolver_algorithm_specification This is also outlined in the Webpack docs here
You can test this behaviour with yarn add esbuild
# try this with with both versions of your package.json, and you will see
# that .cjs is used if the default appears before the import in your exports field
yarn esbuild ./src/main.js --bundle --format=esm |
Closing due to inactivity. The solution is to order the exports correctly - please comment if you run into further issues. |
Reproduction
https://github.com/xiaoxiangmoe/vite-exports-and-cjs-bug
Open browser
Describe the bug
In this demo, we create a package with
package.json
as below:And vite use
pkg.exports['.'].require
as entry file.This has a bug:
System Info
vite
version: 2.1.2The text was updated successfully, but these errors were encountered: