You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default values for those options are updated to the corresponding values and ssr.resolve.conditions no longer uses resolve.conditions as the default value.
Vitest uses ssr environment in node Vitest environment (previously, ssr field in the config), and client environment in jsdom or happy-dom (previously, the root config)
IMHO, I don't think Vite 6's documentation is relevant to this issue. The breaking changes in Vite 6 only mention default values, but my reproduction uses a custom dev value instead, without default value.
I also tried setting ssr.resolve.conditions: ['dev'], but it doesn't work.
The breaking changes in Vite 6 only mention default values, but my reproduction uses a custom dev value instead, without default value.
Vite 6 doesn't inherit resolve.conditions in SSR. Vitest uses SSR environment for the default node environment (from the reproduction). The only bug here is that Vitest doesn't inherit ssr.resolve.conditions. It treats should treat resolve.conditions the same way Vite does.
I don't think this is part of Vitest API, this is how Vite works. If you don't want to use Vite 6, use Vite 5. We support both versions and just follow the configuration supported by the version of Vite that you are using.
The breaking changes in Vite 6 only mention default values, but my reproduction uses a custom dev value instead, without default value.
Vite 6 doesn't inherit resolve.conditions in SSR. Vitest uses SSR environment for the default node environment (from the reproduction). The only bug here is that Vitest doesn't inherit ssr.resolve.conditions. It treats should treat resolve.conditions the same way Vite does.
I have the same problem. Can you maybe explain how this could look like in a workaround? Using vitest with happy dom.
Does this also means vitest 3 (beside < vitest 2.17) will be the first version which supports vite 6 or will you also release a vitest 2.x version which supports vite 6?
Does this also means vitest 3 (beside < vitest 2.17) will be the first version which supports vite 6 or will you also release a vitest 2.x version which supports vite 6?
There will be no more Vitest 2 versions. Vitest 3 is the first version that supports Vite 6 (excluding 2.1.6)
Reacted by Manuel, Kevin Deng, Bobbie Goede, Corbin Crutchley, James Ross, Eric Kim-Butler, Bazyli BrzΓ³ska, Shay Cojocaru, Jeffrey Yasskin and Joel
conditions passed through NODE_OPTIONS are also not respected, which means internal imports are no longer resolved properly.
β [ERROR] Could not resolve "#colors"
__tests__/reporters/verbose.mts:7:19:
7 β import colors from '#colors'
β΅ ~~~~~~~~~
The module "./dist/colors.mjs" was not found on the file system:
package.json:54:17:
54 β "default": "./dist/colors.mjs"
β΅ ~~~~~~~~~~~~~~~~~~~
You can mark the path "#colors" as external to exclude it from the bundle, which will remove this
error and leave the unresolved path in the bundle.
failed to load config from /Users/lex/Projects/FLDV/FLDV-P061/vitest.config.mts
note: the suggestion provided does not fix the error.
pinning vite to version 5.4.14 seems to be the only workaround. unfortunately, this isn't ideal. is this expected behavior?
Activity
colinlienard commentedon Nov 30, 2024
Also experiencing this issue, but I'm not using vite, it's the bump of vitest to v2.1.6 that is causing the issue for me, sticking to v2.1.5 for now
sxzz commentedon Nov 30, 2024
Vitest uses Vite at its core, and Vitest v2.1.5 uses Vite 5, so this issue can be avoided on v2.1.5.
sxzz commentedon Nov 30, 2024
Investigating: maybe related to Environment API
sxzz commentedon Nov 30, 2024
Workaround: Adding
environments.ssr.resolve.conditionscan fix this issue.test: fix custom resolver conditions on Vite 6 + Vitest
fix: custom resolver conditions on ssr environment
sheremet-va commentedon Nov 30, 2024
This is expected behaviour in Vite 6: https://vite.dev/guide/migration.html#general-changes
Vitest uses
ssrenvironment innodeVitest environment (previously,ssrfield in the config), andclientenvironment injsdomorhappy-dom(previously, the root config)We can add this to documentation
sxzz commentedon Nov 30, 2024
IMHO, I don't think Vite 6's documentation is relevant to this issue. The breaking changes in Vite 6 only mention default values, but my reproduction uses a custom
devvalue instead, without default value.I also tried setting
ssr.resolve.conditions: ['dev'], but it doesn't work.sheremet-va commentedon Nov 30, 2024
Vite 6 doesn't inherit
resolve.conditionsin SSR. Vitest uses SSR environment for the defaultnodeenvironment (from the reproduction). The only bug here is that Vitest doesn't inheritssr.resolve.conditions. Ittreatsshould treatresolve.conditionsthe same way Vite does.sheremet-va commentedon Nov 30, 2024
You can override
transformMode, by the way: https://vitest.dev/config/#testtransformmode (by default, it depends on the environment)sxzz commentedon Nov 30, 2024
I see. Maybe Vitest should release a major version due to the breaking change in Vite that significantly affects Vitest.
sheremet-va commentedon Nov 30, 2024
I don't think this is part of Vitest API, this is how Vite works. If you don't want to use Vite 6, use Vite 5. We support both versions and just follow the configuration supported by the version of Vite that you are using.
kolorfilm commentedon Dec 1, 2024
I have the same problem. Can you maybe explain how this could look like in a workaround? Using vitest with happy dom.
Thank you!
kolorfilm commentedon Dec 1, 2024
Somehow has the same issue.
12 remaining items
WtfJoke commentedon Dec 5, 2024
Does this also means vitest 3 (beside < vitest 2.17) will be the first version which supports vite 6 or will you also release a vitest 2.x version which supports vite 6?
sheremet-va commentedon Dec 5, 2024
There will be no more Vitest 2 versions. Vitest 3 is the first version that supports Vite 6 (excluding 2.1.6)
chore: pin to vitest 2.1.5
chore: bump vitest in templates (#7384)
[Workers] fix: update supported vitest version (#18474)
unicornware commentedon Jan 27, 2025
@sheremet-va
conditions passed through
NODE_OPTIONSare also not respected, which means internal imports are no longer resolved properly.pinning vite to version
5.4.14seems to be the only workaround. unfortunately, this isn't ideal. is this expected behavior?hi-ogawa commentedon Jan 28, 2025
Closing since this is an intended breaking change on Vitest 3 and OP's reproduction passes now with
ssr.resolve.conditions: ['dev']https://stackblitz.com/edit/github-bf27lxf7?file=vitest.config.tsIf you encounter an issue, please create a new issue with the reproduction. Thanks!