@vercel/microfrontends 1.2.1 → 1.2.3

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.
@@ -219,19 +219,29 @@ function findPackageWithMicrofrontendsConfig({
219
219
  const microfrontendsJson = parse(microfrontendsJsonContent);
220
220
  if (microfrontendsJson.applications[applicationName]) {
221
221
  matchingPaths.push(microfrontendsJsonPath);
222
+ } else {
223
+ for (const [_, app] of Object.entries(
224
+ microfrontendsJson.applications
225
+ )) {
226
+ if (app.packageName === applicationName) {
227
+ matchingPaths.push(microfrontendsJsonPath);
228
+ }
229
+ }
222
230
  }
223
231
  } catch (error) {
224
232
  }
225
233
  }
226
234
  if (matchingPaths.length > 1) {
227
- throw new Error(
235
+ throw new MicrofrontendError(
228
236
  `Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
229
- ${matchingPaths.join("\n \u2022 ")}`
237
+ ${matchingPaths.join("\n \u2022 ")}`,
238
+ { type: "config", subtype: "inference_failed" }
230
239
  );
231
240
  }
232
241
  if (matchingPaths.length === 0) {
233
- throw new Error(
234
- `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`
242
+ throw new MicrofrontendError(
243
+ `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`,
244
+ { type: "config", subtype: "inference_failed" }
235
245
  );
236
246
  }
237
247
  const [packageJsonPath] = matchingPaths;
@@ -247,8 +257,9 @@ function inferMicrofrontendsLocation(opts) {
247
257
  }
248
258
  const result = findPackageWithMicrofrontendsConfig(opts);
249
259
  if (!result) {
250
- throw new Error(
251
- `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`
260
+ throw new MicrofrontendError(
261
+ `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`,
262
+ { type: "config", subtype: "inference_failed" }
252
263
  );
253
264
  }
254
265
  configCache[cacheKey] = result;
@@ -1376,15 +1387,17 @@ var MicrofrontendsServer = class {
1376
1387
  });
1377
1388
  }
1378
1389
  }
1379
- throw new Error(
1380
- "Unable to automatically infer the location of the `microfrontends.json` file. Microfrontends defined in separate repositories are not supported yet. If you suspect this is thrown in error, please reach out to the Vercel team."
1390
+ throw new MicrofrontendError(
1391
+ "Unable to automatically infer the location of the `microfrontends.json` file. Microfrontends defined in separate repositories are not supported yet. If you suspect this is thrown in error, please reach out to the Vercel team.",
1392
+ { type: "config", subtype: "inference_failed" }
1381
1393
  );
1382
1394
  } catch (e) {
1383
1395
  if (e instanceof MicrofrontendError) {
1384
1396
  throw e;
1385
1397
  }
1398
+ const errorMessage = e instanceof Error ? e.message : String(e);
1386
1399
  throw new MicrofrontendError(
1387
- "Unable to locate and parse the `microfrontends.json` configuration file.",
1400
+ `Unable to locate and parse the \`microfrontends.json\` configuration file. Original error message: ${errorMessage}`,
1388
1401
  { cause: e, type: "config", subtype: "inference_failed" }
1389
1402
  );
1390
1403
  }