Skip to content

Commit 8842539

Browse files
committed
Fix entry file dependency logic
1 parent 193ea8a commit 8842539

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/react-router-dev/config/config.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,19 @@ function findEntry(
841841
function isEntryFileDependency(
842842
moduleGraph: Vite.ModuleGraph,
843843
entryFilepath: string,
844-
filepath: string
844+
filepath: string,
845+
visited = new Set<string>()
845846
): boolean {
846847
// Ensure normalized paths
847848
entryFilepath = Path.normalize(entryFilepath);
848849
filepath = Path.normalize(filepath);
849850

851+
if (visited.has(filepath)) {
852+
return false;
853+
}
854+
855+
visited.add(filepath);
856+
850857
if (filepath === entryFilepath) {
851858
return true;
852859
}
@@ -857,8 +864,16 @@ function isEntryFileDependency(
857864
return false;
858865
}
859866

867+
// Recursively check all importers to see if any of them are the entry file
860868
for (let importer of mod.importers) {
861-
if (importer.id === entryFilepath) {
869+
if (!importer.id) {
870+
continue;
871+
}
872+
873+
if (
874+
importer.id === entryFilepath ||
875+
isEntryFileDependency(moduleGraph, entryFilepath, importer.id, visited)
876+
) {
862877
return true;
863878
}
864879
}

0 commit comments

Comments
 (0)