@vercel/microfrontends 2.1.2 → 2.2.0

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +4 -0
  3. package/dist/bin/cli.cjs +125 -89
  4. package/dist/config.d.ts +2 -2
  5. package/dist/experimental/sveltekit.cjs +97 -62
  6. package/dist/experimental/sveltekit.cjs.map +1 -1
  7. package/dist/experimental/sveltekit.d.ts +6 -0
  8. package/dist/experimental/sveltekit.js +97 -62
  9. package/dist/experimental/sveltekit.js.map +1 -1
  10. package/dist/experimental/vite.cjs +96 -65
  11. package/dist/experimental/vite.cjs.map +1 -1
  12. package/dist/experimental/vite.js +96 -65
  13. package/dist/experimental/vite.js.map +1 -1
  14. package/dist/microfrontends/server.cjs +92 -59
  15. package/dist/microfrontends/server.cjs.map +1 -1
  16. package/dist/microfrontends/server.d.ts +2 -2
  17. package/dist/microfrontends/server.js +92 -59
  18. package/dist/microfrontends/server.js.map +1 -1
  19. package/dist/microfrontends/utils.cjs +3 -3
  20. package/dist/microfrontends/utils.cjs.map +1 -1
  21. package/dist/microfrontends/utils.d.ts +1 -1
  22. package/dist/microfrontends/utils.js +3 -3
  23. package/dist/microfrontends/utils.js.map +1 -1
  24. package/dist/next/config.cjs +133 -115
  25. package/dist/next/config.cjs.map +1 -1
  26. package/dist/next/config.d.ts +11 -1
  27. package/dist/next/config.js +133 -115
  28. package/dist/next/config.js.map +1 -1
  29. package/dist/next/middleware.cjs +35 -17
  30. package/dist/next/middleware.cjs.map +1 -1
  31. package/dist/next/middleware.js +35 -17
  32. package/dist/next/middleware.js.map +1 -1
  33. package/dist/next/testing.d.ts +2 -2
  34. package/dist/overrides.d.ts +3 -3
  35. package/dist/schema.d.ts +2 -2
  36. package/dist/{types-88602303.d.ts → types-b9ea41b2.d.ts} +1 -1
  37. package/dist/{types-e7523e61.d.ts → types-dcd8b17a.d.ts} +71 -24
  38. package/dist/utils/mfe-port.cjs +92 -59
  39. package/dist/utils/mfe-port.cjs.map +1 -1
  40. package/dist/utils/mfe-port.js +92 -59
  41. package/dist/utils/mfe-port.js.map +1 -1
  42. package/dist/validation.cjs +47 -38
  43. package/dist/validation.cjs.map +1 -1
  44. package/dist/validation.d.ts +1 -1
  45. package/dist/validation.js +47 -38
  46. package/dist/validation.js.map +1 -1
  47. package/package.json +1 -1
  48. package/schema/schema.json +47 -38
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @vercel/microfrontends
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 966b2e9: Two improvements to the local development proxy:
8
+
9
+ - Make routing logging less noisy by default. Logging can be added by setting the `MFE_DEBUG` env var or `debug` option. This information is printed in an info message on dev server startup.
10
+ - Always route requests to the local proxy when the local development proxy is running through Turborepo. The logic has been simplified. Users who are running the proxy manually can set the `TURBO_TASK_HAS_MFE_PROXY` env var to `true` when running.
11
+
12
+ In addition, we are deprecating two options in `withMicrofrontends` for configuring microfrontends:
13
+
14
+ - Deprecate the `configPath` option as `VC_MICROFRONTENDS_CONFIG_FILE_NAME` supersedes it.
15
+ - Deprecate `isProduction`. The application will be treated as non-production if the local turbo proxy is running by detecting the `TURBO_TASK_HAS_MFE_PROXY` env var which Turborepo sets to `true`.
16
+
17
+ ## 2.1.3
18
+
19
+ ### Patch Changes
20
+
21
+ - 93506f2: Fix Next.js image optimization locally for any image path
22
+
3
23
  ## 2.1.2
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -9,6 +9,10 @@ Split apart large applications and develop faster with microfrontends. This pack
9
9
 
10
10
  See the [full documentation](https://vercel.com/docs/microfrontends) and [examples](https://vercel.com/templates/microfrontends) to learn more.
11
11
 
12
+ ## Changelog
13
+
14
+ See the [changelog](./packages/microfrontends/CHANGELOG.md) for a list of changes.
15
+
12
16
  ## Getting Started
13
17
 
14
18
  Follow the [quickstart](https://vercel.com/docs/microfrontends/quickstart) documentation to get started.
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: "2.1.2",
33
+ version: "2.2.0",
34
34
  private: false,
35
35
  description: "Defines configuration and utilities for microfrontends development",
36
36
  keywords: [
@@ -1119,8 +1119,8 @@ var import_fast_glob = __toESM(require("fast-glob"), 1);
1119
1119
 
1120
1120
  // src/config/microfrontends/utils/get-config-file-name.ts
1121
1121
  var DEFAULT_CONFIGURATION_FILENAMES = [
1122
- "microfrontends.jsonc",
1123
- "microfrontends.json"
1122
+ "microfrontends.json",
1123
+ "microfrontends.jsonc"
1124
1124
  ];
1125
1125
  function getPossibleConfigurationFilenames({
1126
1126
  customConfigFilename
@@ -1128,7 +1128,7 @@ function getPossibleConfigurationFilenames({
1128
1128
  if (customConfigFilename) {
1129
1129
  if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
1130
1130
  throw new Error(
1131
- `The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
1131
+ `Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}. The file name must end with '.json' or '.jsonc'. It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`
1132
1132
  );
1133
1133
  }
1134
1134
  return Array.from(
@@ -1176,7 +1176,7 @@ function findPackageWithMicrofrontendsConfig({
1176
1176
  }
1177
1177
  }
1178
1178
  }
1179
- } catch (error) {
1179
+ } catch (error2) {
1180
1180
  }
1181
1181
  }
1182
1182
  if (matchingPaths.length > 1) {
@@ -1212,9 +1212,9 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
1212
1212
  }
1213
1213
  const [packageJsonPath] = matchingPaths;
1214
1214
  return (0, import_node_path2.dirname)(packageJsonPath);
1215
- } catch (error) {
1216
- if (error instanceof MicrofrontendError) {
1217
- throw error;
1215
+ } catch (error2) {
1216
+ if (error2 instanceof MicrofrontendError) {
1217
+ throw error2;
1218
1218
  }
1219
1219
  return null;
1220
1220
  }
@@ -1238,6 +1238,30 @@ function inferMicrofrontendsLocation(opts) {
1238
1238
  // src/config/microfrontends/utils/is-monorepo.ts
1239
1239
  var import_node_fs3 = __toESM(require("fs"), 1);
1240
1240
  var import_node_path3 = __toESM(require("path"), 1);
1241
+
1242
+ // src/bin/logger.ts
1243
+ function debug(...args) {
1244
+ if (process.env.MFE_DEBUG) {
1245
+ console.log(...args);
1246
+ }
1247
+ }
1248
+ function info(...args) {
1249
+ console.log(...args);
1250
+ }
1251
+ function warn(...args) {
1252
+ console.warn(...args);
1253
+ }
1254
+ function error(...args) {
1255
+ console.error(...args);
1256
+ }
1257
+ var logger = {
1258
+ debug,
1259
+ info,
1260
+ warn,
1261
+ error
1262
+ };
1263
+
1264
+ // src/config/microfrontends/utils/is-monorepo.ts
1241
1265
  function isMonorepo({
1242
1266
  repositoryRoot
1243
1267
  }) {
@@ -1259,8 +1283,8 @@ function isMonorepo({
1259
1283
  import_node_fs3.default.readFileSync(packageJsonPath, "utf-8")
1260
1284
  );
1261
1285
  return packageJson.workspaces !== void 0;
1262
- } catch (error) {
1263
- console.error("Error determining if repository is a monorepo", error);
1286
+ } catch (error2) {
1287
+ logger.error("Error determining if repository is a monorepo", error2);
1264
1288
  return false;
1265
1289
  }
1266
1290
  }
@@ -1383,38 +1407,28 @@ var schema_default = {
1383
1407
  type: "object",
1384
1408
  properties: {
1385
1409
  $schema: {
1386
- type: "string"
1410
+ type: "string",
1411
+ description: "See https://openapi.vercel.sh/microfrontends.json."
1387
1412
  },
1388
1413
  version: {
1389
1414
  type: "string",
1390
- const: "1"
1391
- },
1392
- options: {
1393
- $ref: "#/definitions/Options"
1415
+ const: "1",
1416
+ description: "The version of the microfrontends config schema."
1394
1417
  },
1395
1418
  applications: {
1396
1419
  $ref: "#/definitions/ApplicationRouting",
1397
- description: "Mapping of application names to the routes that they host. Only needs to be defined in the application that owns the primary microfrontend domain"
1420
+ description: "Mapping of Vercel project names to their microfrontend configurations."
1421
+ },
1422
+ options: {
1423
+ $ref: "#/definitions/Options",
1424
+ description: "Optional configuration options for the microfrontend."
1398
1425
  }
1399
1426
  },
1400
1427
  required: [
1401
1428
  "applications"
1402
1429
  ],
1403
- additionalProperties: false
1404
- },
1405
- Options: {
1406
- type: "object",
1407
- properties: {
1408
- disableOverrides: {
1409
- type: "boolean",
1410
- description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
1411
- },
1412
- localProxyPort: {
1413
- type: "number",
1414
- description: "The port number used by the local proxy server.\n\nThe default is `3024`."
1415
- }
1416
- },
1417
- additionalProperties: false
1430
+ additionalProperties: false,
1431
+ description: "The microfrontends configuration schema. See https://vercel.com/docs/microfrontends/configuration."
1418
1432
  },
1419
1433
  ApplicationRouting: {
1420
1434
  type: "object",
@@ -1422,8 +1436,9 @@ var schema_default = {
1422
1436
  $ref: "#/definitions/Application"
1423
1437
  },
1424
1438
  propertyNames: {
1425
- description: "The unique identifier for a Microfrontend Application.\n\nMust match the Vercel project name.\n\nNote: If this name does not also match the name used to run the application, (e.g. the `name` from the `package.json`), then the `packageName` field should be set."
1426
- }
1439
+ description: "The Vercel project name of the microfrontend application.\n\nNote: If this name does not also match the name `name` from the `package.json`, set `packageName` with the name used in `package.json`.\n\nSee https://vercel.com/docs/microfrontends/configuration#application-naming."
1440
+ },
1441
+ description: "Mapping of Vercel project names to their microfrontend configurations."
1427
1442
  },
1428
1443
  Application: {
1429
1444
  anyOf: [
@@ -1433,14 +1448,15 @@ var schema_default = {
1433
1448
  {
1434
1449
  $ref: "#/definitions/ChildApplication"
1435
1450
  }
1436
- ]
1451
+ ],
1452
+ description: "The configuration for a microfrontend application. There must always be one default application."
1437
1453
  },
1438
1454
  DefaultApplication: {
1439
1455
  type: "object",
1440
1456
  properties: {
1441
1457
  packageName: {
1442
1458
  type: "string",
1443
- description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
1459
+ description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`.\n\nSee https://vercel.com/docs/microfrontends/configuration#application-naming."
1444
1460
  },
1445
1461
  development: {
1446
1462
  $ref: "#/definitions/DefaultDevelopment",
@@ -1460,15 +1476,15 @@ var schema_default = {
1460
1476
  "number",
1461
1477
  "string"
1462
1478
  ],
1463
- description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1479
+ description: "A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\n\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\n\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\n\nSee https://vercel.com/docs/microfrontends/local-development."
1464
1480
  },
1465
1481
  task: {
1466
1482
  type: "string",
1467
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1483
+ description: 'The task to run when starting the development server. Should reference a script in the package.json of the application.\n\nThe default value is "dev".\n\nSee https://vercel.com/docs/microfrontends/local-development.'
1468
1484
  },
1469
1485
  fallback: {
1470
1486
  type: "string",
1471
- description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1487
+ description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\n\nSee https://vercel.com/docs/microfrontends/local-development."
1472
1488
  }
1473
1489
  },
1474
1490
  required: [
@@ -1481,7 +1497,7 @@ var schema_default = {
1481
1497
  properties: {
1482
1498
  packageName: {
1483
1499
  type: "string",
1484
- description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
1500
+ description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`.\n\nSee https://vercel.com/docs/microfrontends/configuration#application-naming."
1485
1501
  },
1486
1502
  development: {
1487
1503
  $ref: "#/definitions/ChildDevelopment",
@@ -1489,11 +1505,11 @@ var schema_default = {
1489
1505
  },
1490
1506
  routing: {
1491
1507
  $ref: "#/definitions/Routing",
1492
- description: "Groups of path expressions that are routed to this application."
1508
+ description: "Groups of path expressions that are routed to this application.\n\nSee https://vercel.com/docs/microfrontends/path-routing."
1493
1509
  },
1494
1510
  assetPrefix: {
1495
1511
  type: "string",
1496
- description: "The name of the asset prefix to use instead of the auto-generated name.\n\nThe asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain.\n\nAn auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided.\n\nWhen this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field."
1512
+ description: "The name of the asset prefix to use instead of the auto-generated name.\n\nThe asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain.\n\nAn auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided.\n\nWhen this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field.\n\nThe default value is the auto-generated asset prefix of the form `vc-ap-<hash>`.\n\nSee https://vercel.com/docs/microfrontends/path-routing#asset-prefix."
1497
1513
  }
1498
1514
  },
1499
1515
  required: [
@@ -1509,15 +1525,15 @@ var schema_default = {
1509
1525
  "number",
1510
1526
  "string"
1511
1527
  ],
1512
- description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1528
+ description: "A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\n\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\n\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\n\nSee https://vercel.com/docs/microfrontends/local-development."
1513
1529
  },
1514
1530
  task: {
1515
1531
  type: "string",
1516
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1532
+ description: 'The task to run when starting the development server. Should reference a script in the package.json of the application.\n\nThe default value is "dev".\n\nSee https://vercel.com/docs/microfrontends/local-development.'
1517
1533
  },
1518
1534
  fallback: {
1519
1535
  type: "string",
1520
- description: "Fallback for local development, could point to any environment. This is optional for child apps. If not provided, the fallback of the default app will be used.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1536
+ description: "Fallback for local development, could point to any environment. If not provided for child apps, the fallback of the default app will be used.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\n\nSee https://vercel.com/docs/microfrontends/local-development."
1521
1537
  }
1522
1538
  },
1523
1539
  additionalProperties: false
@@ -1526,29 +1542,46 @@ var schema_default = {
1526
1542
  type: "array",
1527
1543
  items: {
1528
1544
  $ref: "#/definitions/PathGroup"
1529
- }
1545
+ },
1546
+ description: "A list of path groups that are routed to this application."
1530
1547
  },
1531
1548
  PathGroup: {
1532
1549
  type: "object",
1533
1550
  properties: {
1534
1551
  group: {
1535
1552
  type: "string",
1536
- description: "Optional group name for the paths"
1553
+ description: "Group name for the paths."
1537
1554
  },
1538
1555
  flag: {
1539
1556
  type: "string",
1540
- description: "flag name that can be used to enable/disable all paths in the group"
1557
+ description: "The name of the feature flag that controls routing for this group of paths. See https://vercel.com/docs/microfrontends/path-routing#routing-changes-safely-with-flags."
1541
1558
  },
1542
1559
  paths: {
1543
1560
  type: "array",
1544
1561
  items: {
1545
1562
  type: "string"
1546
- }
1563
+ },
1564
+ description: "A list of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions."
1547
1565
  }
1548
1566
  },
1549
1567
  required: [
1550
1568
  "paths"
1551
1569
  ],
1570
+ additionalProperties: false,
1571
+ description: "A group of paths that is routed to this application."
1572
+ },
1573
+ Options: {
1574
+ type: "object",
1575
+ properties: {
1576
+ disableOverrides: {
1577
+ type: "boolean",
1578
+ description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect.\n\nSee https://vercel.com/docs/microfrontends/managing-microfrontends/vercel-toolbar#routing-overrides."
1579
+ },
1580
+ localProxyPort: {
1581
+ type: "number",
1582
+ description: "The port number used by the local proxy server.\n\nThe default value is 3024.\n\nSee https://vercel.com/docs/microfrontends/local-development."
1583
+ }
1584
+ },
1552
1585
  additionalProperties: false
1553
1586
  }
1554
1587
  }
@@ -1567,19 +1600,19 @@ function formatAjvErrors(errors) {
1567
1600
  return [];
1568
1601
  }
1569
1602
  const errorMessages = [];
1570
- for (const error of errors) {
1571
- if (error.instancePath === "" && (error.keyword === "anyOf" || error.keyword === "required" && error.params.missingProperty === "partOf")) {
1603
+ for (const error2 of errors) {
1604
+ if (error2.instancePath === "" && (error2.keyword === "anyOf" || error2.keyword === "required" && error2.params.missingProperty === "partOf")) {
1572
1605
  continue;
1573
1606
  }
1574
- const instancePath = error.instancePath.slice(1);
1607
+ const instancePath = error2.instancePath.slice(1);
1575
1608
  const formattedInstancePath = instancePath === "" ? "at the root" : `in field ${instancePath}`;
1576
- if (error.keyword === "required" && error.params.missingProperty === "routing" && instancePath.split("/").length === 2) {
1609
+ if (error2.keyword === "required" && error2.params.missingProperty === "routing" && instancePath.split("/").length === 2) {
1577
1610
  errorMessages.push(
1578
1611
  `Unable to infer if ${instancePath} is the default app or a child app. This usually means that there is another error in the configuration.`
1579
1612
  );
1580
- } else if (error.keyword === "anyOf" && instancePath.split("/").length > 2) {
1613
+ } else if (error2.keyword === "anyOf" && instancePath.split("/").length > 2) {
1581
1614
  const anyOfErrors = errors.filter(
1582
- (e) => e.instancePath === error.instancePath && e.keyword !== "anyOf"
1615
+ (e) => e.instancePath === error2.instancePath && e.keyword !== "anyOf"
1583
1616
  );
1584
1617
  if (anyOfErrors.every((e) => e.keyword === "type")) {
1585
1618
  const allowedTypes = LIST_FORMATTER2.format(
@@ -1595,13 +1628,13 @@ function formatAjvErrors(errors) {
1595
1628
  `Invalid field for ${instancePath}. Possible error messages are ${LIST_FORMATTER2.format(anyOfErrors.map((e) => e.message ?? ""))}`
1596
1629
  );
1597
1630
  }
1598
- } else if (error.keyword === "additionalProperties" && !(error.params.additionalProperty === "routing" && instancePath.split("/").length === 2)) {
1631
+ } else if (error2.keyword === "additionalProperties" && !(error2.params.additionalProperty === "routing" && instancePath.split("/").length === 2)) {
1599
1632
  errorMessages.push(
1600
- `Property '${error.params.additionalProperty}' is not allowed ${formattedInstancePath}`
1633
+ `Property '${error2.params.additionalProperty}' is not allowed ${formattedInstancePath}`
1601
1634
  );
1602
- } else if (error.keyword === "required") {
1635
+ } else if (error2.keyword === "required") {
1603
1636
  errorMessages.push(
1604
- `Property '${error.params.missingProperty}' is required ${formattedInstancePath}`
1637
+ `Property '${error2.params.missingProperty}' is required ${formattedInstancePath}`
1605
1638
  );
1606
1639
  }
1607
1640
  }
@@ -1614,8 +1647,8 @@ function validateSchema(configString) {
1614
1647
  const isValid = validate(parsedConfig);
1615
1648
  if (!isValid) {
1616
1649
  throw new MicrofrontendError(
1617
- `Invalid microfrontends config:${formatAjvErrors(validate.errors).map((error) => `
1618
- - ${error}`).join(
1650
+ `Invalid microfrontends config:${formatAjvErrors(validate.errors).map((error2) => `
1651
+ - ${error2}`).join(
1619
1652
  ""
1620
1653
  )}
1621
1654
 
@@ -2293,7 +2326,7 @@ var ProxyRequestRouter = class {
2293
2326
  if (target)
2294
2327
  return target;
2295
2328
  const defaultHost = this.getDefaultHost(config);
2296
- console.log(
2329
+ logger.debug(
2297
2330
  ` ${path7} - Did not match any routes. Routing to default app: ${formatProxyTarget(defaultHost)}`
2298
2331
  );
2299
2332
  return { path: path7, ...defaultHost };
@@ -2310,7 +2343,7 @@ var ProxyRequestRouter = class {
2310
2343
  const target = this.getApplicationTarget(application);
2311
2344
  if (middlewareMfeZone) {
2312
2345
  if (middlewareMfeZone === application.name) {
2313
- console.log(
2346
+ logger.debug(
2314
2347
  ` ${path7} - Routing to ${formatProxyTarget(target)} according to 'x-vercel-mfe-zone' header`
2315
2348
  );
2316
2349
  return { path: path7, ...target };
@@ -2335,19 +2368,19 @@ var ProxyRequestRouter = class {
2335
2368
  } else if (mfeFlagValue === false) {
2336
2369
  continue;
2337
2370
  } else {
2338
- console.log(
2371
+ logger.debug(
2339
2372
  "Routing group is behind flag. Routing to default app to check flag via middleware."
2340
2373
  );
2341
2374
  if (!this.isDefaultAppLocal()) {
2342
2375
  const defaultApp = this.getDefaultHost(this.config);
2343
- console.error(
2376
+ logger.error(
2344
2377
  `'${path7}' is a flagged path, but the default application is not running locally. Using '${defaultApp.hostname}' to handle this request.`
2345
2378
  );
2346
2379
  }
2347
2380
  return null;
2348
2381
  }
2349
2382
  }
2350
- console.log(
2383
+ logger.debug(
2351
2384
  ` ${path7} - Matched ${childPath}. Routing to ${formatProxyTarget(target)}`
2352
2385
  );
2353
2386
  return { path: path7, ...target };
@@ -2356,7 +2389,7 @@ var ProxyRequestRouter = class {
2356
2389
  }
2357
2390
  }
2358
2391
  if (middlewareMfeZone) {
2359
- console.error(
2392
+ logger.error(
2360
2393
  `A request contained 'x-vercel-mfe-zone: ${middlewareMfeZone}', but no application was found with that name.`
2361
2394
  );
2362
2395
  }
@@ -2378,7 +2411,7 @@ var ProxyRequestRouter = class {
2378
2411
  for (const rewrite of rewrites) {
2379
2412
  for (const assetPrefix of assetPrefixes) {
2380
2413
  if ((0, import_path_to_regexp3.pathToRegexp)(`/${assetPrefix}${rewrite}`).test(pathname)) {
2381
- console.log(
2414
+ logger.debug(
2382
2415
  ` ${pathname} - Matched asset prefix. Routing to ${formatProxyTarget(target)}`
2383
2416
  );
2384
2417
  return {
@@ -2410,7 +2443,7 @@ var ProxyRequestRouter = class {
2410
2443
  if (!refererApp) {
2411
2444
  return null;
2412
2445
  }
2413
- console.log(
2446
+ logger.debug(
2414
2447
  ` ${refererURL.pathname} - Routing nextjs stack frame request to ${formatProxyTarget(refererApp)}`
2415
2448
  );
2416
2449
  return {
@@ -2425,13 +2458,13 @@ var ProxyRequestRouter = class {
2425
2458
  }
2426
2459
  const localApp = this.getArbitraryLocalApp();
2427
2460
  if (!localApp) {
2428
- console.error(
2461
+ logger.error(
2429
2462
  ` ${url.pathname} - No locally running application to route request to`
2430
2463
  );
2431
2464
  return null;
2432
2465
  }
2433
2466
  const target = this.getApplicationTarget(localApp);
2434
- console.log(
2467
+ logger.debug(
2435
2468
  ` ${url.pathname} - Routing nextjs source map request to randomly selected local application: ${formatProxyTarget(target)}`
2436
2469
  );
2437
2470
  return {
@@ -2449,7 +2482,7 @@ var ProxyRequestRouter = class {
2449
2482
  }
2450
2483
  const imageUrl = url.searchParams.get("url");
2451
2484
  if (!imageUrl) {
2452
- console.error(
2485
+ logger.error(
2453
2486
  ` ${url.pathname}?${url.search} - No url parameter found in _next/image request`
2454
2487
  );
2455
2488
  return null;
@@ -2464,7 +2497,7 @@ var ProxyRequestRouter = class {
2464
2497
  if (!imageApp) {
2465
2498
  return null;
2466
2499
  }
2467
- console.log(
2500
+ logger.debug(
2468
2501
  ` ${url.pathname}?${url.search} - Routing nextjs image request to ${formatProxyTarget(imageApp)}`
2469
2502
  );
2470
2503
  return {
@@ -2509,7 +2542,7 @@ var LocalProxy = class {
2509
2542
  res.end(
2510
2543
  `Error proxying request to ${formatProxyTarget(target)}. Is the server running locally on port ${target.port}?`
2511
2544
  );
2512
- console.error(
2545
+ logger.error(
2513
2546
  `Error proxying request for ${formatProxyTarget(target)}: `,
2514
2547
  err
2515
2548
  );
@@ -2565,7 +2598,7 @@ var LocalProxy = class {
2565
2598
  headers
2566
2599
  });
2567
2600
  } catch (err) {
2568
- console.error("Error proxying ws: ", err);
2601
+ logger.error("Error proxying ws: ", err);
2569
2602
  }
2570
2603
  });
2571
2604
  httpServer.listen(this.proxyPort, () => {
@@ -2662,7 +2695,7 @@ var LocalProxy = class {
2662
2695
  });
2663
2696
  req.pipe(proxyReq);
2664
2697
  proxyReq.on("error", (err) => {
2665
- console.error("Proxy request error: ", err);
2698
+ logger.error("Proxy request error: ", err);
2666
2699
  res.writeHead(500, { "Content-Type": "text/plain" });
2667
2700
  res.end(
2668
2701
  `Error proxying request for ${target.application} to ${hostname}:${port}${path7}`
@@ -2735,49 +2768,52 @@ var LocalProxy = class {
2735
2768
  });
2736
2769
  }
2737
2770
  }
2738
- console.log(`
2771
+ logger.info(`
2739
2772
  \u25B2 Microfrontends Proxy (${package_default.version}) Started`);
2740
- console.log(` - Proxy URL: http://localhost:${this.proxyPort}`);
2773
+ logger.info(` - Proxy URL: http://localhost:${this.proxyPort}`);
2741
2774
  if (this.configFilePath) {
2742
- console.log(` - Config: ${this.configFilePath}`);
2775
+ logger.info(` - Config: ${this.configFilePath}`);
2743
2776
  }
2744
2777
  if (localApps.length > 0) {
2745
- console.log(" - Local Applications:");
2778
+ logger.info(" - Local Applications:");
2746
2779
  const displayLocalApps = localApps.length > 5 ? [
2747
2780
  ...localApps.slice(0, 5),
2748
2781
  { name: `... and ${localApps.length - 5} more`, port: void 0 }
2749
2782
  ] : localApps;
2750
2783
  for (const app of displayLocalApps) {
2751
2784
  if (app.port !== void 0) {
2752
- console.log(` \u2022 ${app.name} (port ${app.port})`);
2785
+ logger.info(` \u2022 ${app.name} (port ${app.port})`);
2753
2786
  } else {
2754
- console.log(` \u2022 ${app.name}`);
2787
+ logger.info(` \u2022 ${app.name}`);
2755
2788
  }
2756
2789
  }
2757
2790
  }
2758
2791
  if (fallbackApps.length > 0) {
2759
- console.log(" - Fallback Applications:");
2792
+ logger.info(" - Fallback Applications:");
2760
2793
  const displayFallbackApps = fallbackApps.length > 5 ? [
2761
2794
  ...fallbackApps.slice(0, 5),
2762
2795
  { name: `... and ${fallbackApps.length - 5} more`, fallback: "" }
2763
2796
  ] : fallbackApps;
2764
2797
  for (const app of displayFallbackApps) {
2765
2798
  if (app.fallback) {
2766
- console.log(` \u2022 ${app.name} \u2192 ${app.fallback}`);
2799
+ logger.info(` \u2022 ${app.name} \u2192 ${app.fallback}`);
2767
2800
  } else {
2768
- console.log(` \u2022 ${app.name}`);
2801
+ logger.info(` \u2022 ${app.name}`);
2769
2802
  }
2770
2803
  }
2771
2804
  }
2772
2805
  if (localApps.length === 0 && fallbackApps.length === 0) {
2773
- console.log(" - No applications configured\n");
2806
+ logger.info(" - No applications configured\n");
2774
2807
  }
2775
2808
  if (localApps.length > 0) {
2776
- console.log(
2809
+ logger.info(
2777
2810
  "\nRequests directly to the ports of these applications may be automatically\nredirected to this proxy. Set the MFE_DISABLE_LOCAL_PROXY_REWRITE=1\nenvironment variable to disable this behavior."
2778
2811
  );
2779
2812
  }
2780
- console.log(`
2813
+ logger.info(
2814
+ "\nTo debug routing, set an environment variable MFE_DEBUG=1,\nor enable the debug option when calling withMicrofrontends.\nThis will print out all routing information to the console.\n"
2815
+ );
2816
+ logger.info(`
2781
2817
  ${"\u2500".repeat(50)}
2782
2818
  `);
2783
2819
  }
@@ -2856,10 +2892,10 @@ function loadConfig({
2856
2892
  function displayPort() {
2857
2893
  const portInfo = mfePort((0, import_node_process.cwd)());
2858
2894
  header(portInfo);
2859
- console.log(portInfo.port);
2895
+ logger.info(portInfo.port);
2860
2896
  }
2861
2897
  function header({ name, version, port }) {
2862
- console.error(`
2898
+ logger.error(`
2863
2899
  \u25B2 ${name}@${version}
2864
2900
  \xB7 setting port to ${port}
2865
2901
  `);
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as ApplicationId, P as PathGroup, D as DefaultApplication$1, b as ChildApplication$1, A as Application$1, C as Config } from './types-e7523e61.js';
2
- import { H as HostConfig, L as LocalHostConfig, A as ApplicationOverrideConfig, O as OverridesConfig } from './types-88602303.js';
1
+ import { a as ApplicationId, P as PathGroup, D as DefaultApplication$1, b as ChildApplication$1, A as Application$1, C as Config } from './types-dcd8b17a.js';
2
+ import { H as HostConfig, L as LocalHostConfig, A as ApplicationOverrideConfig, O as OverridesConfig } from './types-b9ea41b2.js';
3
3
 
4
4
  interface ClientApplication {
5
5
  routing?: PathGroup[];