vitest resolves imported modules (in setup files) as relative imports from the cwd if the import module has the same name as a directory
Describe the bug
I have a project where I split the vite config into several parts to keep the config readable and compact - created a vite/-directory in the project's root for those partials.. After updating vitest some tests failed due to the error TypeError: createServer is not a function suddenly. When logging the vite import (see repro) I noticed it actually imported my vite directory instead of the module
Reproduction
https://stackblitz.com/edit/vitejs-vite-jp6xhw
System Info
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-4288U CPU @ 2.60GHz
Memory: 1.22 GB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 18.3.0 - /var/folders/15/2rcb_9zn3_158phhs1smcbz00000gp/T/fnm_multishells/735_1675040607640/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 8.3.2 - ~/.config/yarn/global/node_modules/.bin/npm
Browsers:
Chrome: 109.0.5414.119
Firefox: 105.0.3
Safari: 14.1.2
Used Package Manager
pnpm
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
can be workarounded by simply renaming the directory to something else like _vite (reporting anyway since it might become an issue at any later point anyway I'd guess)
Doesn't look like this is an issue anymore.