Skip to content

Commit

Permalink
fix(node): remove timestamp query of staticImportedUrls (#15663)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaejunlee committed Jan 23, 2024
1 parent 74382b9 commit 6c4bf26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -43,6 +43,7 @@ import {
normalizePath,
prettifyUrl,
removeImportQuery,
removeTimestampQuery,
stripBase,
stripBomTag,
timeFrom,
Expand Down Expand Up @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions playground/hmr/__tests__/hmr.spec.ts
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 6c4bf26

Please sign in to comment.