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.4
Used Package Manager
pnpm
Validations
Describe the bug
V3 seems to be changing how dynamic imports work.
Imports in the following style seem to be incorrectly cached.
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
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