@vercel/microfrontends 0.17.4 → 0.19.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 (53) hide show
  1. package/README.md +7 -159
  2. package/dist/bin/cli.cjs +202 -139
  3. package/dist/config.cjs +103 -57
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +4 -4
  6. package/dist/config.js +103 -57
  7. package/dist/config.js.map +1 -1
  8. package/dist/{index-f094deb1.d.ts → index-09b1ddf9.d.ts} +16 -19
  9. package/dist/{index-5fcf0863.d.ts → index-2f78c0ca.d.ts} +44 -17
  10. package/dist/microfrontends/server.cjs +180 -133
  11. package/dist/microfrontends/server.cjs.map +1 -1
  12. package/dist/microfrontends/server.d.ts +4 -4
  13. package/dist/microfrontends/server.js +180 -133
  14. package/dist/microfrontends/server.js.map +1 -1
  15. package/dist/microfrontends.cjs +104 -58
  16. package/dist/microfrontends.cjs.map +1 -1
  17. package/dist/microfrontends.d.ts +4 -4
  18. package/dist/microfrontends.js +104 -58
  19. package/dist/microfrontends.js.map +1 -1
  20. package/dist/next/client.cjs +1 -1
  21. package/dist/next/client.cjs.map +1 -1
  22. package/dist/next/client.d.ts +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 +197 -145
  26. package/dist/next/config.cjs.map +1 -1
  27. package/dist/next/config.js +197 -145
  28. package/dist/next/config.js.map +1 -1
  29. package/dist/next/endpoints.d.ts +2 -2
  30. package/dist/next/middleware.cjs +121 -80
  31. package/dist/next/middleware.cjs.map +1 -1
  32. package/dist/next/middleware.js +121 -80
  33. package/dist/next/middleware.js.map +1 -1
  34. package/dist/next/testing.cjs +110 -63
  35. package/dist/next/testing.cjs.map +1 -1
  36. package/dist/next/testing.d.ts +4 -4
  37. package/dist/next/testing.js +110 -63
  38. package/dist/next/testing.js.map +1 -1
  39. package/dist/overrides.d.ts +3 -3
  40. package/dist/schema.d.ts +1 -1
  41. package/dist/{types-5900be7c.d.ts → types-4ef2bddb.d.ts} +1 -1
  42. package/dist/{types-ecd7b91b.d.ts → types-b6d38aea.d.ts} +1 -1
  43. package/dist/utils/mfe-port.cjs +181 -134
  44. package/dist/utils/mfe-port.cjs.map +1 -1
  45. package/dist/utils/mfe-port.js +181 -134
  46. package/dist/utils/mfe-port.js.map +1 -1
  47. package/dist/validation.cjs +74 -73
  48. package/dist/validation.cjs.map +1 -1
  49. package/dist/validation.d.ts +1 -1
  50. package/dist/validation.js +74 -73
  51. package/dist/validation.js.map +1 -1
  52. package/package.json +19 -3
  53. package/schema/schema.json +80 -73
@@ -42,7 +42,7 @@ function parseOverrides(cookies) {
42
42
  // src/config/errors.ts
43
43
  var MicrofrontendError = class extends Error {
44
44
  constructor(message, opts) {
45
- super(message);
45
+ super(message, { cause: opts?.cause });
46
46
  this.name = "MicrofrontendsError";
47
47
  this.source = opts?.source ?? "@vercel/microfrontends";
48
48
  this.type = opts?.type ?? "unknown";
@@ -234,7 +234,8 @@ var validateConfigPaths = (applicationConfigsById) => {
234
234
  if (isDefaultApp(app)) {
235
235
  continue;
236
236
  }
237
- for (const pathMatch of app.routing) {
237
+ const childApp = app;
238
+ for (const pathMatch of childApp.routing) {
238
239
  for (const path6 of pathMatch.paths) {
239
240
  const maybeError = validatePathExpression(path6);
240
241
  if (maybeError) {
@@ -254,33 +255,31 @@ var validateConfigPaths = (applicationConfigsById) => {
254
255
  }
255
256
  }
256
257
  const entries = Array.from(pathsByApplicationId.entries());
257
- entries.forEach(([path6, { applications: ids, matcher, applicationId }]) => {
258
+ for (const [path6, { applications: ids, matcher, applicationId }] of entries) {
258
259
  if (ids.length > 1) {
259
260
  errors.push(
260
261
  `Duplicate path "${path6}" for applications "${ids.join(", ")}"`
261
262
  );
262
263
  }
263
- entries.forEach(
264
- ([
265
- matchPath,
266
- { applications: matchIds, applicationId: matchApplicationId }
267
- ]) => {
268
- if (path6 === matchPath) {
269
- return;
270
- }
271
- if (applicationId === matchApplicationId) {
272
- return;
273
- }
274
- if (matcher.test(matchPath)) {
275
- const source = `"${path6}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
276
- const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
277
- errors.push(
278
- `Overlapping path detected between ${source} and ${destination}`
279
- );
280
- }
264
+ for (const [
265
+ matchPath,
266
+ { applications: matchIds, applicationId: matchApplicationId }
267
+ ] of entries) {
268
+ if (path6 === matchPath) {
269
+ continue;
281
270
  }
282
- );
283
- });
271
+ if (applicationId === matchApplicationId) {
272
+ continue;
273
+ }
274
+ if (matcher.test(matchPath)) {
275
+ const source = `"${path6}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
276
+ const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
277
+ errors.push(
278
+ `Overlapping path detected between ${source} and ${destination}`
279
+ );
280
+ }
281
+ }
282
+ }
284
283
  if (errors.length) {
285
284
  throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
286
285
  type: "config",
@@ -349,7 +348,7 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
349
348
  const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
350
349
  if (numApplicationsWithoutRouting === 0) {
351
350
  throw new MicrofrontendError(
352
- `No default application found. At least one application needs to be the default by omitting routing.`,
351
+ "No default application found. At least one application needs to be the default by omitting routing.",
353
352
  { type: "config", subtype: "no_default_application" }
354
353
  );
355
354
  }
@@ -395,47 +394,80 @@ function generatePortFromName({
395
394
  // src/config/microfrontends-config/isomorphic/host.ts
396
395
  var Host = class {
397
396
  constructor(hostConfig, options) {
398
- const { protocol = "https", host, port } = hostConfig;
399
- this.protocol = protocol;
400
- this.host = host;
401
- this.port = Host.getPort({ port, protocol: this.protocol });
397
+ if (typeof hostConfig === "string") {
398
+ ({
399
+ protocol: this.protocol,
400
+ host: this.host,
401
+ port: this.port
402
+ } = Host.parseUrl(hostConfig));
403
+ } else {
404
+ const { protocol = "https", host, port } = hostConfig;
405
+ this.protocol = protocol;
406
+ this.host = host;
407
+ this.port = port;
408
+ }
402
409
  this.local = options?.isLocal;
403
410
  }
404
- isLocal() {
405
- return this.local || this.host === "localhost" || this.host === "127.0.0.1";
406
- }
407
- static getPort({
408
- protocol,
409
- port
410
- }) {
411
- if (!port) {
412
- if (protocol === "http") {
413
- return 80;
414
- }
415
- return 443;
411
+ static parseUrl(url) {
412
+ let hostToParse = url;
413
+ if (!/^https?:\/\//.exec(hostToParse)) {
414
+ hostToParse = `https://${hostToParse}`;
415
+ }
416
+ const parsed = new URL(hostToParse);
417
+ if (!parsed.hostname) {
418
+ throw new Error(Host.getMicrofrontendsError(url, "requires a host"));
419
+ }
420
+ if (parsed.hash) {
421
+ throw new Error(
422
+ Host.getMicrofrontendsError(url, "cannot have a fragment")
423
+ );
416
424
  }
417
- return port;
425
+ if (parsed.username || parsed.password) {
426
+ throw new Error(
427
+ Host.getMicrofrontendsError(
428
+ url,
429
+ "cannot have authentication credentials (username and/or password)"
430
+ )
431
+ );
432
+ }
433
+ if (parsed.pathname !== "/") {
434
+ throw new Error(Host.getMicrofrontendsError(url, "cannot have a path"));
435
+ }
436
+ if (parsed.search) {
437
+ throw new Error(
438
+ Host.getMicrofrontendsError(url, "cannot have query parameters")
439
+ );
440
+ }
441
+ const protocol = parsed.protocol.slice(0, -1);
442
+ return {
443
+ protocol,
444
+ host: parsed.hostname,
445
+ port: parsed.port ? Number.parseInt(parsed.port) : void 0
446
+ };
418
447
  }
419
- isDefaultPort() {
420
- return this.port === Host.getPort({ protocol: this.protocol });
448
+ static getMicrofrontendsError(url, message) {
449
+ return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;
450
+ }
451
+ isLocal() {
452
+ return this.local || this.host === "localhost" || this.host === "127.0.0.1";
421
453
  }
422
- toString(opts = {}) {
423
- const url = this.toUrl(opts);
454
+ toString() {
455
+ const url = this.toUrl();
424
456
  return url.toString().replace(/\/$/, "");
425
457
  }
426
- toUrl(opts = {}) {
427
- const { includeDefaultPort } = opts;
428
- const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? "" : `:${this.port}`}`;
458
+ toUrl() {
459
+ const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ""}`;
429
460
  return new URL(url);
430
461
  }
431
462
  };
432
463
  var LocalHost = class extends Host {
433
464
  constructor({
434
465
  appName,
466
+ localPort,
435
467
  ...hostConfig
436
468
  }) {
437
469
  const host = hostConfig.host ?? "localhost";
438
- const port = hostConfig.port ?? generatePortFromName({ name: appName });
470
+ const port = localPort ?? hostConfig.port ?? generatePortFromName({ name: appName });
439
471
  const protocol = hostConfig.protocol ?? "http";
440
472
  super({ protocol, host, port });
441
473
  }
@@ -452,12 +484,17 @@ var Application = class {
452
484
  this.development = {
453
485
  local: new LocalHost({
454
486
  appName: name,
487
+ localPort: app.development?.localPort,
455
488
  ...app.development?.local
456
489
  }),
457
490
  fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
458
491
  };
459
- this.production = app.production ? new Host(app.production) : void 0;
460
- this.vercel = app.vercel;
492
+ if (app.development?.fallback) {
493
+ this.fallback = new Host(app.development.fallback);
494
+ } else if (app.production) {
495
+ this.fallback = new Host(app.production);
496
+ }
497
+ this.projectId = app.projectId ?? app.vercel?.projectId;
461
498
  this.overrides = overrides?.environment ? {
462
499
  environment: new Host(overrides.environment)
463
500
  } : void 0;
@@ -485,7 +522,16 @@ var DefaultApplication = class extends Application {
485
522
  isDefault: true
486
523
  });
487
524
  this.default = true;
488
- this.production = new Host(app.production);
525
+ const fallbackHost = app.development?.fallback ?? app.production;
526
+ if (fallbackHost === void 0) {
527
+ throw new Error(
528
+ "`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
529
+ );
530
+ }
531
+ this.fallback = new Host(fallbackHost);
532
+ if (app.production) {
533
+ this.production = new Host(app.production);
534
+ }
489
535
  }
490
536
  getAssetPrefix() {
491
537
  return "";
@@ -555,7 +601,7 @@ var MicrofrontendConfigIsomorphic = class {
555
601
  }
556
602
  if (isMainConfig(config) && !this.defaultApplication) {
557
603
  throw new MicrofrontendError(
558
- `Could not find default application in microfrontends configuration`,
604
+ "Could not find default application in microfrontends configuration",
559
605
  {
560
606
  type: "application",
561
607
  subtype: "not_found"
@@ -631,11 +677,11 @@ var MicrofrontendConfigIsomorphic = class {
631
677
  return app;
632
678
  }
633
679
  getApplicationByProjectId(projectId) {
634
- if (this.defaultApplication?.vercel?.projectId === projectId) {
680
+ if (this.defaultApplication?.projectId === projectId) {
635
681
  return this.defaultApplication;
636
682
  }
637
683
  return Object.values(this.childApplications).find(
638
- (app) => app.vercel?.projectId === projectId
684
+ (app) => app.projectId === projectId
639
685
  );
640
686
  }
641
687
  /**
@@ -645,7 +691,7 @@ var MicrofrontendConfigIsomorphic = class {
645
691
  getDefaultApplication() {
646
692
  if (!this.defaultApplication) {
647
693
  throw new MicrofrontendError(
648
- `Could not find default application in microfrontends configuration`,
694
+ "Could not find default application in microfrontends configuration",
649
695
  {
650
696
  type: "application",
651
697
  subtype: "not_found"
@@ -658,7 +704,7 @@ var MicrofrontendConfigIsomorphic = class {
658
704
  * Returns the configured port for the local proxy
659
705
  */
660
706
  getLocalProxyPort() {
661
- return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
707
+ return this.config.options?.localProxyPort ?? this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
662
708
  }
663
709
  /**
664
710
  * Serializes the class back to the Schema type.
@@ -732,7 +778,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
732
778
  }
733
779
  if (!defaultApplication) {
734
780
  throw new MicrofrontendError(
735
- `Could not find default application in microfrontends configuration`,
781
+ "Could not find default application in microfrontends configuration",
736
782
  {
737
783
  type: "application",
738
784
  subtype: "not_found"
@@ -1019,24 +1065,12 @@ var schema_default = {
1019
1065
  options: {
1020
1066
  $ref: "#/definitions/Options"
1021
1067
  },
1022
- remotes: {
1023
- type: "object",
1024
- additionalProperties: {
1025
- $ref: "#/definitions/Application"
1026
- },
1027
- propertyNames: {
1028
- description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1029
- },
1030
- 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."
1031
- },
1032
1068
  applications: {
1033
1069
  $ref: "#/definitions/ApplicationRouting",
1034
1070
  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"
1035
1071
  }
1036
1072
  },
1037
- required: [
1038
- "applications"
1039
- ],
1073
+ required: ["applications"],
1040
1074
  additionalProperties: false
1041
1075
  },
1042
1076
  Options: {
@@ -1044,11 +1078,21 @@ var schema_default = {
1044
1078
  properties: {
1045
1079
  vercel: {
1046
1080
  $ref: "#/definitions/VercelOptions",
1047
- description: "Micro-Frontends wide options for Vercel."
1081
+ description: "Microfrontends wide options for Vercel.",
1082
+ deprecated: "This is being replaced by the `disableOverrides` field below."
1083
+ },
1084
+ disableOverrides: {
1085
+ type: "boolean",
1086
+ 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."
1048
1087
  },
1049
1088
  localProxy: {
1050
1089
  $ref: "#/definitions/LocalProxyOptions",
1051
- description: "Options for local proxy."
1090
+ description: "Options for local proxy.",
1091
+ deprecated: "This is being replaced by the `localProxyPort` field below."
1092
+ },
1093
+ localProxyPort: {
1094
+ type: "number",
1095
+ description: "The port number used by the local proxy server.\n\nThe default is `3024`."
1052
1096
  }
1053
1097
  },
1054
1098
  additionalProperties: false
@@ -1056,10 +1100,6 @@ var schema_default = {
1056
1100
  VercelOptions: {
1057
1101
  type: "object",
1058
1102
  properties: {
1059
- teamSlug: {
1060
- type: "string",
1061
- description: "Team slug for the Vercel team"
1062
- },
1063
1103
  disableOverrides: {
1064
1104
  type: "boolean",
1065
1105
  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."
@@ -1077,6 +1117,15 @@ var schema_default = {
1077
1117
  },
1078
1118
  additionalProperties: false
1079
1119
  },
1120
+ ApplicationRouting: {
1121
+ type: "object",
1122
+ additionalProperties: {
1123
+ $ref: "#/definitions/Application"
1124
+ },
1125
+ propertyNames: {
1126
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1127
+ }
1128
+ },
1080
1129
  Application: {
1081
1130
  anyOf: [
1082
1131
  {
@@ -1091,18 +1140,22 @@ var schema_default = {
1091
1140
  type: "object",
1092
1141
  properties: {
1093
1142
  vercel: {
1094
- $ref: "#/definitions/Vercel"
1143
+ $ref: "#/definitions/Vercel",
1144
+ deprecated: "This is being replaced by the `projectId` field below."
1145
+ },
1146
+ projectId: {
1147
+ type: "string",
1148
+ description: "Vercel project ID"
1095
1149
  },
1096
1150
  development: {
1097
1151
  $ref: "#/definitions/Development"
1098
1152
  },
1099
1153
  production: {
1100
- $ref: "#/definitions/HostConfig"
1154
+ $ref: "#/definitions/HostConfig",
1155
+ deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
1101
1156
  }
1102
1157
  },
1103
- required: [
1104
- "production"
1105
- ],
1158
+ required: ["production"],
1106
1159
  additionalProperties: false
1107
1160
  },
1108
1161
  Vercel: {
@@ -1113,20 +1166,30 @@ var schema_default = {
1113
1166
  description: "Vercel project ID"
1114
1167
  }
1115
1168
  },
1116
- required: [
1117
- "projectId"
1118
- ],
1169
+ required: ["projectId"],
1119
1170
  additionalProperties: false
1120
1171
  },
1121
1172
  Development: {
1122
1173
  type: "object",
1123
1174
  properties: {
1124
1175
  local: {
1125
- $ref: "#/definitions/LocalHostConfig"
1176
+ $ref: "#/definitions/LocalHostConfig",
1177
+ deprecated: "This is being replaced by the `localPort` field below."
1178
+ },
1179
+ localPort: {
1180
+ type: "number",
1181
+ description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS."
1126
1182
  },
1127
1183
  fallback: {
1128
- $ref: "#/definitions/HostConfig",
1129
- description: "Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error."
1184
+ anyOf: [
1185
+ {
1186
+ $ref: "#/definitions/HostConfig"
1187
+ },
1188
+ {
1189
+ type: "string"
1190
+ }
1191
+ ],
1192
+ description: "Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\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."
1130
1193
  },
1131
1194
  task: {
1132
1195
  type: "string",
@@ -1145,10 +1208,7 @@ var schema_default = {
1145
1208
  },
1146
1209
  protocol: {
1147
1210
  type: "string",
1148
- enum: [
1149
- "http",
1150
- "https"
1151
- ],
1211
+ enum: ["http", "https"],
1152
1212
  description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1153
1213
  },
1154
1214
  port: {
@@ -1162,10 +1222,7 @@ var schema_default = {
1162
1222
  properties: {
1163
1223
  protocol: {
1164
1224
  type: "string",
1165
- enum: [
1166
- "http",
1167
- "https"
1168
- ],
1225
+ enum: ["http", "https"],
1169
1226
  description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1170
1227
  },
1171
1228
  host: {
@@ -1177,16 +1234,19 @@ var schema_default = {
1177
1234
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1178
1235
  }
1179
1236
  },
1180
- required: [
1181
- "host"
1182
- ],
1237
+ required: ["host"],
1183
1238
  additionalProperties: false
1184
1239
  },
1185
1240
  ChildApplication: {
1186
1241
  type: "object",
1187
1242
  properties: {
1188
1243
  vercel: {
1189
- $ref: "#/definitions/Vercel"
1244
+ $ref: "#/definitions/Vercel",
1245
+ deprecated: "This is being replaced by the `projectId` field below."
1246
+ },
1247
+ projectId: {
1248
+ type: "string",
1249
+ description: "Vercel project ID"
1190
1250
  },
1191
1251
  development: {
1192
1252
  $ref: "#/definitions/Development"
@@ -1196,12 +1256,11 @@ var schema_default = {
1196
1256
  description: "Groups of path expressions that are routed to this application."
1197
1257
  },
1198
1258
  production: {
1199
- $ref: "#/definitions/HostConfig"
1259
+ $ref: "#/definitions/HostConfig",
1260
+ deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
1200
1261
  }
1201
1262
  },
1202
- required: [
1203
- "routing"
1204
- ],
1263
+ required: ["routing"],
1205
1264
  additionalProperties: false
1206
1265
  },
1207
1266
  Routing: {
@@ -1228,20 +1287,9 @@ var schema_default = {
1228
1287
  }
1229
1288
  }
1230
1289
  },
1231
- required: [
1232
- "paths"
1233
- ],
1290
+ required: ["paths"],
1234
1291
  additionalProperties: false
1235
1292
  },
1236
- ApplicationRouting: {
1237
- type: "object",
1238
- additionalProperties: {
1239
- $ref: "#/definitions/Application"
1240
- },
1241
- propertyNames: {
1242
- description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1243
- }
1244
- },
1245
1293
  ChildConfig: {
1246
1294
  type: "object",
1247
1295
  properties: {
@@ -1255,24 +1303,12 @@ var schema_default = {
1255
1303
  options: {
1256
1304
  $ref: "#/definitions/Options"
1257
1305
  },
1258
- remotes: {
1259
- type: "object",
1260
- additionalProperties: {
1261
- $ref: "#/definitions/Application"
1262
- },
1263
- propertyNames: {
1264
- description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1265
- },
1266
- 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."
1267
- },
1268
1306
  partOf: {
1269
1307
  type: "string",
1270
1308
  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."
1271
1309
  }
1272
1310
  },
1273
- required: [
1274
- "partOf"
1275
- ],
1311
+ required: ["partOf"],
1276
1312
  additionalProperties: false
1277
1313
  }
1278
1314
  }
@@ -1282,6 +1318,14 @@ var schema_default = {
1282
1318
  var SCHEMA = schema_default;
1283
1319
 
1284
1320
  // src/config/microfrontends/server/validation.ts
1321
+ function filterAjvErrors(errors) {
1322
+ if (!errors) {
1323
+ return [];
1324
+ }
1325
+ return errors.filter((error) => {
1326
+ return error.keyword === "additionalProperties" || error.keyword === "required";
1327
+ });
1328
+ }
1285
1329
  function validateSchema(configString) {
1286
1330
  const parsedConfig = parse3(configString);
1287
1331
  const ajv = new Ajv();
@@ -1289,7 +1333,10 @@ function validateSchema(configString) {
1289
1333
  const isValid = validate(parsedConfig);
1290
1334
  if (!isValid) {
1291
1335
  throw new MicrofrontendError(
1292
- `Invalid config: ${ajv.errorsText(validate.errors)}`,
1336
+ `Invalid microfrontends config:
1337
+ - ${ajv.errorsText(filterAjvErrors(validate.errors), { separator: "\n - " })}
1338
+
1339
+ See https://openapi.vercel.sh/microfrontends.json for the schema.`,
1293
1340
  { type: "config", subtype: "does_not_match_schema" }
1294
1341
  );
1295
1342
  }
@@ -1429,8 +1476,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1429
1476
  throw new Error("Unable to infer");
1430
1477
  } catch (e) {
1431
1478
  throw new MicrofrontendError(
1432
- "Unable to infer microfrontends configuration",
1433
- { type: "config", subtype: "inference_failed" }
1479
+ "Unable to locate and parse microfrontends configuration",
1480
+ { cause: e, type: "config", subtype: "inference_failed" }
1434
1481
  );
1435
1482
  }
1436
1483
  }
@@ -1506,7 +1553,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1506
1553
  const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
1507
1554
  if (!defaultApplication) {
1508
1555
  throw new MicrofrontendError(
1509
- `No default application found. At least one application needs to be the default by omitting routing.`,
1556
+ "No default application found. At least one application needs to be the default by omitting routing.",
1510
1557
  { type: "config", subtype: "no_default_application" }
1511
1558
  );
1512
1559
  }
@@ -1559,7 +1606,7 @@ function loadConfig({
1559
1606
  return void 0;
1560
1607
  }
1561
1608
  const app = config.config.getApplication(appName);
1562
- const port = app.development.local.port;
1609
+ const port = app.development.local.port ?? (app.development.local.protocol === "https" ? 443 : 80);
1563
1610
  return { port };
1564
1611
  }
1565
1612
  export {