aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.24k stars 43 forks source link

Incompatibility with vitest 0.25.6 #90

Closed harveylee closed 1 year ago

harveylee commented 1 year ago

I have a piece of code in a vitest test like:

import { something } from '~/fileA'
// ...and later
const module = await import('~/foo/bar/fileB')

And in my tsconfig.json, something like:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "~/*": ["./*"]
    }
  }
}

(i.e. I create an alias ~ for the src directory)

Using vitest 0.25.5, both the static import (fileA) and the dynamic import (fileB) work.

Using vitest 0.25.6, the static import works but the dynamic import fails. [vite-node] Failed to load ~/foo/bar/fileB

Here is the commit in vitest 0.25.6 that I think gives rise to this issue? https://github.com/vitest-dev/vitest/pull/2461 https://github.com/vitest-dev/vitest/commit/e9cb4136

aleclarson commented 1 year ago

This seems like a Vitest bug.