@vercel/microfrontends 0.9.0 → 0.10.1

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 (90) hide show
  1. package/README.md +7 -7
  2. package/dist/bin/cli.cjs +1604 -221
  3. package/dist/config/client.d.ts +1 -1
  4. package/dist/config/edge.cjs +47 -47
  5. package/dist/config/edge.cjs.map +1 -1
  6. package/dist/config/edge.d.ts +6 -6
  7. package/dist/config/edge.js +46 -46
  8. package/dist/config/edge.js.map +1 -1
  9. package/dist/config.cjs +67 -66
  10. package/dist/config.cjs.map +1 -1
  11. package/dist/config.d.ts +4 -4
  12. package/dist/config.js +66 -65
  13. package/dist/config.js.map +1 -1
  14. package/dist/{index-eff254d8.d.ts → index-acb44057.d.ts} +12 -23
  15. package/dist/{micro-frontend-config-42886104.d.ts → microfrontend-config-983a5139.d.ts} +13 -13
  16. package/dist/next/client.cjs +1 -1
  17. package/dist/next/client.cjs.map +1 -1
  18. package/dist/next/client.js +1 -1
  19. package/dist/next/client.js.map +1 -1
  20. package/dist/next/config.cjs +86 -87
  21. package/dist/next/config.cjs.map +1 -1
  22. package/dist/next/config.d.ts +3 -3
  23. package/dist/next/config.js +85 -86
  24. package/dist/next/config.js.map +1 -1
  25. package/dist/next/middleware.cjs +60 -62
  26. package/dist/next/middleware.cjs.map +1 -1
  27. package/dist/next/middleware.d.ts +11 -11
  28. package/dist/next/middleware.js +58 -60
  29. package/dist/next/middleware.js.map +1 -1
  30. package/dist/next/testing.cjs +80 -79
  31. package/dist/next/testing.cjs.map +1 -1
  32. package/dist/next/testing.d.ts +10 -10
  33. package/dist/next/testing.js +80 -79
  34. package/dist/next/testing.js.map +1 -1
  35. package/dist/overrides.cjs +9 -9
  36. package/dist/overrides.cjs.map +1 -1
  37. package/dist/overrides.d.ts +2 -2
  38. package/dist/overrides.js +9 -9
  39. package/dist/overrides.js.map +1 -1
  40. package/dist/{schema-83a75e61.d.ts → schema-2922d49e.d.ts} +1 -7
  41. package/dist/{types-4fd1c7c6.d.ts → types-7b1cd9f7.d.ts} +1 -7
  42. package/dist/types-c3d15d04.d.ts +15 -0
  43. package/dist/v2/config.cjs +39 -39
  44. package/dist/v2/config.cjs.map +1 -1
  45. package/dist/v2/config.d.ts +3 -2
  46. package/dist/v2/config.js +38 -38
  47. package/dist/v2/config.js.map +1 -1
  48. package/dist/v2/microfrontends/server.cjs +223 -96
  49. package/dist/v2/microfrontends/server.cjs.map +1 -1
  50. package/dist/v2/microfrontends/server.d.ts +11 -3
  51. package/dist/v2/microfrontends/server.js +223 -96
  52. package/dist/v2/microfrontends/server.js.map +1 -1
  53. package/dist/v2/microfrontends.cjs +44 -44
  54. package/dist/v2/microfrontends.cjs.map +1 -1
  55. package/dist/v2/microfrontends.d.ts +6 -5
  56. package/dist/v2/microfrontends.js +44 -44
  57. package/dist/v2/microfrontends.js.map +1 -1
  58. package/dist/v2/next/client.cjs +1 -1
  59. package/dist/v2/next/client.cjs.map +1 -1
  60. package/dist/v2/next/client.js +1 -1
  61. package/dist/v2/next/client.js.map +1 -1
  62. package/dist/v2/next/config.cjs +247 -122
  63. package/dist/v2/next/config.cjs.map +1 -1
  64. package/dist/v2/next/config.d.ts +4 -4
  65. package/dist/v2/next/config.js +246 -121
  66. package/dist/v2/next/config.js.map +1 -1
  67. package/dist/v2/next/endpoints.cjs +5 -5
  68. package/dist/v2/next/endpoints.cjs.map +1 -1
  69. package/dist/v2/next/endpoints.js +5 -5
  70. package/dist/v2/next/endpoints.js.map +1 -1
  71. package/dist/v2/next/middleware.cjs +55 -55
  72. package/dist/v2/next/middleware.cjs.map +1 -1
  73. package/dist/v2/next/middleware.d.ts +8 -8
  74. package/dist/v2/next/middleware.js +53 -53
  75. package/dist/v2/next/middleware.js.map +1 -1
  76. package/dist/v2/overrides.cjs +75 -0
  77. package/dist/v2/overrides.cjs.map +1 -0
  78. package/dist/v2/overrides.d.ts +24 -0
  79. package/dist/v2/overrides.js +45 -0
  80. package/dist/v2/overrides.js.map +1 -0
  81. package/dist/v2/schema.cjs.map +1 -1
  82. package/dist/v2/schema.d.ts +1 -1
  83. package/dist/validation.cjs +20 -28
  84. package/dist/validation.cjs.map +1 -1
  85. package/dist/validation.d.ts +2 -8
  86. package/dist/validation.js +20 -28
  87. package/dist/validation.js.map +1 -1
  88. package/package.json +15 -7
  89. package/schema/schema-v2.json +0 -4
  90. package/schema/schema.json +0 -4
@@ -52,7 +52,7 @@ var import_web = require("next/dist/server/base-http/web");
52
52
  // src/config/types.ts
53
53
  var isDefaultApplicationConfig = (app) => app.default && typeof app.routing === "undefined";
54
54
 
55
- // src/config/micro-frontend-config.ts
55
+ // src/config/microfrontend-config.ts
56
56
  var import_node_fs2 = __toESM(require("fs"), 1);
57
57
 
58
58
  // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
@@ -80,14 +80,14 @@ function getOutputFilePath() {
80
80
  }
81
81
 
82
82
  // src/config/errors.ts
83
- var MicroFrontendError = class extends Error {
83
+ var MicrofrontendError = class extends Error {
84
84
  constructor(message, opts) {
85
85
  super(message);
86
- this.name = "MicroFrontendsError";
87
- this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/micro-frontends";
86
+ this.name = "MicrofrontendsError";
87
+ this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
88
88
  this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
89
89
  this.subtype = opts == null ? void 0 : opts.subtype;
90
- Error.captureStackTrace(this, MicroFrontendError);
90
+ Error.captureStackTrace(this, MicrofrontendError);
91
91
  }
92
92
  isKnown() {
93
93
  return this.type !== "unknown";
@@ -96,13 +96,13 @@ var MicroFrontendError = class extends Error {
96
96
  return !this.isKnown();
97
97
  }
98
98
  /**
99
- * Converts an error to a MicroFrontendsError.
99
+ * Converts an error to a MicrofrontendsError.
100
100
  * @param original - The original error to convert.
101
- * @returns The converted MicroFrontendsError.
101
+ * @returns The converted MicrofrontendsError.
102
102
  */
103
103
  static convert(original, opts) {
104
104
  if (opts == null ? void 0 : opts.fileName) {
105
- const err = MicroFrontendError.convertFSError(original, opts.fileName);
105
+ const err = MicrofrontendError.convertFSError(original, opts.fileName);
106
106
  if (err) {
107
107
  return err;
108
108
  }
@@ -110,25 +110,25 @@ var MicroFrontendError = class extends Error {
110
110
  if (original.message.includes(
111
111
  "Code generation from strings disallowed for this context"
112
112
  )) {
113
- return new MicroFrontendError(original.message, {
113
+ return new MicrofrontendError(original.message, {
114
114
  type: "config",
115
115
  subtype: "unsupported_validation_env",
116
116
  source: "ajv"
117
117
  });
118
118
  }
119
- return new MicroFrontendError(original.message);
119
+ return new MicrofrontendError(original.message);
120
120
  }
121
121
  static convertFSError(original, fileName) {
122
122
  if (original instanceof Error && "code" in original) {
123
123
  if (original.code === "ENOENT") {
124
- return new MicroFrontendError(`Could not find "${fileName}"`, {
124
+ return new MicrofrontendError(`Could not find "${fileName}"`, {
125
125
  type: "config",
126
126
  subtype: "unable_to_read_file",
127
127
  source: "fs"
128
128
  });
129
129
  }
130
130
  if (original.code === "EACCES") {
131
- return new MicroFrontendError(
131
+ return new MicrofrontendError(
132
132
  `Permission denied while accessing "${fileName}"`,
133
133
  {
134
134
  type: "config",
@@ -139,7 +139,7 @@ var MicroFrontendError = class extends Error {
139
139
  }
140
140
  }
141
141
  if (original instanceof SyntaxError) {
142
- return new MicroFrontendError(
142
+ return new MicrofrontendError(
143
143
  `Failed to parse "${fileName}": Invalid JSON format.`,
144
144
  {
145
145
  type: "config",
@@ -151,23 +151,23 @@ var MicroFrontendError = class extends Error {
151
151
  return null;
152
152
  }
153
153
  /**
154
- * Handles an unknown error and returns a MicroFrontendsError instance.
154
+ * Handles an unknown error and returns a MicrofrontendsError instance.
155
155
  * @param err - The error to handle.
156
- * @returns A MicroFrontendsError instance.
156
+ * @returns A MicrofrontendsError instance.
157
157
  */
158
158
  static handle(err, opts) {
159
- if (err instanceof MicroFrontendError) {
159
+ if (err instanceof MicrofrontendError) {
160
160
  return err;
161
161
  }
162
162
  if (err instanceof Error) {
163
- return MicroFrontendError.convert(err, opts);
163
+ return MicrofrontendError.convert(err, opts);
164
164
  }
165
165
  if (typeof err === "object" && err !== null) {
166
166
  if ("message" in err && typeof err.message === "string") {
167
- return MicroFrontendError.convert(new Error(err.message), opts);
167
+ return MicrofrontendError.convert(new Error(err.message), opts);
168
168
  }
169
169
  }
170
- return new MicroFrontendError("An unknown error occurred");
170
+ return new MicrofrontendError("An unknown error occurred");
171
171
  }
172
172
  };
173
173
 
@@ -250,27 +250,27 @@ var _Overrides = class {
250
250
  });
251
251
  return overridesConfig;
252
252
  }
253
- static validOverrideDomainsForZone(microFrontendConfig, zone) {
253
+ static validOverrideDomainsForZone(microfrontendConfig, zone) {
254
254
  var _a, _b, _c, _d, _e;
255
- const projectName = (_a = microFrontendConfig.getZone(zone).vercel) == null ? void 0 : _a.projectName;
255
+ const projectName = (_a = microfrontendConfig.getZone(zone).vercel) == null ? void 0 : _a.projectName;
256
256
  if (!projectName) {
257
- return [microFrontendConfig.getZone(zone).production.host];
257
+ return [microfrontendConfig.getZone(zone).production.host];
258
258
  }
259
259
  const parsedProjectName = makeUrlSafe(projectName);
260
- const previewDeploymentSuffix = (_c = (_b = microFrontendConfig.options) == null ? void 0 : _b.vercel) == null ? void 0 : _c.previewDeploymentSuffix;
261
- const teamSlug = (_e = (_d = microFrontendConfig.options) == null ? void 0 : _d.vercel) == null ? void 0 : _e.teamSlug;
260
+ const previewDeploymentSuffix = (_c = (_b = microfrontendConfig.options) == null ? void 0 : _b.vercel) == null ? void 0 : _c.previewDeploymentSuffix;
261
+ const teamSlug = (_e = (_d = microfrontendConfig.options) == null ? void 0 : _d.vercel) == null ? void 0 : _e.teamSlug;
262
262
  if (!teamSlug && !previewDeploymentSuffix) {
263
- return [microFrontendConfig.getZone(zone).production.host];
263
+ return [microfrontendConfig.getZone(zone).production.host];
264
264
  }
265
265
  const suffix = previewDeploymentSuffix ? `.${previewDeploymentSuffix}` : `-${teamSlug}.vercel.app`;
266
266
  return [
267
267
  `${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,
268
- microFrontendConfig.getZone(zone).production.host
268
+ microfrontendConfig.getZone(zone).production.host
269
269
  ];
270
270
  }
271
- static validateOverrideDomain(microFrontendConfig, zone, domain) {
271
+ static validateOverrideDomain(microfrontendConfig, zone, domain) {
272
272
  return new RegExp(
273
- `^${_Overrides.validOverrideDomainsForZone(microFrontendConfig, zone).join(
273
+ `^${_Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(
274
274
  "|"
275
275
  )}$`
276
276
  ).test(domain);
@@ -352,7 +352,7 @@ var Application = class {
352
352
  static validate(name, app) {
353
353
  var _a, _b, _c, _d, _e;
354
354
  if (((_b = (_a = app.routing) == null ? void 0 : _a.assetPrefix) == null ? void 0 : _b.startsWith("/")) || ((_d = (_c = app.routing) == null ? void 0 : _c.assetPrefix) == null ? void 0 : _d.endsWith("/"))) {
355
- throw new MicroFrontendError(
355
+ throw new MicrofrontendError(
356
356
  `Invalid assetPrefix for application "${name}". Must not start or end with a slash.`,
357
357
  { type: "zone", subtype: "invalid_asset_prefix" }
358
358
  );
@@ -363,13 +363,13 @@ var Application = class {
363
363
  continue;
364
364
  }
365
365
  if (p.endsWith("/")) {
366
- throw new MicroFrontendError(
366
+ throw new MicrofrontendError(
367
367
  `Invalid path for application "${name}". ${p} must not end with a slash.`,
368
368
  { type: "zone", subtype: "invalid_path" }
369
369
  );
370
370
  }
371
371
  if (!p.startsWith("/")) {
372
- throw new MicroFrontendError(
372
+ throw new MicrofrontendError(
373
373
  `Invalid path for application "${name}". ${p} must start with a slash.`,
374
374
  { type: "zone", subtype: "invalid_path" }
375
375
  );
@@ -403,10 +403,10 @@ var Application = class {
403
403
  }
404
404
  };
405
405
 
406
- // src/config/common/micro-frontend-config.ts
406
+ // src/config/common/microfrontend-config.ts
407
407
  var SUPPORTED_VERSIONS = ["1"];
408
408
  var DEFAULT_LOCAL_PROXY_PORT = 3024;
409
- var MicroFrontendConfigCommon = class {
409
+ var MicrofrontendConfigCommon = class {
410
410
  constructor({
411
411
  config,
412
412
  overrides
@@ -414,7 +414,7 @@ var MicroFrontendConfigCommon = class {
414
414
  this.zones = {};
415
415
  var _a, _b, _c;
416
416
  if (!SUPPORTED_VERSIONS.includes(config.version)) {
417
- throw new MicroFrontendError(
417
+ throw new MicrofrontendError(
418
418
  `Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
419
419
  ", "
420
420
  )}`,
@@ -442,7 +442,7 @@ var MicroFrontendConfigCommon = class {
442
442
  static getConfigFromEnv() {
443
443
  const config = process.env.MFE_CONFIG;
444
444
  if (!config) {
445
- throw new MicroFrontendError(`Missing "MFE_CONFIG" in environment.`, {
445
+ throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
446
446
  type: "config",
447
447
  subtype: "not_found_in_env"
448
448
  });
@@ -461,8 +461,8 @@ var MicroFrontendConfigCommon = class {
461
461
  getZone(name) {
462
462
  const zone = this.zones[name];
463
463
  if (!zone) {
464
- throw new MicroFrontendError(
465
- `Could not find micro-frontends configuration for application "${name}"`,
464
+ throw new MicrofrontendError(
465
+ `Could not find microfrontends configuration for application "${name}"`,
466
466
  {
467
467
  type: "zone",
468
468
  subtype: "not_found"
@@ -482,8 +482,8 @@ var MicroFrontendConfigCommon = class {
482
482
  getDefaultZone() {
483
483
  const zone = Object.values(this.zones).find((z) => z.default);
484
484
  if (!zone) {
485
- throw new MicroFrontendError(
486
- `Could not find default zone in micro-frontends configuration`,
485
+ throw new MicrofrontendError(
486
+ `Could not find default zone in microfrontends configuration`,
487
487
  {
488
488
  type: "zone",
489
489
  subtype: "not_found"
@@ -535,8 +535,8 @@ var MicroFrontendConfigCommon = class {
535
535
  };
536
536
  }
537
537
  write(_) {
538
- throw new MicroFrontendError(
539
- `Writing to file to disk requires using an instance of "MicroFrontendConfig".`,
538
+ throw new MicrofrontendError(
539
+ `Writing to file to disk requires using an instance of "MicrofrontendConfig".`,
540
540
  { type: "config", subtype: "unsupported_operation" }
541
541
  );
542
542
  }
@@ -715,10 +715,6 @@ var schema_default = {
715
715
  flag: {
716
716
  type: "string",
717
717
  description: "flag name that can be used to enable/disable all paths in the group"
718
- },
719
- routeToDefaultApplication: {
720
- type: "boolean",
721
- description: "True to route the request to the default application for this micro-frontends set-up. This must be `true` when using `flag` or when you want to use custom logic to make the routing decision for this group of paths."
722
718
  }
723
719
  }
724
720
  },
@@ -897,7 +893,7 @@ var validateSchema = (configString) => {
897
893
  const validate = ajv.compile(SCHEMA);
898
894
  const isValid = validate(parsedConfig);
899
895
  if (!isValid) {
900
- throw new MicroFrontendError(
896
+ throw new MicrofrontendError(
901
897
  `Invalid config: ${ajv.errorsText(validate.errors)}`,
902
898
  { type: "config", subtype: "does_not_match_schema" }
903
899
  );
@@ -907,7 +903,7 @@ var validateSchema = (configString) => {
907
903
  var SUPPORTED_VERSIONS2 = ["1"];
908
904
  var validateVersion = (version) => {
909
905
  if (!SUPPORTED_VERSIONS2.includes(version)) {
910
- throw new MicroFrontendError(
906
+ throw new MicrofrontendError(
911
907
  `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS2.join(
912
908
  ", "
913
909
  )}`,
@@ -940,7 +936,7 @@ function validateMainPath(applicationConfigsById) {
940
936
  return !matcher.test(defaultRoute);
941
937
  });
942
938
  if (!isValid) {
943
- throw new MicroFrontendError(
939
+ throw new MicrofrontendError(
944
940
  `default route "${defaultRoute}" cannot be used for "${id}" because it is matched by "${otherId}"`,
945
941
  { type: "config", subtype: "invalid_main_path" }
946
942
  );
@@ -953,7 +949,7 @@ function validateMainPath(applicationConfigsById) {
953
949
  return matcher.test(defaultRoute);
954
950
  });
955
951
  if (!isValid) {
956
- throw new MicroFrontendError(
952
+ throw new MicrofrontendError(
957
953
  `default route "${defaultRoute}" is not included by the routing config for application "${id}"`,
958
954
  { type: "config", subtype: "invalid_main_path" }
959
955
  );
@@ -1016,7 +1012,7 @@ var validatePaths = (applicationConfigsById) => {
1016
1012
  );
1017
1013
  });
1018
1014
  if (errors.length) {
1019
- throw new MicroFrontendError(`Invalid paths: ${errors.join(", ")}`, {
1015
+ throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
1020
1016
  type: "config",
1021
1017
  subtype: "conflicting_paths"
1022
1018
  });
@@ -1050,13 +1046,13 @@ function validatePathExpression(path3) {
1050
1046
  var validateDefaults = (applicationConfigsById) => {
1051
1047
  const defaultApplicationIds = Object.entries(applicationConfigsById).reduce((acc, [id, app]) => app.default ? [...acc, id] : acc, []);
1052
1048
  if (defaultApplicationIds.length === 0) {
1053
- throw new MicroFrontendError(
1049
+ throw new MicrofrontendError(
1054
1050
  `No default application found. At least one application must be marked as default.`,
1055
1051
  { type: "config", subtype: "no_default_application" }
1056
1052
  );
1057
1053
  }
1058
1054
  if (defaultApplicationIds.length > 1) {
1059
- throw new MicroFrontendError(
1055
+ throw new MicrofrontendError(
1060
1056
  `Only one default application is allowed. Found ${defaultApplicationIds.join(", ")}.`,
1061
1057
  { type: "config", subtype: "multiple_default_applications" }
1062
1058
  );
@@ -1068,7 +1064,7 @@ var validateOptions = (options) => {
1068
1064
  if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
1069
1065
  options.vercel.previewDeploymentSuffix
1070
1066
  )) {
1071
- throw new MicroFrontendError(
1067
+ throw new MicrofrontendError(
1072
1068
  `Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
1073
1069
  { type: "config", subtype: "invalid_preview_deployment_suffix" }
1074
1070
  );
@@ -1079,11 +1075,10 @@ var validateOptions = (options) => {
1079
1075
  // src/config/utils/convert.ts
1080
1076
  function convertV1RoutingToV2Routing(routing) {
1081
1077
  return routing.matches.map((group) => {
1082
- var _a, _b;
1078
+ var _a;
1083
1079
  return {
1084
1080
  group: group.group,
1085
1081
  flag: (_a = group.options) == null ? void 0 : _a.flag,
1086
- routeToDefaultApplication: (_b = group.options) == null ? void 0 : _b.routeToDefaultApplication,
1087
1082
  paths: group.paths
1088
1083
  };
1089
1084
  });
@@ -1123,9 +1118,15 @@ function convertV1ConfigToV2Config(config, fromApp) {
1123
1118
  )
1124
1119
  };
1125
1120
  }
1121
+ const defaultApplication = Object.entries(config.applications).find(
1122
+ ([, application]) => application.default
1123
+ );
1124
+ if (!defaultApplication) {
1125
+ throw new Error("No default application found in the config");
1126
+ }
1126
1127
  return {
1127
1128
  ...common,
1128
- partOf: fromApp
1129
+ partOf: defaultApplication[0]
1129
1130
  };
1130
1131
  }
1131
1132
 
@@ -1140,8 +1141,8 @@ function writeFile(outputPath, config, prettify) {
1140
1141
  );
1141
1142
  }
1142
1143
 
1143
- // src/config/micro-frontend-config.ts
1144
- var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
1144
+ // src/config/microfrontend-config.ts
1145
+ var MicrofrontendConfig = class extends MicrofrontendConfigCommon {
1145
1146
  static validate(configString) {
1146
1147
  const config = validateSchema(configString);
1147
1148
  validateVersion(config.version);
@@ -1154,9 +1155,9 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
1154
1155
  static fromEnv({
1155
1156
  cookies
1156
1157
  }) {
1157
- return new MicroFrontendConfigCommon({
1158
- config: MicroFrontendConfig.validate(
1159
- MicroFrontendConfigCommon.getConfigFromEnv()
1158
+ return new MicrofrontendConfigCommon({
1159
+ config: MicrofrontendConfig.validate(
1160
+ MicrofrontendConfigCommon.getConfigFromEnv()
1160
1161
  ),
1161
1162
  overrides: Overrides.parseOverrides(cookies)
1162
1163
  });
@@ -1166,11 +1167,11 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
1166
1167
  }) {
1167
1168
  try {
1168
1169
  const config = import_node_fs2.default.readFileSync(filePath, "utf-8");
1169
- return new MicroFrontendConfig({
1170
- config: MicroFrontendConfig.validate(config)
1170
+ return new MicrofrontendConfig({
1171
+ config: MicrofrontendConfig.validate(config)
1171
1172
  });
1172
1173
  } catch (e) {
1173
- throw MicroFrontendError.handle(e, {
1174
+ throw MicrofrontendError.handle(e, {
1174
1175
  fileName: filePath
1175
1176
  });
1176
1177
  }
@@ -1215,7 +1216,7 @@ function expandWildcards(path3) {
1215
1216
  }
1216
1217
  function loadMicrofrontendConfigForEdge(path3) {
1217
1218
  const rawMfConfig = (0, import_jsonc_parser2.parse)((0, import_node_fs3.readFileSync)(path3, "utf-8"));
1218
- return new MicroFrontendConfig({ config: rawMfConfig });
1219
+ return new MicrofrontendConfig({ config: rawMfConfig });
1219
1220
  }
1220
1221
  function getAllZoneNames(mfConfig) {
1221
1222
  return mfConfig.getAllApplications().filter((app) => !app.default).map((app) => app.name);
@@ -1277,12 +1278,12 @@ function urlMatches(middlewareConfig, path3, host) {
1277
1278
  }
1278
1279
  return false;
1279
1280
  }
1280
- function validateMiddlewareConfig(middlewareConfig, microFrontendConfigOrPath, extraProductionMatches) {
1281
+ function validateMiddlewareConfig(middlewareConfig, microfrontendConfigOrPath, extraProductionMatches) {
1281
1282
  var _a, _b;
1282
- const microFrontendConfig = typeof microFrontendConfigOrPath === "string" ? loadMicrofrontendConfigForEdge(microFrontendConfigOrPath) : microFrontendConfigOrPath;
1283
+ const microfrontendConfig = typeof microfrontendConfigOrPath === "string" ? loadMicrofrontendConfigForEdge(microfrontendConfigOrPath) : microfrontendConfigOrPath;
1283
1284
  const errors = [];
1284
1285
  const usedExtraProductionMatches = /* @__PURE__ */ new Set();
1285
- for (const application of microFrontendConfig.getAllApplications()) {
1286
+ for (const application of microfrontendConfig.getAllApplications()) {
1286
1287
  if ((_a = application.routing) == null ? void 0 : _a.matches) {
1287
1288
  const matches = [...application.routing.matches];
1288
1289
  if (application.routing.assetPrefix) {
@@ -1299,14 +1300,14 @@ function validateMiddlewareConfig(middlewareConfig, microFrontendConfigOrPath, e
1299
1300
  if (!urlMatches(middlewareConfig, testPath, "test.nonproduction.host")) {
1300
1301
  errors.push(
1301
1302
  `Matcher misconfigured for ${pathForDisplay}. This path should have matched the middleware config on a non-production host, but did not. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. That can be configured with a configuration like this:
1302
- ${getSampleMatcher(path3, microFrontendConfig.getDefaultZone().production.host)}`
1303
+ ${getSampleMatcher(path3, microfrontendConfig.getDefaultZone().production.host)}`
1303
1304
  );
1304
1305
  break;
1305
1306
  }
1306
1307
  const productionUrlMatches = urlMatches(
1307
1308
  middlewareConfig,
1308
1309
  testPath,
1309
- microFrontendConfig.getDefaultZone().production.host
1310
+ microfrontendConfig.getDefaultZone().production.host
1310
1311
  );
1311
1312
  if (isFlagged) {
1312
1313
  if (!productionUrlMatches) {
@@ -1321,7 +1322,7 @@ ${getSampleMatcher(path3, microFrontendConfig.getDefaultZone().production.host)}
1321
1322
  } else {
1322
1323
  errors.push(
1323
1324
  `Matcher misconfigured for ${pathForDisplay}. This path matched the middleware config on a production host, but should not have. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. If this is desired, you can add the path the to extraProductionMatches parameter. Otherwise, you can set up a configuration like this:
1324
- ${getSampleMatcher(path3, microFrontendConfig.getDefaultZone().production.host)}`
1325
+ ${getSampleMatcher(path3, microfrontendConfig.getDefaultZone().production.host)}`
1325
1326
  );
1326
1327
  }
1327
1328
  break;
@@ -1340,7 +1341,7 @@ ${getSampleMatcher(path3, microFrontendConfig.getDefaultZone().production.host)}
1340
1341
  );
1341
1342
  }
1342
1343
  if (errors.length > 0) {
1343
- const message = `Found the following inconsistencies between your microfrontend config ${typeof microFrontendConfigOrPath === "string" ? `(at ${microFrontendConfigOrPath}) ` : ""}and middleware config:
1344
+ const message = `Found the following inconsistencies between your microfrontend config ${typeof microfrontendConfigOrPath === "string" ? `(at ${microfrontendConfigOrPath}) ` : ""}and middleware config:
1344
1345
 
1345
1346
  - `;
1346
1347
  throw new Error(message + errors.join("\n\n- "));
@@ -1356,26 +1357,26 @@ function getSampleMatcher(path3, host) {
1356
1357
  ],
1357
1358
  }`;
1358
1359
  }
1359
- async function validateMiddlewareOnFlaggedPaths(microFrontendConfigOrPath, middleware) {
1360
+ async function validateMiddlewareOnFlaggedPaths(microfrontendConfigOrPath, middleware) {
1360
1361
  const initialEnv = process.env.VERCEL_ENV;
1361
1362
  const initialMfePreviewDomains = process.env.MFE_PREVIEW_DOMAINS;
1362
1363
  try {
1363
- const microFrontendConfig = typeof microFrontendConfigOrPath === "string" ? loadMicrofrontendConfigForEdge(microFrontendConfigOrPath) : microFrontendConfigOrPath;
1364
- const fakePreviewDomains = createFakePreviewDomains(microFrontendConfig);
1364
+ const microfrontendConfig = typeof microfrontendConfigOrPath === "string" ? loadMicrofrontendConfigForEdge(microfrontendConfigOrPath) : microfrontendConfigOrPath;
1365
+ const fakePreviewDomains = createFakePreviewDomains(microfrontendConfig);
1365
1366
  process.env.MFE_PREVIEW_DOMAINS = JSON.stringify(fakePreviewDomains);
1366
- const allZoneNames = getAllZoneNames(microFrontendConfig);
1367
+ const allZoneNames = getAllZoneNames(microfrontendConfig);
1367
1368
  const errors = [];
1368
1369
  for (const zoneName of allZoneNames) {
1369
1370
  const flaggedPaths = getFlaggedPathsForZone(
1370
- microFrontendConfig,
1371
+ microfrontendConfig,
1371
1372
  zoneName
1372
1373
  );
1373
1374
  if (flaggedPaths.length) {
1374
1375
  for (const env of ["preview", "production"]) {
1375
1376
  process.env.VERCEL_ENV = env;
1376
1377
  for (const path3 of flaggedPaths) {
1377
- const expectedHost = env === "preview" ? fakePreviewDomains[zoneName] : getExpectedDomainForZone(microFrontendConfig, zoneName, env);
1378
- const requestPath = `https://${microFrontendConfig.getDefaultZone().production.host}${path3}`;
1378
+ const expectedHost = env === "preview" ? fakePreviewDomains[zoneName] : getExpectedDomainForZone(microfrontendConfig, zoneName, env);
1379
+ const requestPath = `https://${microfrontendConfig.getDefaultZone().production.host}${path3}`;
1379
1380
  const request = new import_server.NextRequest(requestPath, {
1380
1381
  headers: { "x-vercel-skip-deployment-existence-check": "1" }
1381
1382
  });