-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
thank you vitest team for this awesome project! i can't be happier leaving jest in the dust.
when using an import statment in vitest.workspace.ts, i can't import .ts files using the .js extension.
changing the extension to use .ts or removing the extension completely, makes the import succeed.
perculiarly, this seems to only fail if the import is inside the vitest.workspace.ts file, any further .js imports that exist within the imported modules will import successfully.
Reproduction
// vite.workspace.ts
import { foo } from './foo.js';
// ^ Error: Failed to load url ./foo.js (resolved id: ./foo.js). Does the file exist?
// at loadAndTransform (./node_modules/vite/dist/node/chunks/dep-DyBnyoVI.js:51857:17)
// at async ViteNodeServer._transformRequest (./node_modules/vite-node/dist/server.mjs:524:16)
// at async ViteNodeServer._fetchModule (./node_modules/vite-node/dist/server.mjs:486:17)
// at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:277:46)
// at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:206:14)
// at async ViteNodeRunner.dependencyRequest (./node_modules/vite-node/dist/client.mjs:259:12)
// at async C:\__Projects\Code\pawe\vitest.workspace.ts:4:31
// at async ViteNodeRunner.runModule (./node_modules/vite-node/dist/client.mjs:399:5)
// at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:381:5)
// at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:206:14) {
// code: 'ERR_LOAD_URL'
void foo;// foo.ts
export foo = 'bar';System Info
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 AMD Ryzen 9 4900HS with Radeon Graphics
Memory: 4.02 GB / 15.42 GB
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.21 - C:\Program Files\nodejs\yarn.CMD
npm: 10.8.1 - ~\AppData\Roaming\npm\npm.CMD
pnpm: 8.7.4 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.22621.3527
npmPackages:
@vitejs/plugin-react: ^4.3.1 => 4.3.1
@vitest/browser: ^2.1.1 => 2.1.1
vite: ^5.4.6 => 5.4.6
vitest: ^2.1.1 => 2.1.1Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)