Description
Describe the bug
@vue/test-utils
provides module
field, that is resolved by bundlers, but if I import library with native node (or vitest, that used native node module resolution), then imported module will be in cjs (/dist/vue-test-utils.cjs
). Other issue is that all files have the same extension (js
), which is not supported by Node (For reference: https://github.com/sheremet-va/dual-packaging).
This leads to @vue/test-utils
importing cjs version of Vue in Vitest, which fails the tests (with --no-threads
), because it was already required()
when defining plugin.
To Reproduce
import { mount } from '@vue/test-utils'
// leads to cjs.js
Expected behavior
import { mount } from '@vue/test-utils'
// leads to esm.mjs
@vue/test-utils
needs an exports
field, so Node will correctly resolve paths:
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/vue-test-utils.esm-bundler.mjs",
"browser": "./dist/vue-test-utils.browser.js",
"require": "./dist/vue-test-utils.cjs.js",
"default": "./dist/vue-test-utils.cjs.js"
}
},
And mjs
extension on esm files (will require twicking bundling process).
Related information:
@vue/test-utils
version: anyVue
version: not relevantnode
version: not relevantnpm
(oryarn
) version: not relevant
Additional context