Skip to content

Commit

Permalink
fix(vite-node): check circular before adding path to importers
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed May 31, 2023
1 parent add29c8 commit c064ff9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite-node/src/client.ts
Expand Up @@ -188,13 +188,16 @@ export class ViteNodeRunner {

if (!mod.importers)
mod.importers = new Set()

const isCircular = mod.importers.has(importee)

if (importee)
mod.importers.add(importee)

const getStack = () => `stack:\n${[...callstack, fsPath].reverse().map(p => ` - ${p}`).join('\n')}`

// check circular dependency
if (callstack.includes(fsPath) || callstack.some(c => this.moduleCache.get(c).importers?.has(fsPath)) || mod.importers.has(importee)) {
if (isCircular || callstack.includes(fsPath) || callstack.some(c => this.moduleCache.get(c).importers?.has(fsPath))) {
if (mod.exports)
return mod.exports
}
Expand Down

0 comments on commit c064ff9

Please sign in to comment.