@vercel/microfrontends 1.2.1 → 1.2.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.
package/dist/bin/cli.cjs CHANGED
@@ -30,7 +30,7 @@ var import_env = require("@next/env");
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "@vercel/microfrontends",
33
- version: "1.2.1",
33
+ version: "1.2.2",
34
34
  private: false,
35
35
  description: "Defines configuration and utilities for microfrontends development",
36
36
  keywords: [
@@ -1103,19 +1103,29 @@ function findPackageWithMicrofrontendsConfig({
1103
1103
  const microfrontendsJson = (0, import_jsonc_parser2.parse)(microfrontendsJsonContent);
1104
1104
  if (microfrontendsJson.applications[applicationName]) {
1105
1105
  matchingPaths.push(microfrontendsJsonPath);
1106
+ } else {
1107
+ for (const [_, app] of Object.entries(
1108
+ microfrontendsJson.applications
1109
+ )) {
1110
+ if (app.packageName === applicationName) {
1111
+ matchingPaths.push(microfrontendsJsonPath);
1112
+ }
1113
+ }
1106
1114
  }
1107
1115
  } catch (error) {
1108
1116
  }
1109
1117
  }
1110
1118
  if (matchingPaths.length > 1) {
1111
- throw new Error(
1119
+ throw new MicrofrontendError(
1112
1120
  `Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
1113
- ${matchingPaths.join("\n \u2022 ")}`
1121
+ ${matchingPaths.join("\n \u2022 ")}`,
1122
+ { type: "config", subtype: "inference_failed" }
1114
1123
  );
1115
1124
  }
1116
1125
  if (matchingPaths.length === 0) {
1117
- throw new Error(
1118
- `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`
1126
+ throw new MicrofrontendError(
1127
+ `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`,
1128
+ { type: "config", subtype: "inference_failed" }
1119
1129
  );
1120
1130
  }
1121
1131
  const [packageJsonPath] = matchingPaths;
@@ -1131,8 +1141,9 @@ function inferMicrofrontendsLocation(opts) {
1131
1141
  }
1132
1142
  const result = findPackageWithMicrofrontendsConfig(opts);
1133
1143
  if (!result) {
1134
- throw new Error(
1135
- `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`
1144
+ throw new MicrofrontendError(
1145
+ `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`,
1146
+ { type: "config", subtype: "inference_failed" }
1136
1147
  );
1137
1148
  }
1138
1149
  configCache[cacheKey] = result;
@@ -1618,15 +1629,17 @@ var MicrofrontendsServer = class {
1618
1629
  });
1619
1630
  }
1620
1631
  }
1621
- throw new Error(
1622
- "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."
1632
+ throw new MicrofrontendError(
1633
+ "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.",
1634
+ { type: "config", subtype: "inference_failed" }
1623
1635
  );
1624
1636
  } catch (e) {
1625
1637
  if (e instanceof MicrofrontendError) {
1626
1638
  throw e;
1627
1639
  }
1640
+ const errorMessage = e instanceof Error ? e.message : String(e);
1628
1641
  throw new MicrofrontendError(
1629
- "Unable to locate and parse the `microfrontends.json` configuration file.",
1642
+ `Unable to locate and parse the \`microfrontends.json\` configuration file. Original error message: ${errorMessage}`,
1630
1643
  { cause: e, type: "config", subtype: "inference_failed" }
1631
1644
  );
1632
1645
  }
@@ -255,19 +255,29 @@ function findPackageWithMicrofrontendsConfig({
255
255
  const microfrontendsJson = (0, import_jsonc_parser.parse)(microfrontendsJsonContent);
256
256
  if (microfrontendsJson.applications[applicationName]) {
257
257
  matchingPaths.push(microfrontendsJsonPath);
258
+ } else {
259
+ for (const [_, app] of Object.entries(
260
+ microfrontendsJson.applications
261
+ )) {
262
+ if (app.packageName === applicationName) {
263
+ matchingPaths.push(microfrontendsJsonPath);
264
+ }
265
+ }
258
266
  }
259
267
  } catch (error) {
260
268
  }
261
269
  }
262
270
  if (matchingPaths.length > 1) {
263
- throw new Error(
271
+ throw new MicrofrontendError(
264
272
  `Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
265
- ${matchingPaths.join("\n \u2022 ")}`
273
+ ${matchingPaths.join("\n \u2022 ")}`,
274
+ { type: "config", subtype: "inference_failed" }
266
275
  );
267
276
  }
268
277
  if (matchingPaths.length === 0) {
269
- throw new Error(
270
- `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`
278
+ throw new MicrofrontendError(
279
+ `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`,
280
+ { type: "config", subtype: "inference_failed" }
271
281
  );
272
282
  }
273
283
  const [packageJsonPath] = matchingPaths;
@@ -283,8 +293,9 @@ function inferMicrofrontendsLocation(opts) {
283
293
  }
284
294
  const result = findPackageWithMicrofrontendsConfig(opts);
285
295
  if (!result) {
286
- throw new Error(
287
- `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`
296
+ throw new MicrofrontendError(
297
+ `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`,
298
+ { type: "config", subtype: "inference_failed" }
288
299
  );
289
300
  }
290
301
  configCache[cacheKey] = result;
@@ -1412,15 +1423,17 @@ var MicrofrontendsServer = class {
1412
1423
  });
1413
1424
  }
1414
1425
  }
1415
- throw new Error(
1416
- "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."
1426
+ throw new MicrofrontendError(
1427
+ "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.",
1428
+ { type: "config", subtype: "inference_failed" }
1417
1429
  );
1418
1430
  } catch (e) {
1419
1431
  if (e instanceof MicrofrontendError) {
1420
1432
  throw e;
1421
1433
  }
1434
+ const errorMessage = e instanceof Error ? e.message : String(e);
1422
1435
  throw new MicrofrontendError(
1423
- "Unable to locate and parse the `microfrontends.json` configuration file.",
1436
+ `Unable to locate and parse the \`microfrontends.json\` configuration file. Original error message: ${errorMessage}`,
1424
1437
  { cause: e, type: "config", subtype: "inference_failed" }
1425
1438
  );
1426
1439
  }