-
-
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
V3 seems to be changing how dynamic imports work.
Imports in the following style seem to be incorrectly cached.
const lib = await import('<url#hash1>');
// ...
const libUpdated = await import('<url#hash2>');
assert(lib !== libUpdated);
Note: This works correctly in V2.
Might be related to: #7269, #7266, but it doesn't seem to be fixed in v3.0.4.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-1rbfzzpd?file=test%2Fsuite.test.ts
describe('suite name', () => {
it('validates that async import works as expected.', async () => {
const hello0 = await import(urlHelloJs.href);
expect(hello0['sayHello']).toBeTypeOf('function');
});
it('validates that async import with hash change will reload.', async () => {
const hello0 = await import(urlHelloJs.href);
const url1 = new URL(urlHelloJs);
url1.hash = 'bustCache=1';
const hello1 = await import(url1.href);
expect(hello1['sayHello']).toBeTypeOf('function');
expect(hello1).not.toBe(hello0);
});
it('validates that async import with query change will reload.', async () => {
const hello0 = await import(urlHelloJs.href);
const url1 = new URL(urlHelloJs);
url1.searchParams.set('bustCache', '1');
const hello1 = await import(url1.href);
expect(hello1['sayHello']).toBeTypeOf('function');
expect(hello1).not.toBe(hello0);
});
});System Info
Note: it breaks on Linux and Windows as well.
System:
OS: macOS 15.2
CPU: (12) arm64 Apple M3 Pro
Memory: 182.05 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.18.1 - ~/.nvm/versions/node/v20.18.1/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.18.1/bin/npm
pnpm: 9.15.0 - ~/.nvm/versions/node/v20.18.1/bin/pnpm
Browsers:
Chrome: 132.0.6834.110
Edge: 132.0.2957.127
Safari: 18.2
npmPackages:
@vitest/coverage-istanbul: ^3.0.4 => 3.0.4
vite: ^6.0.11 => 6.0.11
vitest: ^3.0.4 => 3.0.4Used Package Manager
pnpm
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)