vitest
vitest copied to clipboard
v4 breaks for type import without `import type` in globalSetup file
Describe the bug
vitest v4 report SyntaxError for type import without import type in globalSetup file,
similar to https://github.com/vitest-dev/vitest/issues/8868
SyntaxError: [vite] The requested module '/node_modules/.pnpm/@[email protected]/node_modules/@azure/core-lro/dist/esm/index.js' does not provide an export named 'OperationState'
❯ analyzeImportedModDifference node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:484:36
❯ ServerModuleRunner.processImport node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1053:54
❯ ServerModuleRunner.cachedRequest node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1078:59
❯ test/setup.ts:1:1
1| import { PollerLike, OperationState } from '@azure/core-lro';
| ^
2|
3| export default async function setup() {
❯ VitestModuleEvaluator._runInlinedModule node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vitest/dist/module-evaluator.js:225:4
❯ ServerModuleRunner.directRequest node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1171:59
❯ ServerModuleRunner.cachedRequest node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1078:73
❯ ServerModuleRunner.import node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/module-runner.js:1039:10
❯ loadGlobalSetupFile node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:8514:12
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-bcftlj4g?file=vite.config.ts
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@vitest/ui: latest => 4.0.15
vite: latest => 7.2.6
vitest: latest => 4.0.15
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.