Skip to content

Commit 6c4bf26

Browse files
authored
fix(node): remove timestamp query of staticImportedUrls (vitejs#15663)
1 parent 74382b9 commit 6c4bf26

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/vite/src/node/plugins/importAnalysis.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
normalizePath,
4444
prettifyUrl,
4545
removeImportQuery,
46+
removeTimestampQuery,
4647
stripBase,
4748
stripBomTag,
4849
timeFrom,
@@ -685,7 +686,9 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
685686
// `importedUrls` will be mixed with watched files for the module graph,
686687
// `staticImportedUrls` will only contain the static top-level imports and
687688
// dynamic imports
688-
const staticImportedUrls = new Set(_orderedImportedUrls)
689+
const staticImportedUrls = new Set(
690+
_orderedImportedUrls.map((url) => removeTimestampQuery(url)),
691+
)
689692
const acceptedUrls = mergeAcceptedUrls(orderedAcceptedUrls)
690693
const acceptedExports = mergeAcceptedUrls(orderedAcceptedExports)
691694

playground/hmr/__tests__/hmr.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ if (!isBuild) {
186186
() => el.textContent(),
187187
'soft-invalidation/index.js is transformed 1 times. child is updated',
188188
)
189+
190+
editFile('soft-invalidation/index.js', (code) =>
191+
code.replace('child is', 'child is now'),
192+
)
193+
editFile('soft-invalidation/child.js', (code) =>
194+
code.replace('updated', 'updated?'),
195+
)
196+
await untilUpdated(
197+
() => el.textContent(),
198+
'soft-invalidation/index.js is transformed 2 times. child is now updated?',
199+
)
189200
})
190201

191202
test('plugin hmr handler + custom event', async () => {

0 commit comments

Comments
 (0)