diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index cb2511c7d2ed21..63f39d15b0f979 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -43,6 +43,7 @@ import { normalizePath, prettifyUrl, removeImportQuery, + removeTimestampQuery, stripBase, stripBomTag, timeFrom, @@ -685,7 +686,9 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { // `importedUrls` will be mixed with watched files for the module graph, // `staticImportedUrls` will only contain the static top-level imports and // dynamic imports - const staticImportedUrls = new Set(_orderedImportedUrls) + const staticImportedUrls = new Set( + _orderedImportedUrls.map((url) => removeTimestampQuery(url)), + ) const acceptedUrls = mergeAcceptedUrls(orderedAcceptedUrls) const acceptedExports = mergeAcceptedUrls(orderedAcceptedExports) diff --git a/playground/hmr/__tests__/hmr.spec.ts b/playground/hmr/__tests__/hmr.spec.ts index cd4fb773cb753a..0d95557aa65fb3 100644 --- a/playground/hmr/__tests__/hmr.spec.ts +++ b/playground/hmr/__tests__/hmr.spec.ts @@ -186,6 +186,17 @@ if (!isBuild) { () => el.textContent(), 'soft-invalidation/index.js is transformed 1 times. child is updated', ) + + editFile('soft-invalidation/index.js', (code) => + code.replace('child is', 'child is now'), + ) + editFile('soft-invalidation/child.js', (code) => + code.replace('updated', 'updated?'), + ) + await untilUpdated( + () => el.textContent(), + 'soft-invalidation/index.js is transformed 2 times. child is now updated?', + ) }) test('plugin hmr handler + custom event', async () => {