-
Notifications
You must be signed in to change notification settings - Fork 263
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: use .mjs
extension for ESM bundles
#671
Conversation
Thanks @sodatea |
This change broke something for me in Any idea @sodatea? This is the problem line: https://github.com/vuejs/vue-test-utils-next/blob/cfa9064e6bcbce282ca634cc5340058f3748d461/src/utils/compileSlots.ts#L1 Should the published
🤔 |
Yeah… maybe it's better to revert this change at this moment. I found another workaround in vite-jest anyway. |
I'm also working on a post to discuss the issue on native Node ESM support in Vue 3 core packages. Hopefully I can present it in the next team meeting. |
Sounds good. Happy to make this change, but we should make sure the rest of the core ecosystem follows the same conventions. |
The problem of this PR is that So when we mix the none-standard For example, in the case of vite-jest, module resolution and transformation is done by vite, which recognizes the It won't be a problem if the module resolution is also done by Node (the I worked around this issue in vite-jest by completely ignoring the |
I see. Right now we are building will rollup. Maybe there is something I can change in my config, I'll try that before reverting this change. Although this is not following the standard, breaking popular tools is not ideal either. What is the ideal solution moving forward? All tools and libraries should be adopting |
I could not find a way to build a library. It could be my lack of understanding on how to configure rollup. This seems to be a problem in other projects, too. I will revert this (for now). Happy to support the correct |
Reverted in 2.0.0-rc.9. https://github.com/vuejs/vue-test-utils-next/releases/tag/v2.0.0-rc.9 Let's chat more and figure out the best approach for moving the Vue core ecosystem to |
I talked to Evan and he believes that we need a dedicated time period to make the switch to ESM - just like the switch to Vue 3 as default. Because actually, Node.js now works quite well in ESM-CJS interop. As this issue illustrates, we can now seamlessly import from a CJS module to an ESM module as long as it's statically analyzable by https://github.com/guybedford/cjs-module-lexer. The CJS Module Lexer does support quite a lot of patterns. The error from But anyway, there's no urgent need for a native ESM entry now. If it's safer to keep it as-is, let's keep it as-is. |
https://nodejs.org/api/packages.html#packages_determining_module_system
Without
type: "module"
in thepackage.json
, Node.js (and therefore Jest, too) treats these.js
files as CommonJS modules, which is incorrect. It is also causing trouble invite-jest
.