Skip to content

Commit

Permalink
fix(vite): ensureEntryFromUrl should return an existing module with t…
Browse files Browse the repository at this point in the history
…he same id
  • Loading branch information
paraboul committed Jul 15, 2021
1 parent 887c247 commit 9f558ce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vite/src/node/server/moduleGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export class ModuleGraph {

async ensureEntryFromUrl(rawUrl: string): Promise<ModuleNode> {
const [url, resolvedId] = await this.resolveUrl(rawUrl)
let mod = this.urlToModuleMap.get(url)
let mod = this.urlToModuleMap.get(url) || this.idToModuleMap.get(resolvedId)

if (!mod) {
mod = new ModuleNode(url)
this.urlToModuleMap.set(url, mod)
Expand Down Expand Up @@ -179,6 +180,10 @@ export class ModuleGraph {

const mod = new ModuleNode(url)
mod.file = file

mod.id = file
this.idToModuleMap.set(mod.id, mod)

fileMappedModules.add(mod)
return mod
}
Expand Down

0 comments on commit 9f558ce

Please sign in to comment.