File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
packages/vite/src/node/server Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -361,11 +361,13 @@ function propagateUpdate(
361
361
* @param nodeChain The chain of nodes/imports that lead to the node.
362
362
* (The last node in the chain imports the `node` parameter)
363
363
* @param currentChain The current chain tracked from the `node` parameter
364
+ * @param traversedModules The set of modules that have traversed
364
365
*/
365
366
function isNodeWithinCircularImports (
366
367
node : ModuleNode ,
367
368
nodeChain : ModuleNode [ ] ,
368
369
currentChain : ModuleNode [ ] = [ node ] ,
370
+ traversedModules = new Set < ModuleNode > ( ) ,
369
371
) : HasDeadEnd {
370
372
// To help visualize how each parameters work, imagine this import graph:
371
373
//
@@ -383,6 +385,11 @@ function isNodeWithinCircularImports(
383
385
// It works by checking if any `node` importers are within `nodeChain`, which
384
386
// means there's an import loop with a HMR-accepted module in it.
385
387
388
+ if ( traversedModules . has ( node ) ) {
389
+ return false
390
+ }
391
+ traversedModules . add ( node )
392
+
386
393
for ( const importer of node . importers ) {
387
394
// Node may import itself which is safe
388
395
if ( importer === node ) continue
@@ -416,6 +423,7 @@ function isNodeWithinCircularImports(
416
423
importer ,
417
424
nodeChain ,
418
425
currentChain . concat ( importer ) ,
426
+ traversedModules ,
419
427
)
420
428
if ( result ) return result
421
429
}
You can’t perform that action at this time.
0 commit comments