vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
12.63k stars 1.13k forks source link

Secondary `resolveId` calls on virtual modules #6406

Open epfremmer opened 2 weeks ago

epfremmer commented 2 weeks ago

Describe the bug

The resolveId method on plugins which return a virtual module is called a second time with the previously resolved module id. It seems odd this would happen which made me question if this the intended behavior?

This came up while troubleshooting import errors using the plugin from lezer-parser/generator which uses virtual modules to load *.grammar.terms imports. I've opened an issue there (https://github.com/lezer-parser/generator/pull/21), but the question that this may be a bug in vitest was raised in that discussion.

Thank you for any assistance & guidance you can provide ❤️

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-yzpqjh?file=README.md

System Info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.63 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.volta/tools/image/node/18.18.2/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 9.8.1 - ~/.volta/tools/image/node/18.18.2/bin/npm
    pnpm: 8.15.6 - /opt/homebrew/bin/pnpm
    Watchman: 2024.04.08.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 128.0.6613.84
    Safari: 17.6
  npmPackages:
    vitest: 2.0.5 => 2.0.5

Used Package Manager

npm

Validations

sheremet-va commented 2 weeks ago

This is spam. If anyone comes across this issue, DO NOT click on links or download anything.