@vercel/microfrontends 1.4.0 → 1.4.2

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.
@@ -172,17 +172,27 @@ function hasGitDirectory(dir) {
172
172
  function hasPnpmWorkspaces(dir) {
173
173
  return fs.existsSync(path.join(dir, "pnpm-workspace.yaml"));
174
174
  }
175
+ function hasPackageJson(dir) {
176
+ return fs.existsSync(path.join(dir, "package.json"));
177
+ }
175
178
  function findRepositoryRoot(startDir) {
176
179
  if (process.env.NX_WORKSPACE_ROOT) {
177
180
  return process.env.NX_WORKSPACE_ROOT;
178
181
  }
179
182
  let currentDir = startDir || process.cwd();
183
+ let lastPackageJsonDir = null;
180
184
  while (currentDir !== path.parse(currentDir).root) {
181
185
  if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
182
186
  return currentDir;
183
187
  }
188
+ if (hasPackageJson(currentDir)) {
189
+ lastPackageJsonDir = currentDir;
190
+ }
184
191
  currentDir = path.dirname(currentDir);
185
192
  }
193
+ if (lastPackageJsonDir) {
194
+ return lastPackageJsonDir;
195
+ }
186
196
  throw new Error(
187
197
  `Could not find the root of the repository for ${startDir}. Please ensure that the directory is part of a Git repository. If you suspect that this should work, please file an issue to the Vercel team.`
188
198
  );