Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hmr): entry mod's importers contains css mod invalidate hmr #3929

Merged
merged 2 commits into from
Jun 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update hmr.ts
  • Loading branch information
yyx990803 authored Jun 28, 2021
commit 328a2940963e52f1bf30412564624ff1715155cb
20 changes: 11 additions & 9 deletions packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,18 @@ function propagateUpdate(
if (!node.importers.size) {
return true
}

const isNotCSSMod = !isCSSRequest(node.url)
let noImporter = true

// #3716, #3913
// For a non-CSS file, if all of its importers are CSS files (registered via
// PostCSS plugins) it should be considered a dead end and force full reload.
if (
!isCSSRequest(node.url) &&
[...node.importers].every((i) => isCSSRequest(i.url))
) {
return true
}

for (const importer of node.importers) {
if (isCSSRequest(importer.url) && isNotCSSMod) {
continue
}
noImporter = false

const subChain = currentChain.concat(importer)
if (importer.acceptedHmrDeps.has(node)) {
boundaries.add({
Expand All @@ -271,7 +273,7 @@ function propagateUpdate(
return true
}
}
return noImporter
return false
}

function invalidate(mod: ModuleNode, timestamp: number, seen: Set<ModuleNode>) {
Expand Down