@vercel/microfrontends 0.17.2 → 0.17.4

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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -89
  3. package/dist/bin/cli.cjs +298 -200
  4. package/dist/config.cjs +19 -43
  5. package/dist/config.cjs.map +1 -1
  6. package/dist/config.d.ts +4 -4
  7. package/dist/config.js +19 -43
  8. package/dist/config.js.map +1 -1
  9. package/dist/{types-a29d224a.d.ts → index-5fcf0863.d.ts} +2 -2
  10. package/dist/{index-09caaa28.d.ts → index-f094deb1.d.ts} +3 -3
  11. package/dist/microfrontends/server.cjs +65 -73
  12. package/dist/microfrontends/server.cjs.map +1 -1
  13. package/dist/microfrontends/server.d.ts +4 -4
  14. package/dist/microfrontends/server.js +65 -73
  15. package/dist/microfrontends/server.js.map +1 -1
  16. package/dist/microfrontends.cjs +21 -46
  17. package/dist/microfrontends.cjs.map +1 -1
  18. package/dist/microfrontends.d.ts +4 -4
  19. package/dist/microfrontends.js +21 -46
  20. package/dist/microfrontends.js.map +1 -1
  21. package/dist/next/client.cjs +1 -1
  22. package/dist/next/client.cjs.map +1 -1
  23. package/dist/next/client.js +1 -1
  24. package/dist/next/client.js.map +1 -1
  25. package/dist/next/config.cjs +83 -99
  26. package/dist/next/config.cjs.map +1 -1
  27. package/dist/next/config.js +83 -99
  28. package/dist/next/config.js.map +1 -1
  29. package/dist/next/endpoints.cjs +1 -1
  30. package/dist/next/endpoints.cjs.map +1 -1
  31. package/dist/next/endpoints.d.ts +2 -2
  32. package/dist/next/endpoints.js +1 -1
  33. package/dist/next/endpoints.js.map +1 -1
  34. package/dist/next/middleware.cjs +29 -61
  35. package/dist/next/middleware.cjs.map +1 -1
  36. package/dist/next/middleware.js +29 -61
  37. package/dist/next/middleware.js.map +1 -1
  38. package/dist/next/testing.cjs +24 -52
  39. package/dist/next/testing.cjs.map +1 -1
  40. package/dist/next/testing.d.ts +4 -4
  41. package/dist/next/testing.js +24 -52
  42. package/dist/next/testing.js.map +1 -1
  43. package/dist/overrides.cjs +1 -2
  44. package/dist/overrides.cjs.map +1 -1
  45. package/dist/overrides.d.ts +3 -3
  46. package/dist/overrides.js +1 -2
  47. package/dist/overrides.js.map +1 -1
  48. package/dist/schema.cjs.map +1 -1
  49. package/dist/schema.d.ts +1 -1
  50. package/dist/{types-fc30696d.d.ts → types-5900be7c.d.ts} +1 -1
  51. package/dist/{types-cfe3308b.d.ts → types-ecd7b91b.d.ts} +1 -1
  52. package/dist/utils/mfe-port.cjs +65 -73
  53. package/dist/utils/mfe-port.cjs.map +1 -1
  54. package/dist/utils/mfe-port.js +65 -73
  55. package/dist/utils/mfe-port.js.map +1 -1
  56. package/dist/validation.cjs +46 -17
  57. package/dist/validation.cjs.map +1 -1
  58. package/dist/validation.d.ts +1 -1
  59. package/dist/validation.js +46 -17
  60. package/dist/validation.js.map +1 -1
  61. package/package.json +20 -24
  62. package/schema/schema.json +15 -8
@@ -45,8 +45,7 @@ var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
45
45
 
46
46
  // src/config/overrides/is-override-cookie.ts
47
47
  function isOverrideCookie(cookie) {
48
- var _a;
49
- return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
48
+ return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
50
49
  }
51
50
 
52
51
  // src/config/overrides/get-override-from-cookie.ts
@@ -78,9 +77,9 @@ var MicrofrontendError = class extends Error {
78
77
  constructor(message, opts) {
79
78
  super(message);
80
79
  this.name = "MicrofrontendsError";
81
- this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
82
- this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
83
- this.subtype = opts == null ? void 0 : opts.subtype;
80
+ this.source = opts?.source ?? "@vercel/microfrontends";
81
+ this.type = opts?.type ?? "unknown";
82
+ this.subtype = opts?.subtype;
84
83
  Error.captureStackTrace(this, MicrofrontendError);
85
84
  }
86
85
  isKnown() {
@@ -95,7 +94,7 @@ var MicrofrontendError = class extends Error {
95
94
  * @returns The converted MicrofrontendsError.
96
95
  */
97
96
  static convert(original, opts) {
98
- if (opts == null ? void 0 : opts.fileName) {
97
+ if (opts?.fileName) {
99
98
  const err = MicrofrontendError.convertFSError(original, opts.fileName);
100
99
  if (err) {
101
100
  return err;
@@ -196,7 +195,7 @@ var MicrofrontendConfigClient = class {
196
195
  constructor(config, opts) {
197
196
  this.pathCache = {};
198
197
  this.serialized = config;
199
- if (opts == null ? void 0 : opts.removeFlaggedPaths) {
198
+ if (opts?.removeFlaggedPaths) {
200
199
  for (const app of Object.values(config.applications)) {
201
200
  if (app.routing) {
202
201
  app.routing = app.routing.filter((match) => !match.flag);
@@ -258,17 +257,6 @@ var MicrofrontendConfigClient = class {
258
257
 
259
258
  // src/config/microfrontends-config/isomorphic/validation.ts
260
259
  var import_path_to_regexp2 = require("path-to-regexp");
261
- var SUPPORTED_VERSIONS = ["2"];
262
- var validateConfigVersion = (version) => {
263
- if (!SUPPORTED_VERSIONS.includes(version)) {
264
- throw new MicrofrontendError(
265
- `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
266
- ", "
267
- )}`,
268
- { type: "config", subtype: "unsupported_version" }
269
- );
270
- }
271
- };
272
260
  var validateConfigPaths = (applicationConfigsById) => {
273
261
  if (!applicationConfigsById) {
274
262
  return;
@@ -444,7 +432,7 @@ var Host = class {
444
432
  this.protocol = protocol;
445
433
  this.host = host;
446
434
  this.port = Host.getPort({ port, protocol: this.protocol });
447
- this.local = options == null ? void 0 : options.isLocal;
435
+ this.local = options?.isLocal;
448
436
  }
449
437
  isLocal() {
450
438
  return this.local || this.host === "localhost" || this.host === "127.0.0.1";
@@ -493,18 +481,17 @@ var Application = class {
493
481
  overrides,
494
482
  isDefault
495
483
  }) {
496
- var _a, _b;
497
484
  this.name = name;
498
485
  this.development = {
499
486
  local: new LocalHost({
500
487
  appName: name,
501
- ...(_a = app.development) == null ? void 0 : _a.local
488
+ ...app.development?.local
502
489
  }),
503
- fallback: ((_b = app.development) == null ? void 0 : _b.fallback) ? new Host(app.development.fallback) : void 0
490
+ fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
504
491
  };
505
492
  this.production = app.production ? new Host(app.production) : void 0;
506
493
  this.vercel = app.vercel;
507
- this.overrides = (overrides == null ? void 0 : overrides.environment) ? {
494
+ this.overrides = overrides?.environment ? {
508
495
  environment: new Host(overrides.environment)
509
496
  } : void 0;
510
497
  this.default = isDefault ?? false;
@@ -568,14 +555,13 @@ var MicrofrontendConfigIsomorphic = class {
568
555
  opts
569
556
  }) {
570
557
  this.childApplications = {};
571
- var _a, _b, _c, _d;
572
558
  MicrofrontendConfigIsomorphic.validate(config, opts);
573
- const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
559
+ const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
574
560
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
575
561
  this.isMainConfig = isMainConfig(config);
576
562
  if (isMainConfig(config)) {
577
563
  for (const [appId, appConfig] of Object.entries(config.applications)) {
578
- const appOverrides = !disableOverrides ? (_c = this.overrides) == null ? void 0 : _c.applications[appId] : void 0;
564
+ const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
579
565
  if (isDefaultApp(appConfig)) {
580
566
  this.defaultApplication = new DefaultApplication(appId, {
581
567
  app: appConfig,
@@ -590,7 +576,7 @@ var MicrofrontendConfigIsomorphic = class {
590
576
  }
591
577
  } else {
592
578
  this.partOf = config.partOf;
593
- const appOverrides = !disableOverrides ? (_d = this.overrides) == null ? void 0 : _d.applications[meta.fromApp] : void 0;
579
+ const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
594
580
  this.childApplications[meta.fromApp] = new ChildApplication(
595
581
  meta.fromApp,
596
582
  {
@@ -618,12 +604,9 @@ var MicrofrontendConfigIsomorphic = class {
618
604
  };
619
605
  }
620
606
  static validate(config, opts) {
621
- const skipValidation = (opts == null ? void 0 : opts.skipValidation) ?? [];
607
+ const skipValidation = opts?.skipValidation ?? [];
622
608
  const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
623
609
  if (isMainConfig(c)) {
624
- if (!skipValidation.includes("version")) {
625
- validateConfigVersion(c.version);
626
- }
627
610
  if (!skipValidation.includes("paths")) {
628
611
  validateConfigPaths(c.applications);
629
612
  }
@@ -644,8 +627,7 @@ var MicrofrontendConfigIsomorphic = class {
644
627
  });
645
628
  }
646
629
  isOverridesDisabled() {
647
- var _a, _b;
648
- return ((_b = (_a = this.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
630
+ return this.options?.vercel?.disableOverrides ?? false;
649
631
  }
650
632
  getConfig() {
651
633
  return this.config;
@@ -666,8 +648,7 @@ var MicrofrontendConfigIsomorphic = class {
666
648
  ].filter(Boolean);
667
649
  }
668
650
  getApplication(name) {
669
- var _a;
670
- if (((_a = this.defaultApplication) == null ? void 0 : _a.name) === name) {
651
+ if (this.defaultApplication?.name === name) {
671
652
  return this.defaultApplication;
672
653
  }
673
654
  const app = this.childApplications[name];
@@ -683,15 +664,11 @@ var MicrofrontendConfigIsomorphic = class {
683
664
  return app;
684
665
  }
685
666
  getApplicationByProjectId(projectId) {
686
- var _a, _b;
687
- if (((_b = (_a = this.defaultApplication) == null ? void 0 : _a.vercel) == null ? void 0 : _b.projectId) === projectId) {
667
+ if (this.defaultApplication?.vercel?.projectId === projectId) {
688
668
  return this.defaultApplication;
689
669
  }
690
670
  return Object.values(this.childApplications).find(
691
- (app) => {
692
- var _a2;
693
- return ((_a2 = app.vercel) == null ? void 0 : _a2.projectId) === projectId;
694
- }
671
+ (app) => app.vercel?.projectId === projectId
695
672
  );
696
673
  }
697
674
  /**
@@ -714,8 +691,7 @@ var MicrofrontendConfigIsomorphic = class {
714
691
  * Returns the configured port for the local proxy
715
692
  */
716
693
  getLocalProxyPort() {
717
- var _a, _b;
718
- return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
694
+ return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
719
695
  }
720
696
  /**
721
697
  * Serializes the class back to the Schema type.
@@ -769,13 +745,12 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
769
745
  overrides,
770
746
  meta
771
747
  }) {
772
- var _a, _b, _c;
773
748
  super({ config, overrides, meta });
774
749
  this.isMainConfig = true;
775
- const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
750
+ const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
776
751
  let defaultApplication;
777
752
  for (const [appId, appConfig] of Object.entries(config.applications)) {
778
- const appOverrides = !disableOverrides ? (_c = this.overrides) == null ? void 0 : _c.applications[appId] : void 0;
753
+ const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
779
754
  if (isDefaultApp(appConfig)) {
780
755
  defaultApplication = new DefaultApplication(appId, {
781
756
  app: appConfig,
@@ -968,7 +943,7 @@ function findDefaultMicrofrontendsPackage(opts) {
968
943
  const result = findDefaultMicrofrontendsPackages(opts);
969
944
  if (!result) {
970
945
  throw new Error(
971
- `Error trying to resolve the main microfrontends configuration`
946
+ "Error trying to resolve the main microfrontends configuration"
972
947
  );
973
948
  }
974
949
  configCache2[cacheKey] = result;
@@ -1040,20 +1015,8 @@ var import_node_path7 = __toESM(require("path"), 1);
1040
1015
  var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
1041
1016
  var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
1042
1017
 
1043
- // src/utils/is-vercel.ts
1044
- function isVercel() {
1045
- return process.env.VERCEL === "1";
1046
- }
1047
-
1048
1018
  // src/config/microfrontends/server/utils/get-output-file-path.ts
1049
1019
  function getOutputFilePath() {
1050
- if (isVercel()) {
1051
- return import_node_path7.default.join(
1052
- ".vercel",
1053
- MFE_CONFIG_DEFAULT_FILE_PATH,
1054
- MFE_CONFIG_DEFAULT_FILE_NAME
1055
- );
1056
- }
1057
1020
  return import_node_path7.default.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1058
1021
  }
1059
1022
 
@@ -1084,7 +1047,7 @@ var schema_default = {
1084
1047
  },
1085
1048
  version: {
1086
1049
  type: "string",
1087
- const: "2"
1050
+ const: "1"
1088
1051
  },
1089
1052
  options: {
1090
1053
  $ref: "#/definitions/Options"
@@ -1094,6 +1057,9 @@ var schema_default = {
1094
1057
  additionalProperties: {
1095
1058
  $ref: "#/definitions/Application"
1096
1059
  },
1060
+ propertyNames: {
1061
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1062
+ },
1097
1063
  description: "Applications that only serve a subset of the microfrontend routes only need to reference the name of the primary application that owns the full microfrontends configuration."
1098
1064
  },
1099
1065
  applications: {
@@ -1101,7 +1067,9 @@ var schema_default = {
1101
1067
  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"
1102
1068
  }
1103
1069
  },
1104
- required: ["applications", "version"],
1070
+ required: [
1071
+ "applications"
1072
+ ],
1105
1073
  additionalProperties: false
1106
1074
  },
1107
1075
  Options: {
@@ -1165,7 +1133,9 @@ var schema_default = {
1165
1133
  $ref: "#/definitions/HostConfig"
1166
1134
  }
1167
1135
  },
1168
- required: ["production"],
1136
+ required: [
1137
+ "production"
1138
+ ],
1169
1139
  additionalProperties: false
1170
1140
  },
1171
1141
  Vercel: {
@@ -1176,7 +1146,9 @@ var schema_default = {
1176
1146
  description: "Vercel project ID"
1177
1147
  }
1178
1148
  },
1179
- required: ["projectId"],
1149
+ required: [
1150
+ "projectId"
1151
+ ],
1180
1152
  additionalProperties: false
1181
1153
  },
1182
1154
  Development: {
@@ -1206,8 +1178,11 @@ var schema_default = {
1206
1178
  },
1207
1179
  protocol: {
1208
1180
  type: "string",
1209
- enum: ["http", "https"],
1210
- description: 'The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n* @defaultValue "http" for local development, "https" for otherwise'
1181
+ enum: [
1182
+ "http",
1183
+ "https"
1184
+ ],
1185
+ description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1211
1186
  },
1212
1187
  port: {
1213
1188
  type: "number",
@@ -1220,8 +1195,11 @@ var schema_default = {
1220
1195
  properties: {
1221
1196
  protocol: {
1222
1197
  type: "string",
1223
- enum: ["http", "https"],
1224
- description: 'The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n* @defaultValue "http" for local development, "https" for otherwise'
1198
+ enum: [
1199
+ "http",
1200
+ "https"
1201
+ ],
1202
+ description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1225
1203
  },
1226
1204
  host: {
1227
1205
  type: "string",
@@ -1232,7 +1210,9 @@ var schema_default = {
1232
1210
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1233
1211
  }
1234
1212
  },
1235
- required: ["host"],
1213
+ required: [
1214
+ "host"
1215
+ ],
1236
1216
  additionalProperties: false
1237
1217
  },
1238
1218
  ChildApplication: {
@@ -1252,7 +1232,9 @@ var schema_default = {
1252
1232
  $ref: "#/definitions/HostConfig"
1253
1233
  }
1254
1234
  },
1255
- required: ["routing"],
1235
+ required: [
1236
+ "routing"
1237
+ ],
1256
1238
  additionalProperties: false
1257
1239
  },
1258
1240
  Routing: {
@@ -1279,13 +1261,18 @@ var schema_default = {
1279
1261
  }
1280
1262
  }
1281
1263
  },
1282
- required: ["paths"],
1264
+ required: [
1265
+ "paths"
1266
+ ],
1283
1267
  additionalProperties: false
1284
1268
  },
1285
1269
  ApplicationRouting: {
1286
1270
  type: "object",
1287
1271
  additionalProperties: {
1288
1272
  $ref: "#/definitions/Application"
1273
+ },
1274
+ propertyNames: {
1275
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1289
1276
  }
1290
1277
  },
1291
1278
  ChildConfig: {
@@ -1296,7 +1283,7 @@ var schema_default = {
1296
1283
  },
1297
1284
  version: {
1298
1285
  type: "string",
1299
- const: "2"
1286
+ const: "1"
1300
1287
  },
1301
1288
  options: {
1302
1289
  $ref: "#/definitions/Options"
@@ -1306,6 +1293,9 @@ var schema_default = {
1306
1293
  additionalProperties: {
1307
1294
  $ref: "#/definitions/Application"
1308
1295
  },
1296
+ propertyNames: {
1297
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1298
+ },
1309
1299
  description: "Applications that only serve a subset of the microfrontend routes only need to reference the name of the primary application that owns the full microfrontends configuration."
1310
1300
  },
1311
1301
  partOf: {
@@ -1313,7 +1303,9 @@ var schema_default = {
1313
1303
  description: "Applications that only serve a subset of the microfrontend routes only need to reference the name of the primary application that owns the full microfrontends configuration."
1314
1304
  }
1315
1305
  },
1316
- required: ["partOf", "version"],
1306
+ required: [
1307
+ "partOf"
1308
+ ],
1317
1309
  additionalProperties: false
1318
1310
  }
1319
1311
  }
@@ -1487,7 +1479,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1487
1479
  try {
1488
1480
  const configJson = import_node_fs7.default.readFileSync(filePath, "utf-8");
1489
1481
  const config = MicrofrontendsServer.validate(configJson);
1490
- if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
1482
+ if (!isMainConfig(config) && options?.resolveMainConfig) {
1491
1483
  const repositoryRoot = findRepositoryRoot();
1492
1484
  const isMonorepo2 = isMonorepo({ repositoryRoot });
1493
1485
  if (isMonorepo2) {
@@ -1595,9 +1587,8 @@ function transform(args) {
1595
1587
 
1596
1588
  // src/next/config/transforms/draft-mode.ts
1597
1589
  function transform2(args) {
1598
- var _a;
1599
1590
  const { next } = args;
1600
- if (((_a = next.experimental) == null ? void 0 : _a.multiZoneDraftMode) !== void 0) {
1591
+ if (next.experimental?.multiZoneDraftMode !== void 0) {
1601
1592
  return {
1602
1593
  next
1603
1594
  };
@@ -1671,21 +1662,17 @@ function getDomainFromEnvironment({
1671
1662
  app,
1672
1663
  target
1673
1664
  }) {
1674
- var _a;
1675
1665
  const mfeProjects = JSON.parse(
1676
1666
  process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "[]"
1677
1667
  );
1678
1668
  if (mfeProjects.length === 0) {
1679
1669
  throw new Error("Missing related microfrontends project information");
1680
1670
  }
1681
- if (!((_a = app.vercel) == null ? void 0 : _a.projectId)) {
1671
+ if (!app.vercel?.projectId) {
1682
1672
  throw new Error(`Missing applications[${app.name}].vercel.projectId`);
1683
1673
  }
1684
1674
  const vercelProject = mfeProjects.find(
1685
- (p) => {
1686
- var _a2;
1687
- return p.project.id === ((_a2 = app.vercel) == null ? void 0 : _a2.projectId);
1688
- }
1675
+ (p) => p.project.id === app.vercel?.projectId
1689
1676
  );
1690
1677
  if (!vercelProject) {
1691
1678
  throw new Error(
@@ -1728,9 +1715,8 @@ function getCurrentEnvironment() {
1728
1715
  return { group: "custom", name: process.env.VERCEL_ENV };
1729
1716
  }
1730
1717
  function getDomainForCurrentEnvironment(config, appName, opts = {}) {
1731
- var _a;
1732
1718
  const app = config.getApplication(appName);
1733
- if (!opts.ignoreOverride && ((_a = app.overrides) == null ? void 0 : _a.environment)) {
1719
+ if (!opts.ignoreOverride && app.overrides?.environment) {
1734
1720
  return app.overrides.environment.toString();
1735
1721
  }
1736
1722
  const { group } = getCurrentEnvironment();
@@ -1775,11 +1761,10 @@ ${table}
1775
1761
  }
1776
1762
  }
1777
1763
  function pathToRewrites(path5) {
1778
- var _a;
1779
1764
  const regex = /(?<base>^.+)\/:.+\*$/;
1780
1765
  const match = regex.exec(path5);
1781
1766
  const paths = [path5];
1782
- if ((_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.base) {
1767
+ if (match?.groups?.base) {
1783
1768
  paths.unshift(match.groups.base);
1784
1769
  }
1785
1770
  return paths;
@@ -1909,7 +1894,6 @@ ${table}
1909
1894
  }
1910
1895
  var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
1911
1896
  function transform5(args) {
1912
- var _a, _b;
1913
1897
  const { next, app, microfrontend } = args;
1914
1898
  if (microfrontend instanceof MicrofrontendChildConfig) {
1915
1899
  console.warn(
@@ -1928,7 +1912,7 @@ function transform5(args) {
1928
1912
  // that are in the default zone.
1929
1913
  defaultApplication
1930
1914
  ];
1931
- const existingServerActionConfig = (_a = next.experimental) == null ? void 0 : _a.serverActions;
1915
+ const existingServerActionConfig = next.experimental?.serverActions;
1932
1916
  next.experimental = {
1933
1917
  ...next.experimental,
1934
1918
  serverActions: {
@@ -1936,7 +1920,7 @@ function transform5(args) {
1936
1920
  allowedOrigins: Array.from(
1937
1921
  /* @__PURE__ */ new Set([
1938
1922
  // existing
1939
- ...(existingServerActionConfig == null ? void 0 : existingServerActionConfig.allowedOrigins) ?? [],
1923
+ ...existingServerActionConfig?.allowedOrigins ?? [],
1940
1924
  // this deployments host
1941
1925
  ...process.env.VERCEL_URL ? [formatDomainForServerAction(process.env.VERCEL_URL)] : [],
1942
1926
  // default application host
@@ -1951,7 +1935,7 @@ function transform5(args) {
1951
1935
  )
1952
1936
  }
1953
1937
  };
1954
- debugRewrites2((_b = next.experimental.serverActions) == null ? void 0 : _b.allowedOrigins);
1938
+ debugRewrites2(next.experimental.serverActions?.allowedOrigins);
1955
1939
  return {
1956
1940
  next
1957
1941
  };
@@ -2033,7 +2017,10 @@ function setEnvironment({
2033
2017
  NEXT_PUBLIC_MFE_CURRENT_APPLICATION: app.name,
2034
2018
  NEXT_PUBLIC_MFE_CLIENT_CONFIG: JSON.stringify(
2035
2019
  microfrontends.config.toClientConfig().serialize()
2036
- )
2020
+ ),
2021
+ ...process.env.ROUTE_OBSERVABILITY_TO_DEFAULT_APP || !app.getAssetPrefix() ? {} : {
2022
+ NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH: `/${app.getAssetPrefix()}/_vercel`
2023
+ }
2037
2024
  };
2038
2025
  const serverEnvs = {
2039
2026
  MFE_CURRENT_APPLICATION: app.name,
@@ -2051,13 +2038,13 @@ function typedEntries(obj) {
2051
2038
  return Object.entries(obj);
2052
2039
  }
2053
2040
  function isProduction(opts) {
2054
- if (opts == null ? void 0 : opts.isProduction) {
2041
+ if (opts?.isProduction) {
2055
2042
  return opts.isProduction();
2056
2043
  }
2057
2044
  return process.env.VERCEL_ENV === "production";
2058
2045
  }
2059
2046
  function getApplicationContext(opts) {
2060
- if (opts == null ? void 0 : opts.appName) {
2047
+ if (opts?.appName) {
2061
2048
  return { name: opts.appName };
2062
2049
  }
2063
2050
  try {
@@ -2081,13 +2068,12 @@ function getApplicationContext(opts) {
2081
2068
  }
2082
2069
  }
2083
2070
  function withMicrofrontends(nextConfig, opts) {
2084
- var _a;
2085
- if (opts == null ? void 0 : opts.debug) {
2071
+ if (opts?.debug) {
2086
2072
  process.env.MFE_DEBUG = "true";
2087
2073
  }
2088
2074
  const { name: fromApp } = getApplicationContext(opts);
2089
2075
  const microfrontends = MicrofrontendsServer.infer({
2090
- filePath: opts == null ? void 0 : opts.configPath,
2076
+ filePath: opts?.configPath,
2091
2077
  meta: {
2092
2078
  fromApp
2093
2079
  }
@@ -2096,7 +2082,7 @@ function withMicrofrontends(nextConfig, opts) {
2096
2082
  setEnvironment({ app, microfrontends });
2097
2083
  let next = { ...nextConfig };
2098
2084
  for (const [key, transform7] of typedEntries(transforms)) {
2099
- if ((_a = opts == null ? void 0 : opts.skipTransforms) == null ? void 0 : _a.includes(key)) {
2085
+ if (opts?.skipTransforms?.includes(key)) {
2100
2086
  console.log(`Skipping ${key} transform`);
2101
2087
  continue;
2102
2088
  }
@@ -2112,12 +2098,10 @@ function withMicrofrontends(nextConfig, opts) {
2112
2098
  next = transformedConfig.next;
2113
2099
  } catch (e) {
2114
2100
  console.error("Error transforming next config", e);
2101
+ throw e;
2115
2102
  }
2116
2103
  }
2117
2104
  displayLocalProxyInfo(microfrontends.config.getLocalProxyPort());
2118
- if (isVercel()) {
2119
- microfrontends.writeConfig();
2120
- }
2121
2105
  return next;
2122
2106
  }
2123
2107
  // Annotate the CommonJS export names for ESM import in node: