-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
regression: import can't be found in v0.23.0 #1978
Comments
Wow, it's not even possible to run {
"exports": {
"*": {
"development": "./index.dev.mjs"
"import": "./index.mjs",
"require": "./index.js"
},
}
} // index.mjs
export * from './dist/vue.esm.js' Anyway, I guess the problem might be somewhere in #1944, since we made vitest/packages/vite-node/src/client.ts Line 408 in a98c845
|
So, the problem was actually this line: vitest/packages/vite-node/src/client.ts Line 411 in a98c845
To be honest, I think this should be fixed on Vue side. Instead of extending Vue it should put named exports on Although we do have interopDefault for vitest/packages/vite-node/src/client.ts Line 364 in a98c845
|
@sheremet-va Thanks for looking into this 🙏 To be honest I don't really get all these subtleties. Do you think this is something fixable in vitest so v0.23 works as v0.22? I guess we can open an issue/PR on vue/compat side, but:
|
@cexbrayat I will make PR to fix this on Vitest side, and open issue to improve |
@sheremet-va You're the best, thanks! |
@sheremet-va sadly, it looks like v0.23.1 does not fix the issue. See vuejs/test-utils#1757 |
For anyone interested, the upstream issue is vuejs/core#6602 |
The upstream issue is supposed to be fixed but the error persists with Vue v3.2.40 and Vitest v0.23.4 |
@sheremet-va The issue is still there with v0.24.2 Do you have an idea of what we can do now that Vue lists the cjs dependencies for the compat build? |
Vitest behaves like Node would behave in this scenario. If you run this in Node, it will output the same module that Node would: import * as mockVue from '@vue/compat'
console.log(mockVue) To work correctly,
This will actually throw an error, because vue-compat doesn't export named |
We were blocked by vitest-dev/vitest#1978 but thanks to @sheremet-va help (see vitest-dev/vitest#1978 (comment)) we now have a way to use the latest vitest releases. It turns out that we needed to: - alias `@vue/compat` to its ESM bundle - use `Vue.extend` instead of `extend` in the `compat.spec.ts` file, as `extend` is not a named export
We were blocked by vitest-dev/vitest#1978 but thanks to @sheremet-va help (see vitest-dev/vitest#1978 (comment)) we now have a way to use the latest vitest releases. It turns out that we needed to: - alias `@vue/compat` to its ESM bundle - use `Vue.extend` instead of `extend` in the `compat.spec.ts` file, as `extend` is not a named export
Thanks for your help @sheremet-va 🙏 Let's close this, thanks again for looking into it. |
Describe the bug
I tried to reproduce in isolation but I couldn't, sorry.
In VTU, we have a test that mocks
vue
to use@vue/compat
insteadhttps://github.com/vuejs/test-utils/blob/main/tests/features/compat.spec.ts#L5
This test fails with vitest v0.23.0, whereas it works with v0.22.1.
It complains the
defineComponent
(a function exposed by vue and vue/compat) is not a function.Reproduction
The Renovate PR is showcasing the error
https://github.com/vuejs/test-utils/runs/8177607839?check_suite_focus=true
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: