@vercel/microfrontends 1.4.0-canary.4 → 1.4.0-canary.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @vercel/microfrontends
2
2
 
3
+ ## 1.4.0-canary.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 3797824: Automatically infer location of microfrontends.json in .vercel directory for polyrepo support.
8
+
3
9
  ## 1.4.0-canary.2
4
10
 
5
11
  ### Minor Changes
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.4.0-canary.4",
33
+ version: "1.4.0-canary.6",
34
34
  private: false,
35
35
  description: "Defines configuration and utilities for microfrontends development",
36
36
  keywords: [
@@ -1133,7 +1133,7 @@ ${matchingPaths.join("\n \u2022 ")}`,
1133
1133
  }
1134
1134
  if (matchingPaths.length === 0) {
1135
1135
  throw new MicrofrontendError(
1136
- `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`,
1136
+ `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable. If you suspect this is thrown in error, please reach out to the Vercel team.`,
1137
1137
  { type: "config", subtype: "inference_failed" }
1138
1138
  );
1139
1139
  }
@@ -1625,21 +1625,43 @@ var MicrofrontendsServer = class {
1625
1625
  }
1626
1626
  const repositoryRoot = findRepositoryRoot();
1627
1627
  const isMonorepo2 = isMonorepo({ repositoryRoot });
1628
- if (isMonorepo2) {
1629
- const defaultPackage = inferMicrofrontendsLocation({
1630
- repositoryRoot,
1631
- applicationName: appName
1628
+ if (typeof process.env.VC_MICROFRONTENDS_CONFIG === "string") {
1629
+ const maybeConfigFromEnv = (0, import_node_path8.resolve)(
1630
+ packageRoot,
1631
+ process.env.VC_MICROFRONTENDS_CONFIG
1632
+ );
1633
+ if (maybeConfigFromEnv) {
1634
+ return MicrofrontendsServer.fromFile({
1635
+ filePath: maybeConfigFromEnv,
1636
+ cookies
1637
+ });
1638
+ }
1639
+ } else {
1640
+ const maybeConfigFromVercel = findConfig({
1641
+ dir: (0, import_node_path8.join)(packageRoot, ".vercel")
1632
1642
  });
1633
- const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
1634
- if (maybeConfigFromDefault) {
1643
+ if (maybeConfigFromVercel) {
1635
1644
  return MicrofrontendsServer.fromFile({
1636
- filePath: maybeConfigFromDefault,
1645
+ filePath: maybeConfigFromVercel,
1637
1646
  cookies
1638
1647
  });
1639
1648
  }
1649
+ if (isMonorepo2) {
1650
+ const defaultPackage = inferMicrofrontendsLocation({
1651
+ repositoryRoot,
1652
+ applicationName: appName
1653
+ });
1654
+ const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
1655
+ if (maybeConfigFromDefault) {
1656
+ return MicrofrontendsServer.fromFile({
1657
+ filePath: maybeConfigFromDefault,
1658
+ cookies
1659
+ });
1660
+ }
1661
+ }
1640
1662
  }
1641
1663
  throw new MicrofrontendError(
1642
- "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.",
1664
+ 'Unable to automatically infer the location of the `microfrontends.json` file. If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable. If you suspect this is thrown in error, please reach out to the Vercel team.',
1643
1665
  { type: "config", subtype: "inference_failed" }
1644
1666
  );
1645
1667
  } catch (e) {
@@ -276,7 +276,7 @@ ${matchingPaths.join("\n \u2022 ")}`,
276
276
  }
277
277
  if (matchingPaths.length === 0) {
278
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.`,
279
+ `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable. If you suspect this is thrown in error, please reach out to the Vercel team.`,
280
280
  { type: "config", subtype: "inference_failed" }
281
281
  );
282
282
  }
@@ -1423,21 +1423,43 @@ var MicrofrontendsServer = class {
1423
1423
  }
1424
1424
  const repositoryRoot = findRepositoryRoot();
1425
1425
  const isMonorepo2 = isMonorepo({ repositoryRoot });
1426
- if (isMonorepo2) {
1427
- const defaultPackage = inferMicrofrontendsLocation({
1428
- repositoryRoot,
1429
- applicationName: appName
1426
+ if (typeof process.env.VC_MICROFRONTENDS_CONFIG === "string") {
1427
+ const maybeConfigFromEnv = (0, import_node_path8.resolve)(
1428
+ packageRoot,
1429
+ process.env.VC_MICROFRONTENDS_CONFIG
1430
+ );
1431
+ if (maybeConfigFromEnv) {
1432
+ return MicrofrontendsServer.fromFile({
1433
+ filePath: maybeConfigFromEnv,
1434
+ cookies
1435
+ });
1436
+ }
1437
+ } else {
1438
+ const maybeConfigFromVercel = findConfig({
1439
+ dir: (0, import_node_path8.join)(packageRoot, ".vercel")
1430
1440
  });
1431
- const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
1432
- if (maybeConfigFromDefault) {
1441
+ if (maybeConfigFromVercel) {
1433
1442
  return MicrofrontendsServer.fromFile({
1434
- filePath: maybeConfigFromDefault,
1443
+ filePath: maybeConfigFromVercel,
1435
1444
  cookies
1436
1445
  });
1437
1446
  }
1447
+ if (isMonorepo2) {
1448
+ const defaultPackage = inferMicrofrontendsLocation({
1449
+ repositoryRoot,
1450
+ applicationName: appName
1451
+ });
1452
+ const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
1453
+ if (maybeConfigFromDefault) {
1454
+ return MicrofrontendsServer.fromFile({
1455
+ filePath: maybeConfigFromDefault,
1456
+ cookies
1457
+ });
1458
+ }
1459
+ }
1438
1460
  }
1439
1461
  throw new MicrofrontendError(
1440
- "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.",
1462
+ 'Unable to automatically infer the location of the `microfrontends.json` file. If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable. If you suspect this is thrown in error, please reach out to the Vercel team.',
1441
1463
  { type: "config", subtype: "inference_failed" }
1442
1464
  );
1443
1465
  } catch (e) {