From 0fd2a5982481c040639ee372e55c00670aab808d Mon Sep 17 00:00:00 2001 From: Chaejun Lee Date: Fri, 19 Jan 2024 15:14:21 -0800 Subject: [PATCH 1/2] fix(node): remove timestamp query of `staticImportedUrls` --- packages/vite/src/node/plugins/importAnalysis.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) From 8b70a0fe1a5bfe0dcf2c2024ab53b06ef052ebad Mon Sep 17 00:00:00 2001 From: Chaejun Lee Date: Tue, 23 Jan 2024 01:15:26 -0800 Subject: [PATCH 2/2] test: soft invalidate --- playground/hmr/__tests__/hmr.spec.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 () => {