Skip to content

Commit

Permalink
fix(hmr): avoid duplicated modules for css dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 18, 2021
1 parent ff7284f commit 385ced9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/vite/src/node/server/moduleGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,20 @@ export class ModuleGraph {
// hmr in the importing css file.
createFileOnlyEntry(file: string): ModuleNode {
file = normalizePath(file)
const url = `${FS_PREFIX}${file}`
let fileMappedModules = this.fileToModulesMap.get(file)
if (!fileMappedModules) {
fileMappedModules = new Set()
this.fileToModulesMap.set(file, fileMappedModules)
}

for (const m of fileMappedModules) {
if (m.url === url) {
if (m.id === file) {
return m
}
}
const mod = new ModuleNode(url)

const mod = new ModuleNode(`${FS_PREFIX}${file}`)
mod.id = file
mod.file = file
fileMappedModules.add(mod)
return mod
Expand Down

0 comments on commit 385ced9

Please sign in to comment.