Skip to content

Commit cc428df

Browse files
committed
Fix CJS resolution infinite loop
1 parent 10bb023 commit cc428df

File tree

3 files changed

+416
-6
lines changed

3 files changed

+416
-6
lines changed

packages/core/src/internal/esm/cjsResolve.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,12 @@ function* nodeModulesPaths(path: URL) {
177177
return;
178178
}
179179
do {
180-
// a. if PARTS[I] = "node_modules" CONTINUE
181-
if (path.pathname.endsWith("/node_modules/")) {
182-
continue;
180+
// a. if PARTS[I] = "node_modules", GOTO d.
181+
if (!path.pathname.endsWith("/node_modules/")) {
182+
// b. DIR = path join(PARTS[0 .. I] + "node_modules")
183+
// c. DIRS = DIR + DIRS
184+
yield new URL("./node_modules/", path);
183185
}
184-
// b. DIR = path join(PARTS[0 .. I] + "node_modules")
185-
yield new URL("./node_modules/", path);
186-
// c. DIRS = DIR + DIRS
187186
// d. let I = I - 1
188187
path = new URL("../", path);
189188
} while (path.pathname !== "/");
Binary file not shown.

0 commit comments

Comments
 (0)