-
-
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
Vitest doesn't honor resolve conditions for nested modules in workspace. #5301
Comments
Thanks for the reproduction. When I test with Vitest 1.2.2, it looks like I get the same error as 1.3.0: $ envinfo --npmPackages
npmPackages:
@vitest/ui: 1.2.2 => 1.2.2
vite: 5.1.4 => 5.1.4
vitest: 1.2.2 => 1.2.2 npm run test
Is it possible that you also upgraded Vite at the same time? It would be great if you can identify previous working versions of both Vite and Vitest. There was a change related to Also one more change related to "browser mode" testing and workspace in Vitest 1.2.1 #4947. Do you happen to use this though your reproduction didn't include this setup? Regardless of whether it was working before, it looks like a bug to me. Nonetheless, it's good to know if it is regression or not. |
As far as I understand, it doesn't look like Vitest can handle Currently vitest/packages/vitest/src/node/pool.ts Line 63 in 5bb8b38
and this is passed to |
@hi-ogawa I just tested in my reproduction with many versions of vitest (and vite 5) and I'm not sure that particular example ever worked, although ideally it would. However the main thing that had me trying to create a reproduction is because of an issue we're seeing in the Marko ecosystem which I thought I had isolated via the above. In Marko it has a similar package.json condition remap that was honored in vitest@1.2.2 but not in 1.3.0+. I created a reproduction (although less simplified since this is actually running Marko code) https://github.com/DylanPiercey/vitest-issue-marko In the above example vitest loads Again the above works as-is in 1.2.2 but breaks when I upgrade just vitest to 1.3.0 🤔 |
Thanks for the update. Now I see that it works on 1.2.2, but it looks like it's working even without If |
Okay, I remembered one more potentially relevant change and indeed it looks like
|
@hi-ogawa I really appreciate the digging here! I apologize, the config there is misleading because the I think I will just update the above code to also enable the |
Dang, I was premature. My patch in marko-js/vite#113 doesn't work. Apparently setting this in the config hook is too late? |
Forget me. I'm just dumb and made a typo 😓. I should probably get vitest itself in the @marko/vite test suite... |
@DylanPiercey Thanks for verifying the workaround on Marko. Many things were intertwined in this particular issue, but for Vitest side, I think the main issue/limitation is about I'll update the issue title accordingly and track it as an known issue. I cannot immediately see how Vitest would support this, but maybe it might be possible in the future since tests between workspace project are guaranteed to be isolated so setting |
Sounds good, thanks for your help @hi-ogawa! |
Describe the bug
resolve.conditions
config for workspace is ignored when resolving nested node_module.When you import a module, which then imports another module that relies on
export
conditions vitest is not honoring those conditions if they are defined in the workspace config.If you define the resolve conditions in the main
vitest.config.ts
it will resolve the nested module, however I am trying to have server & client tests in a workspace which need different conditions (thebrowser
condition is different between them).Note this previously worked fine in
1.2.2
. It was broken in1.3.0
.Reproduction
Clone https://github.com/DylanPiercey/vitest-resolve-condition-nested-issue
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: