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