-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix: export module with .mjs to fix Vite resolution #1366
base: main
Are you sure you want to change the base?
Conversation
Vite tries to resolve the module as a CommonJS module because the main package.json does not contain "type": "module". Override this behavior by explicitly adding a .mjs extension.
Thanks for the pull request. Isn't this incorrect behavior from vite? I thought module and import imply esm. |
I'm unsure what the correct behavior based on the spec should be, but based on this Node.js package example, it claims:
|
This hasn't come up in years and we have multiple packages that I want to keep consistent so I'm treading carefully here. Maybe the best move at this point is to cut new major versions and move on to esm for everything. |
I understand your concern about not special-casing this repo. My guess is that this was more recently broken by #1301, as vega and vega-lite use the older This also seems consistent with the documentation under Conditional exports, which says
which suggests that the target file would default to CommonJS if For consistency, it may be easier to move all repos to |
@domoritz did you have a preference for how you wanted to move forward? I can make a larger PR to convert all the Vega projects to using |
Yeah, I think moving to ESM for everything is a good idea: vega/vega#3990. We already use import statements so hopefully it's a not too painful transition. I'm a bit busy until the end of the semester but plan to make some time over the break to get this done. It would be awesome if you could help with PRs! |
Vite tries to resolve the module as a CommonJS module because the main package.json does not contain "type": "module". Override this behavior by explicitly adding a .mjs extension.
Locally, this fixes vega/svelte-vega#977 for me.