@vercel/microfrontends 0.17.4 → 0.18.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 +52 -69
  3. package/dist/config.cjs +1 -1
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +4 -4
  6. package/dist/config.js +1 -1
  7. package/dist/config.js.map +1 -1
  8. package/dist/{index-f094deb1.d.ts → index-24024799.d.ts} +3 -3
  9. package/dist/{index-5fcf0863.d.ts → index-ef8657e6.d.ts} +0 -10
  10. package/dist/microfrontends/server.cjs +33 -66
  11. package/dist/microfrontends/server.cjs.map +1 -1
  12. package/dist/microfrontends/server.d.ts +4 -4
  13. package/dist/microfrontends/server.js +33 -66
  14. package/dist/microfrontends/server.js.map +1 -1
  15. package/dist/microfrontends.cjs +1 -1
  16. package/dist/microfrontends.cjs.map +1 -1
  17. package/dist/microfrontends.d.ts +4 -4
  18. package/dist/microfrontends.js +1 -1
  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 +33 -66
  26. package/dist/next/config.cjs.map +1 -1
  27. package/dist/next/config.js +33 -66
  28. package/dist/next/config.js.map +1 -1
  29. package/dist/next/endpoints.d.ts +2 -2
  30. package/dist/next/middleware.cjs +1 -5
  31. package/dist/next/middleware.cjs.map +1 -1
  32. package/dist/next/middleware.js +1 -5
  33. package/dist/next/middleware.js.map +1 -1
  34. package/dist/next/testing.cjs +1 -1
  35. package/dist/next/testing.cjs.map +1 -1
  36. package/dist/next/testing.d.ts +4 -4
  37. package/dist/next/testing.js +1 -1
  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-089498fd.d.ts} +1 -1
  42. package/dist/{types-ecd7b91b.d.ts → types-9f161cec.d.ts} +1 -1
  43. package/dist/utils/mfe-port.cjs +33 -66
  44. package/dist/utils/mfe-port.cjs.map +1 -1
  45. package/dist/utils/mfe-port.js +33 -66
  46. package/dist/utils/mfe-port.js.map +1 -1
  47. package/dist/validation.cjs +31 -64
  48. package/dist/validation.cjs.map +1 -1
  49. package/dist/validation.d.ts +1 -1
  50. package/dist/validation.js +31 -64
  51. package/dist/validation.js.map +1 -1
  52. package/package.json +19 -3
  53. package/schema/schema.json +9 -33
@@ -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";
@@ -1019,24 +1019,12 @@ var schema_default = {
1019
1019
  options: {
1020
1020
  $ref: "#/definitions/Options"
1021
1021
  },
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
1022
  applications: {
1033
1023
  $ref: "#/definitions/ApplicationRouting",
1034
1024
  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
1025
  }
1036
1026
  },
1037
- required: [
1038
- "applications"
1039
- ],
1027
+ required: ["applications"],
1040
1028
  additionalProperties: false
1041
1029
  },
1042
1030
  Options: {
@@ -1056,10 +1044,6 @@ var schema_default = {
1056
1044
  VercelOptions: {
1057
1045
  type: "object",
1058
1046
  properties: {
1059
- teamSlug: {
1060
- type: "string",
1061
- description: "Team slug for the Vercel team"
1062
- },
1063
1047
  disableOverrides: {
1064
1048
  type: "boolean",
1065
1049
  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 +1061,15 @@ var schema_default = {
1077
1061
  },
1078
1062
  additionalProperties: false
1079
1063
  },
1064
+ ApplicationRouting: {
1065
+ type: "object",
1066
+ additionalProperties: {
1067
+ $ref: "#/definitions/Application"
1068
+ },
1069
+ propertyNames: {
1070
+ description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
1071
+ }
1072
+ },
1080
1073
  Application: {
1081
1074
  anyOf: [
1082
1075
  {
@@ -1100,9 +1093,7 @@ var schema_default = {
1100
1093
  $ref: "#/definitions/HostConfig"
1101
1094
  }
1102
1095
  },
1103
- required: [
1104
- "production"
1105
- ],
1096
+ required: ["production"],
1106
1097
  additionalProperties: false
1107
1098
  },
1108
1099
  Vercel: {
@@ -1113,9 +1104,7 @@ var schema_default = {
1113
1104
  description: "Vercel project ID"
1114
1105
  }
1115
1106
  },
1116
- required: [
1117
- "projectId"
1118
- ],
1107
+ required: ["projectId"],
1119
1108
  additionalProperties: false
1120
1109
  },
1121
1110
  Development: {
@@ -1145,10 +1134,7 @@ var schema_default = {
1145
1134
  },
1146
1135
  protocol: {
1147
1136
  type: "string",
1148
- enum: [
1149
- "http",
1150
- "https"
1151
- ],
1137
+ enum: ["http", "https"],
1152
1138
  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
1139
  },
1154
1140
  port: {
@@ -1162,10 +1148,7 @@ var schema_default = {
1162
1148
  properties: {
1163
1149
  protocol: {
1164
1150
  type: "string",
1165
- enum: [
1166
- "http",
1167
- "https"
1168
- ],
1151
+ enum: ["http", "https"],
1169
1152
  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
1153
  },
1171
1154
  host: {
@@ -1177,9 +1160,7 @@ var schema_default = {
1177
1160
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1178
1161
  }
1179
1162
  },
1180
- required: [
1181
- "host"
1182
- ],
1163
+ required: ["host"],
1183
1164
  additionalProperties: false
1184
1165
  },
1185
1166
  ChildApplication: {
@@ -1199,9 +1180,7 @@ var schema_default = {
1199
1180
  $ref: "#/definitions/HostConfig"
1200
1181
  }
1201
1182
  },
1202
- required: [
1203
- "routing"
1204
- ],
1183
+ required: ["routing"],
1205
1184
  additionalProperties: false
1206
1185
  },
1207
1186
  Routing: {
@@ -1228,20 +1207,9 @@ var schema_default = {
1228
1207
  }
1229
1208
  }
1230
1209
  },
1231
- required: [
1232
- "paths"
1233
- ],
1210
+ required: ["paths"],
1234
1211
  additionalProperties: false
1235
1212
  },
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
1213
  ChildConfig: {
1246
1214
  type: "object",
1247
1215
  properties: {
@@ -1255,24 +1223,12 @@ var schema_default = {
1255
1223
  options: {
1256
1224
  $ref: "#/definitions/Options"
1257
1225
  },
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
1226
  partOf: {
1269
1227
  type: "string",
1270
1228
  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
1229
  }
1272
1230
  },
1273
- required: [
1274
- "partOf"
1275
- ],
1231
+ required: ["partOf"],
1276
1232
  additionalProperties: false
1277
1233
  }
1278
1234
  }
@@ -1282,6 +1238,14 @@ var schema_default = {
1282
1238
  var SCHEMA = schema_default;
1283
1239
 
1284
1240
  // src/config/microfrontends/server/validation.ts
1241
+ function filterAjvErrors(errors) {
1242
+ if (!errors) {
1243
+ return [];
1244
+ }
1245
+ return errors.filter((error) => {
1246
+ return error.keyword === "additionalProperties" || error.keyword === "required";
1247
+ });
1248
+ }
1285
1249
  function validateSchema(configString) {
1286
1250
  const parsedConfig = parse3(configString);
1287
1251
  const ajv = new Ajv();
@@ -1289,7 +1253,10 @@ function validateSchema(configString) {
1289
1253
  const isValid = validate(parsedConfig);
1290
1254
  if (!isValid) {
1291
1255
  throw new MicrofrontendError(
1292
- `Invalid config: ${ajv.errorsText(validate.errors)}`,
1256
+ `Invalid microfrontends config:
1257
+ - ${ajv.errorsText(filterAjvErrors(validate.errors), { separator: "\n - " })}
1258
+
1259
+ See https://openapi.vercel.sh/microfrontends.json for the schema.`,
1293
1260
  { type: "config", subtype: "does_not_match_schema" }
1294
1261
  );
1295
1262
  }
@@ -1429,8 +1396,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1429
1396
  throw new Error("Unable to infer");
1430
1397
  } catch (e) {
1431
1398
  throw new MicrofrontendError(
1432
- "Unable to infer microfrontends configuration",
1433
- { type: "config", subtype: "inference_failed" }
1399
+ "Unable to locate and parse microfrontends configuration",
1400
+ { cause: e, type: "config", subtype: "inference_failed" }
1434
1401
  );
1435
1402
  }
1436
1403
  }