@module-federation/vite 1.21.3 → 1.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -363,7 +363,6 @@ function resolveInstalledPackageJson(pkg, cwd, packageName, opts) {
363
363
  };
364
364
  const findPackageInPnpmStore = (startDir) => {
365
365
  let currentDir = startDir;
366
- const rootDir = path$1.parse(currentDir).root;
367
366
  while (true) {
368
367
  const pnpmStoreDir = path$1.join(currentDir, "node_modules", ".pnpm");
369
368
  if (existsSync(pnpmStoreDir)) try {
@@ -373,21 +372,26 @@ function resolveInstalledPackageJson(pkg, cwd, packageName, opts) {
373
372
  if (candidate?.packageJson.name === packageName) return candidate;
374
373
  }
375
374
  } catch {}
376
- if (currentDir === rootDir) break;
377
- currentDir = path$1.dirname(currentDir);
375
+ const parentDir = path$1.dirname(currentDir);
376
+ if (parentDir === currentDir) break;
377
+ currentDir = parentDir;
378
378
  }
379
379
  };
380
+ let resolvedPath;
380
381
  try {
381
382
  const projectRequire = createRequire(pathToFileURL(path$1.join(cwd, "package.json")));
382
- let resolvedPath;
383
383
  if (opts?.fromResolvedEntry) resolvedPath = opts.fromResolvedEntry;
384
384
  else try {
385
385
  resolvedPath = projectRequire.resolve(pkg);
386
386
  } catch {
387
387
  resolvedPath = projectRequire.resolve(packageName);
388
388
  }
389
+ } catch {
390
+ resolvedPath = void 0;
391
+ }
392
+ if (resolvedPath !== void 0 && !path$1.isAbsolute(resolvedPath)) resolvedPath = void 0;
393
+ if (resolvedPath !== void 0) try {
389
394
  let currentDir = path$1.dirname(resolvedPath);
390
- const rootDir = path$1.parse(currentDir).root;
391
395
  let matchingPackage;
392
396
  while (true) {
393
397
  const packageJsonPath = path$1.join(currentDir, "package.json");
@@ -408,21 +412,21 @@ function resolveInstalledPackageJson(pkg, cwd, packageName, opts) {
408
412
  if (!(error instanceof SyntaxError)) throw error;
409
413
  }
410
414
  }
411
- if (currentDir === rootDir) break;
412
- currentDir = path$1.dirname(currentDir);
415
+ const parentDir = path$1.dirname(currentDir);
416
+ if (parentDir === currentDir) break;
417
+ currentDir = parentDir;
413
418
  }
414
419
  return matchingPackage;
415
- } catch {
416
- let currentDir = cwd;
417
- const rootDir = path$1.parse(currentDir).root;
418
- while (true) {
419
- const directCandidate = tryReadPackageJson(path$1.join(currentDir, "node_modules", packageName, "package.json"));
420
- if (directCandidate?.packageJson.name === packageName) return directCandidate;
421
- if (currentDir === rootDir) break;
422
- currentDir = path$1.dirname(currentDir);
423
- }
424
- return findPackageInPnpmStore(cwd);
420
+ } catch {}
421
+ let currentDir = cwd;
422
+ while (true) {
423
+ const directCandidate = tryReadPackageJson(path$1.join(currentDir, "node_modules", packageName, "package.json"));
424
+ if (directCandidate?.packageJson.name === packageName) return directCandidate;
425
+ const parentDir = path$1.dirname(currentDir);
426
+ if (parentDir === currentDir) break;
427
+ currentDir = parentDir;
425
428
  }
429
+ return findPackageInPnpmStore(cwd);
426
430
  }
427
431
  function getInstalledPackageEntry(pkg, opts) {
428
432
  const installed = getInstalledPackageJson(pkg, opts);