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
Package.json has type: module but main still points at commonjs #646
Comments
Here's a related discussion in the vitest repo vitest-dev/vitest#4233 |
If anyone else runs into this, I worked around this by adding an alias to my vite config: alias: {
'a11y-dialog': path.resolve(__dirname, './node_modules/a11y-dialog/dist/a11y-dialog.esm.js'),
}, |
Hello Brian, and thanks for opening an issue. 👋 I must say this is the part of maintaining a package I am really unexperienced with, and I am always terrified of breaking things by touching the entry points or the bundling system. I recall having to release several hotfixes after v8 to have something that works. 😓 If you are pretty confident with the |
Yeah I agree touching I'm happy to send a MR when I get a chance. I think the biggest risk is that a user might be reaching into the package to grab some internals, and the |
I just started using this library and it works great! Thanks for your efforts here.
Now I'm writing tests (and running with vitest), but it seems to be picking up the commonjs version of the build. This results in the error "default is not a constructor".
I'm not 100% sure, but it might be that vitest is following closely with the module spec, where the
module
field of package.json isn't actually used, instead it uses the main field when there isn't anexports
field. Themodule
field of package.json isn't standard, so it makes sense that vitest wouldn't use it.As a sanity check, I changed the main field to point to the .esm.js file and stopped getting that error. I wouldn't recommend that for production though, I think this should be updated to use the
exports
field and use conditional exports for require and import.The text was updated successfully, but these errors were encountered: