@vercel/microfrontends 0.17.2 → 0.17.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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -89
  3. package/dist/bin/cli.cjs +296 -198
  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 +18 -22
  62. package/schema/schema.json +15 -8
@@ -11,8 +11,7 @@ var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
11
11
 
12
12
  // src/config/overrides/is-override-cookie.ts
13
13
  function isOverrideCookie(cookie) {
14
- var _a;
15
- return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
14
+ return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
16
15
  }
17
16
 
18
17
  // src/config/overrides/get-override-from-cookie.ts
@@ -44,9 +43,9 @@ var MicrofrontendError = class extends Error {
44
43
  constructor(message, opts) {
45
44
  super(message);
46
45
  this.name = "MicrofrontendsError";
47
- this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
48
- this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
49
- this.subtype = opts == null ? void 0 : opts.subtype;
46
+ this.source = opts?.source ?? "@vercel/microfrontends";
47
+ this.type = opts?.type ?? "unknown";
48
+ this.subtype = opts?.subtype;
50
49
  Error.captureStackTrace(this, MicrofrontendError);
51
50
  }
52
51
  isKnown() {
@@ -61,7 +60,7 @@ var MicrofrontendError = class extends Error {
61
60
  * @returns The converted MicrofrontendsError.
62
61
  */
63
62
  static convert(original, opts) {
64
- if (opts == null ? void 0 : opts.fileName) {
63
+ if (opts?.fileName) {
65
64
  const err = MicrofrontendError.convertFSError(original, opts.fileName);
66
65
  if (err) {
67
66
  return err;
@@ -162,7 +161,7 @@ var MicrofrontendConfigClient = class {
162
161
  constructor(config, opts) {
163
162
  this.pathCache = {};
164
163
  this.serialized = config;
165
- if (opts == null ? void 0 : opts.removeFlaggedPaths) {
164
+ if (opts?.removeFlaggedPaths) {
166
165
  for (const app of Object.values(config.applications)) {
167
166
  if (app.routing) {
168
167
  app.routing = app.routing.filter((match) => !match.flag);
@@ -224,17 +223,6 @@ var MicrofrontendConfigClient = class {
224
223
 
225
224
  // src/config/microfrontends-config/isomorphic/validation.ts
226
225
  import { pathToRegexp as pathToRegexp2, parse as parsePathRegexp } from "path-to-regexp";
227
- var SUPPORTED_VERSIONS = ["2"];
228
- var validateConfigVersion = (version) => {
229
- if (!SUPPORTED_VERSIONS.includes(version)) {
230
- throw new MicrofrontendError(
231
- `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
232
- ", "
233
- )}`,
234
- { type: "config", subtype: "unsupported_version" }
235
- );
236
- }
237
- };
238
226
  var validateConfigPaths = (applicationConfigsById) => {
239
227
  if (!applicationConfigsById) {
240
228
  return;
@@ -410,7 +398,7 @@ var Host = class {
410
398
  this.protocol = protocol;
411
399
  this.host = host;
412
400
  this.port = Host.getPort({ port, protocol: this.protocol });
413
- this.local = options == null ? void 0 : options.isLocal;
401
+ this.local = options?.isLocal;
414
402
  }
415
403
  isLocal() {
416
404
  return this.local || this.host === "localhost" || this.host === "127.0.0.1";
@@ -459,18 +447,17 @@ var Application = class {
459
447
  overrides,
460
448
  isDefault
461
449
  }) {
462
- var _a, _b;
463
450
  this.name = name;
464
451
  this.development = {
465
452
  local: new LocalHost({
466
453
  appName: name,
467
- ...(_a = app.development) == null ? void 0 : _a.local
454
+ ...app.development?.local
468
455
  }),
469
- fallback: ((_b = app.development) == null ? void 0 : _b.fallback) ? new Host(app.development.fallback) : void 0
456
+ fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
470
457
  };
471
458
  this.production = app.production ? new Host(app.production) : void 0;
472
459
  this.vercel = app.vercel;
473
- this.overrides = (overrides == null ? void 0 : overrides.environment) ? {
460
+ this.overrides = overrides?.environment ? {
474
461
  environment: new Host(overrides.environment)
475
462
  } : void 0;
476
463
  this.default = isDefault ?? false;
@@ -534,14 +521,13 @@ var MicrofrontendConfigIsomorphic = class {
534
521
  opts
535
522
  }) {
536
523
  this.childApplications = {};
537
- var _a, _b, _c, _d;
538
524
  MicrofrontendConfigIsomorphic.validate(config, opts);
539
- const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
525
+ const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
540
526
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
541
527
  this.isMainConfig = isMainConfig(config);
542
528
  if (isMainConfig(config)) {
543
529
  for (const [appId, appConfig] of Object.entries(config.applications)) {
544
- const appOverrides = !disableOverrides ? (_c = this.overrides) == null ? void 0 : _c.applications[appId] : void 0;
530
+ const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
545
531
  if (isDefaultApp(appConfig)) {
546
532
  this.defaultApplication = new DefaultApplication(appId, {
547
533
  app: appConfig,
@@ -556,7 +542,7 @@ var MicrofrontendConfigIsomorphic = class {
556
542
  }
557
543
  } else {
558
544
  this.partOf = config.partOf;
559
- const appOverrides = !disableOverrides ? (_d = this.overrides) == null ? void 0 : _d.applications[meta.fromApp] : void 0;
545
+ const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
560
546
  this.childApplications[meta.fromApp] = new ChildApplication(
561
547
  meta.fromApp,
562
548
  {
@@ -584,12 +570,9 @@ var MicrofrontendConfigIsomorphic = class {
584
570
  };
585
571
  }
586
572
  static validate(config, opts) {
587
- const skipValidation = (opts == null ? void 0 : opts.skipValidation) ?? [];
573
+ const skipValidation = opts?.skipValidation ?? [];
588
574
  const c = typeof config === "string" ? parse(config) : config;
589
575
  if (isMainConfig(c)) {
590
- if (!skipValidation.includes("version")) {
591
- validateConfigVersion(c.version);
592
- }
593
576
  if (!skipValidation.includes("paths")) {
594
577
  validateConfigPaths(c.applications);
595
578
  }
@@ -610,8 +593,7 @@ var MicrofrontendConfigIsomorphic = class {
610
593
  });
611
594
  }
612
595
  isOverridesDisabled() {
613
- var _a, _b;
614
- return ((_b = (_a = this.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
596
+ return this.options?.vercel?.disableOverrides ?? false;
615
597
  }
616
598
  getConfig() {
617
599
  return this.config;
@@ -632,8 +614,7 @@ var MicrofrontendConfigIsomorphic = class {
632
614
  ].filter(Boolean);
633
615
  }
634
616
  getApplication(name) {
635
- var _a;
636
- if (((_a = this.defaultApplication) == null ? void 0 : _a.name) === name) {
617
+ if (this.defaultApplication?.name === name) {
637
618
  return this.defaultApplication;
638
619
  }
639
620
  const app = this.childApplications[name];
@@ -649,15 +630,11 @@ var MicrofrontendConfigIsomorphic = class {
649
630
  return app;
650
631
  }
651
632
  getApplicationByProjectId(projectId) {
652
- var _a, _b;
653
- if (((_b = (_a = this.defaultApplication) == null ? void 0 : _a.vercel) == null ? void 0 : _b.projectId) === projectId) {
633
+ if (this.defaultApplication?.vercel?.projectId === projectId) {
654
634
  return this.defaultApplication;
655
635
  }
656
636
  return Object.values(this.childApplications).find(
657
- (app) => {
658
- var _a2;
659
- return ((_a2 = app.vercel) == null ? void 0 : _a2.projectId) === projectId;
660
- }
637
+ (app) => app.vercel?.projectId === projectId
661
638
  );
662
639
  }
663
640
  /**
@@ -680,8 +657,7 @@ var MicrofrontendConfigIsomorphic = class {
680
657
  * Returns the configured port for the local proxy
681
658
  */
682
659
  getLocalProxyPort() {
683
- var _a, _b;
684
- return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
660
+ return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
685
661
  }
686
662
  /**
687
663
  * Serializes the class back to the Schema type.
@@ -735,13 +711,12 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
735
711
  overrides,
736
712
  meta
737
713
  }) {
738
- var _a, _b, _c;
739
714
  super({ config, overrides, meta });
740
715
  this.isMainConfig = true;
741
- const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
716
+ const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
742
717
  let defaultApplication;
743
718
  for (const [appId, appConfig] of Object.entries(config.applications)) {
744
- const appOverrides = !disableOverrides ? (_c = this.overrides) == null ? void 0 : _c.applications[appId] : void 0;
719
+ const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
745
720
  if (isDefaultApp(appConfig)) {
746
721
  defaultApplication = new DefaultApplication(appId, {
747
722
  app: appConfig,
@@ -934,7 +909,7 @@ function findDefaultMicrofrontendsPackage(opts) {
934
909
  const result = findDefaultMicrofrontendsPackages(opts);
935
910
  if (!result) {
936
911
  throw new Error(
937
- `Error trying to resolve the main microfrontends configuration`
912
+ "Error trying to resolve the main microfrontends configuration"
938
913
  );
939
914
  }
940
915
  configCache2[cacheKey] = result;
@@ -1006,20 +981,8 @@ import path4 from "node:path";
1006
981
  var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
1007
982
  var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
1008
983
 
1009
- // src/utils/is-vercel.ts
1010
- function isVercel() {
1011
- return process.env.VERCEL === "1";
1012
- }
1013
-
1014
984
  // src/config/microfrontends/server/utils/get-output-file-path.ts
1015
985
  function getOutputFilePath() {
1016
- if (isVercel()) {
1017
- return path4.join(
1018
- ".vercel",
1019
- MFE_CONFIG_DEFAULT_FILE_PATH,
1020
- MFE_CONFIG_DEFAULT_FILE_NAME
1021
- );
1022
- }
1023
986
  return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1024
987
  }
1025
988
 
@@ -1050,7 +1013,7 @@ var schema_default = {
1050
1013
  },
1051
1014
  version: {
1052
1015
  type: "string",
1053
- const: "2"
1016
+ const: "1"
1054
1017
  },
1055
1018
  options: {
1056
1019
  $ref: "#/definitions/Options"
@@ -1060,6 +1023,9 @@ var schema_default = {
1060
1023
  additionalProperties: {
1061
1024
  $ref: "#/definitions/Application"
1062
1025
  },
1026
+ propertyNames: {
1027
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1028
+ },
1063
1029
  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."
1064
1030
  },
1065
1031
  applications: {
@@ -1067,7 +1033,9 @@ var schema_default = {
1067
1033
  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"
1068
1034
  }
1069
1035
  },
1070
- required: ["applications", "version"],
1036
+ required: [
1037
+ "applications"
1038
+ ],
1071
1039
  additionalProperties: false
1072
1040
  },
1073
1041
  Options: {
@@ -1131,7 +1099,9 @@ var schema_default = {
1131
1099
  $ref: "#/definitions/HostConfig"
1132
1100
  }
1133
1101
  },
1134
- required: ["production"],
1102
+ required: [
1103
+ "production"
1104
+ ],
1135
1105
  additionalProperties: false
1136
1106
  },
1137
1107
  Vercel: {
@@ -1142,7 +1112,9 @@ var schema_default = {
1142
1112
  description: "Vercel project ID"
1143
1113
  }
1144
1114
  },
1145
- required: ["projectId"],
1115
+ required: [
1116
+ "projectId"
1117
+ ],
1146
1118
  additionalProperties: false
1147
1119
  },
1148
1120
  Development: {
@@ -1172,8 +1144,11 @@ var schema_default = {
1172
1144
  },
1173
1145
  protocol: {
1174
1146
  type: "string",
1175
- enum: ["http", "https"],
1176
- 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'
1147
+ enum: [
1148
+ "http",
1149
+ "https"
1150
+ ],
1151
+ description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1177
1152
  },
1178
1153
  port: {
1179
1154
  type: "number",
@@ -1186,8 +1161,11 @@ var schema_default = {
1186
1161
  properties: {
1187
1162
  protocol: {
1188
1163
  type: "string",
1189
- enum: ["http", "https"],
1190
- 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'
1164
+ enum: [
1165
+ "http",
1166
+ "https"
1167
+ ],
1168
+ description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1191
1169
  },
1192
1170
  host: {
1193
1171
  type: "string",
@@ -1198,7 +1176,9 @@ var schema_default = {
1198
1176
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1199
1177
  }
1200
1178
  },
1201
- required: ["host"],
1179
+ required: [
1180
+ "host"
1181
+ ],
1202
1182
  additionalProperties: false
1203
1183
  },
1204
1184
  ChildApplication: {
@@ -1218,7 +1198,9 @@ var schema_default = {
1218
1198
  $ref: "#/definitions/HostConfig"
1219
1199
  }
1220
1200
  },
1221
- required: ["routing"],
1201
+ required: [
1202
+ "routing"
1203
+ ],
1222
1204
  additionalProperties: false
1223
1205
  },
1224
1206
  Routing: {
@@ -1245,13 +1227,18 @@ var schema_default = {
1245
1227
  }
1246
1228
  }
1247
1229
  },
1248
- required: ["paths"],
1230
+ required: [
1231
+ "paths"
1232
+ ],
1249
1233
  additionalProperties: false
1250
1234
  },
1251
1235
  ApplicationRouting: {
1252
1236
  type: "object",
1253
1237
  additionalProperties: {
1254
1238
  $ref: "#/definitions/Application"
1239
+ },
1240
+ propertyNames: {
1241
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1255
1242
  }
1256
1243
  },
1257
1244
  ChildConfig: {
@@ -1262,7 +1249,7 @@ var schema_default = {
1262
1249
  },
1263
1250
  version: {
1264
1251
  type: "string",
1265
- const: "2"
1252
+ const: "1"
1266
1253
  },
1267
1254
  options: {
1268
1255
  $ref: "#/definitions/Options"
@@ -1272,6 +1259,9 @@ var schema_default = {
1272
1259
  additionalProperties: {
1273
1260
  $ref: "#/definitions/Application"
1274
1261
  },
1262
+ propertyNames: {
1263
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1264
+ },
1275
1265
  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."
1276
1266
  },
1277
1267
  partOf: {
@@ -1279,7 +1269,9 @@ var schema_default = {
1279
1269
  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."
1280
1270
  }
1281
1271
  },
1282
- required: ["partOf", "version"],
1272
+ required: [
1273
+ "partOf"
1274
+ ],
1283
1275
  additionalProperties: false
1284
1276
  }
1285
1277
  }
@@ -1453,7 +1445,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1453
1445
  try {
1454
1446
  const configJson = fs5.readFileSync(filePath, "utf-8");
1455
1447
  const config = MicrofrontendsServer.validate(configJson);
1456
- if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
1448
+ if (!isMainConfig(config) && options?.resolveMainConfig) {
1457
1449
  const repositoryRoot = findRepositoryRoot();
1458
1450
  const isMonorepo2 = isMonorepo({ repositoryRoot });
1459
1451
  if (isMonorepo2) {
@@ -1561,9 +1553,8 @@ function transform(args) {
1561
1553
 
1562
1554
  // src/next/config/transforms/draft-mode.ts
1563
1555
  function transform2(args) {
1564
- var _a;
1565
1556
  const { next } = args;
1566
- if (((_a = next.experimental) == null ? void 0 : _a.multiZoneDraftMode) !== void 0) {
1557
+ if (next.experimental?.multiZoneDraftMode !== void 0) {
1567
1558
  return {
1568
1559
  next
1569
1560
  };
@@ -1637,21 +1628,17 @@ function getDomainFromEnvironment({
1637
1628
  app,
1638
1629
  target
1639
1630
  }) {
1640
- var _a;
1641
1631
  const mfeProjects = JSON.parse(
1642
1632
  process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "[]"
1643
1633
  );
1644
1634
  if (mfeProjects.length === 0) {
1645
1635
  throw new Error("Missing related microfrontends project information");
1646
1636
  }
1647
- if (!((_a = app.vercel) == null ? void 0 : _a.projectId)) {
1637
+ if (!app.vercel?.projectId) {
1648
1638
  throw new Error(`Missing applications[${app.name}].vercel.projectId`);
1649
1639
  }
1650
1640
  const vercelProject = mfeProjects.find(
1651
- (p) => {
1652
- var _a2;
1653
- return p.project.id === ((_a2 = app.vercel) == null ? void 0 : _a2.projectId);
1654
- }
1641
+ (p) => p.project.id === app.vercel?.projectId
1655
1642
  );
1656
1643
  if (!vercelProject) {
1657
1644
  throw new Error(
@@ -1694,9 +1681,8 @@ function getCurrentEnvironment() {
1694
1681
  return { group: "custom", name: process.env.VERCEL_ENV };
1695
1682
  }
1696
1683
  function getDomainForCurrentEnvironment(config, appName, opts = {}) {
1697
- var _a;
1698
1684
  const app = config.getApplication(appName);
1699
- if (!opts.ignoreOverride && ((_a = app.overrides) == null ? void 0 : _a.environment)) {
1685
+ if (!opts.ignoreOverride && app.overrides?.environment) {
1700
1686
  return app.overrides.environment.toString();
1701
1687
  }
1702
1688
  const { group } = getCurrentEnvironment();
@@ -1741,11 +1727,10 @@ ${table}
1741
1727
  }
1742
1728
  }
1743
1729
  function pathToRewrites(path5) {
1744
- var _a;
1745
1730
  const regex = /(?<base>^.+)\/:.+\*$/;
1746
1731
  const match = regex.exec(path5);
1747
1732
  const paths = [path5];
1748
- if ((_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.base) {
1733
+ if (match?.groups?.base) {
1749
1734
  paths.unshift(match.groups.base);
1750
1735
  }
1751
1736
  return paths;
@@ -1875,7 +1860,6 @@ ${table}
1875
1860
  }
1876
1861
  var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
1877
1862
  function transform5(args) {
1878
- var _a, _b;
1879
1863
  const { next, app, microfrontend } = args;
1880
1864
  if (microfrontend instanceof MicrofrontendChildConfig) {
1881
1865
  console.warn(
@@ -1894,7 +1878,7 @@ function transform5(args) {
1894
1878
  // that are in the default zone.
1895
1879
  defaultApplication
1896
1880
  ];
1897
- const existingServerActionConfig = (_a = next.experimental) == null ? void 0 : _a.serverActions;
1881
+ const existingServerActionConfig = next.experimental?.serverActions;
1898
1882
  next.experimental = {
1899
1883
  ...next.experimental,
1900
1884
  serverActions: {
@@ -1902,7 +1886,7 @@ function transform5(args) {
1902
1886
  allowedOrigins: Array.from(
1903
1887
  /* @__PURE__ */ new Set([
1904
1888
  // existing
1905
- ...(existingServerActionConfig == null ? void 0 : existingServerActionConfig.allowedOrigins) ?? [],
1889
+ ...existingServerActionConfig?.allowedOrigins ?? [],
1906
1890
  // this deployments host
1907
1891
  ...process.env.VERCEL_URL ? [formatDomainForServerAction(process.env.VERCEL_URL)] : [],
1908
1892
  // default application host
@@ -1917,7 +1901,7 @@ function transform5(args) {
1917
1901
  )
1918
1902
  }
1919
1903
  };
1920
- debugRewrites2((_b = next.experimental.serverActions) == null ? void 0 : _b.allowedOrigins);
1904
+ debugRewrites2(next.experimental.serverActions?.allowedOrigins);
1921
1905
  return {
1922
1906
  next
1923
1907
  };
@@ -1999,7 +1983,10 @@ function setEnvironment({
1999
1983
  NEXT_PUBLIC_MFE_CURRENT_APPLICATION: app.name,
2000
1984
  NEXT_PUBLIC_MFE_CLIENT_CONFIG: JSON.stringify(
2001
1985
  microfrontends.config.toClientConfig().serialize()
2002
- )
1986
+ ),
1987
+ ...process.env.ROUTE_OBSERVABILITY_TO_DEFAULT_APP || !app.getAssetPrefix() ? {} : {
1988
+ NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH: `/${app.getAssetPrefix()}/_vercel`
1989
+ }
2003
1990
  };
2004
1991
  const serverEnvs = {
2005
1992
  MFE_CURRENT_APPLICATION: app.name,
@@ -2017,13 +2004,13 @@ function typedEntries(obj) {
2017
2004
  return Object.entries(obj);
2018
2005
  }
2019
2006
  function isProduction(opts) {
2020
- if (opts == null ? void 0 : opts.isProduction) {
2007
+ if (opts?.isProduction) {
2021
2008
  return opts.isProduction();
2022
2009
  }
2023
2010
  return process.env.VERCEL_ENV === "production";
2024
2011
  }
2025
2012
  function getApplicationContext(opts) {
2026
- if (opts == null ? void 0 : opts.appName) {
2013
+ if (opts?.appName) {
2027
2014
  return { name: opts.appName };
2028
2015
  }
2029
2016
  try {
@@ -2047,13 +2034,12 @@ function getApplicationContext(opts) {
2047
2034
  }
2048
2035
  }
2049
2036
  function withMicrofrontends(nextConfig, opts) {
2050
- var _a;
2051
- if (opts == null ? void 0 : opts.debug) {
2037
+ if (opts?.debug) {
2052
2038
  process.env.MFE_DEBUG = "true";
2053
2039
  }
2054
2040
  const { name: fromApp } = getApplicationContext(opts);
2055
2041
  const microfrontends = MicrofrontendsServer.infer({
2056
- filePath: opts == null ? void 0 : opts.configPath,
2042
+ filePath: opts?.configPath,
2057
2043
  meta: {
2058
2044
  fromApp
2059
2045
  }
@@ -2062,7 +2048,7 @@ function withMicrofrontends(nextConfig, opts) {
2062
2048
  setEnvironment({ app, microfrontends });
2063
2049
  let next = { ...nextConfig };
2064
2050
  for (const [key, transform7] of typedEntries(transforms)) {
2065
- if ((_a = opts == null ? void 0 : opts.skipTransforms) == null ? void 0 : _a.includes(key)) {
2051
+ if (opts?.skipTransforms?.includes(key)) {
2066
2052
  console.log(`Skipping ${key} transform`);
2067
2053
  continue;
2068
2054
  }
@@ -2078,12 +2064,10 @@ function withMicrofrontends(nextConfig, opts) {
2078
2064
  next = transformedConfig.next;
2079
2065
  } catch (e) {
2080
2066
  console.error("Error transforming next config", e);
2067
+ throw e;
2081
2068
  }
2082
2069
  }
2083
2070
  displayLocalProxyInfo(microfrontends.config.getLocalProxyPort());
2084
- if (isVercel()) {
2085
- microfrontends.writeConfig();
2086
- }
2087
2071
  return next;
2088
2072
  }
2089
2073
  export {