vitest icon indicating copy to clipboard operation
vitest copied to clipboard

vitest resolves imported modules (in setup files) as relative imports from the cwd if the import module has the same name as a directory

Open steve-py96 opened this issue 3 years ago • 2 comments

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

steve-py96 avatar Feb 01 '23 12:02 steve-py96

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)

steve-py96 avatar Feb 01 '23 12:02 steve-py96

Doesn't look like this is an issue anymore.

sheremet-va avatar Oct 04 '23 12:10 sheremet-va