-
-
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
When using Preact and Svelte Vite plugins together, Preact tests suddenly fail #737
Comments
We have the same error here: #747 |
This is probably cased by this: testing-library/preact-testing-library#50 Althought it's weird that it's working if you don't use Svelte 🤔 |
So, I identified the problem. Svelte plugin adds There a two questions tho:
To fix this, you can add your alias, pointing to the correct file: resolve: {
alias: [
{
find: /^preact\/hooks$/,
replacement: resolve(
dirname,
'node_modules/.pnpm/preact@10.7.3/node_modules/preact/hooks/dist/hooks.mjs'
),
},
],
}, |
That file is correct. Echoing what I said on the Preact issue, but Vitest enforcing Node's extension semantics ( Not to mention that React Native/Expo (just an example) still does not support the |
Fixed in preactjs/preact#3564 |
Thanks everyone for investigating and fixing this! |
Hi, I'm getting the same error again in my example case (dependencies updated to latest versions) with Node 16 and 18:
Is this still an import issue? Now Thanks for looking into this! |
Yes, svelte plugin adds "module" field to |
Describe the bug
[This is a follow-up to #367. The test case I had provided now works fine, thanks!]
In my project, I’m using Preact and Svelte together. Some components are Preact, some Svelte.
Both work fine together in Vite using @preact/preset-vite and @sveltejs/vite-plugin-svelte.
They also work separately in Vitest. But when I use both, the Preact test suddenly fails – just by adding Svelte’s Vite plugin.
The Preact component in question calls
useState
. This is where the test fails.This might be an issue in @preact/preset-vite or @sveltejs/vite-plugin-svelte. But I don’t know where to start to pin this down. Are the plugins interfering with each other? If so, it produces an error in Vitest, not in pure Vite.
If you have any clue what’s going wrong here, I’m happy to forward it to the respective maintainers.
Thanks a lot!
Reproduction
Minimal example: https://github.com/molily/vitest-test/tree/preact-and-svelte
vite.config.js:
If I remove
svelte(…)
from vite.config.js, the Preact component test is green.System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: