@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
|
@@ -38,7 +38,7 @@ function parseOverrides(cookies) {
|
|
|
38
38
|
// src/config/errors.ts
|
|
39
39
|
var MicrofrontendError = class extends Error {
|
|
40
40
|
constructor(message, opts) {
|
|
41
|
-
super(message);
|
|
41
|
+
super(message, { cause: opts?.cause });
|
|
42
42
|
this.name = "MicrofrontendsError";
|
|
43
43
|
this.source = opts?.source ?? "@vercel/microfrontends";
|
|
44
44
|
this.type = opts?.type ?? "unknown";
|
|
@@ -1015,24 +1015,12 @@ var schema_default = {
|
|
|
1015
1015
|
options: {
|
|
1016
1016
|
$ref: "#/definitions/Options"
|
|
1017
1017
|
},
|
|
1018
|
-
remotes: {
|
|
1019
|
-
type: "object",
|
|
1020
|
-
additionalProperties: {
|
|
1021
|
-
$ref: "#/definitions/Application"
|
|
1022
|
-
},
|
|
1023
|
-
propertyNames: {
|
|
1024
|
-
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1025
|
-
},
|
|
1026
|
-
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."
|
|
1027
|
-
},
|
|
1028
1018
|
applications: {
|
|
1029
1019
|
$ref: "#/definitions/ApplicationRouting",
|
|
1030
1020
|
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"
|
|
1031
1021
|
}
|
|
1032
1022
|
},
|
|
1033
|
-
required: [
|
|
1034
|
-
"applications"
|
|
1035
|
-
],
|
|
1023
|
+
required: ["applications"],
|
|
1036
1024
|
additionalProperties: false
|
|
1037
1025
|
},
|
|
1038
1026
|
Options: {
|
|
@@ -1052,10 +1040,6 @@ var schema_default = {
|
|
|
1052
1040
|
VercelOptions: {
|
|
1053
1041
|
type: "object",
|
|
1054
1042
|
properties: {
|
|
1055
|
-
teamSlug: {
|
|
1056
|
-
type: "string",
|
|
1057
|
-
description: "Team slug for the Vercel team"
|
|
1058
|
-
},
|
|
1059
1043
|
disableOverrides: {
|
|
1060
1044
|
type: "boolean",
|
|
1061
1045
|
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."
|
|
@@ -1073,6 +1057,15 @@ var schema_default = {
|
|
|
1073
1057
|
},
|
|
1074
1058
|
additionalProperties: false
|
|
1075
1059
|
},
|
|
1060
|
+
ApplicationRouting: {
|
|
1061
|
+
type: "object",
|
|
1062
|
+
additionalProperties: {
|
|
1063
|
+
$ref: "#/definitions/Application"
|
|
1064
|
+
},
|
|
1065
|
+
propertyNames: {
|
|
1066
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1076
1069
|
Application: {
|
|
1077
1070
|
anyOf: [
|
|
1078
1071
|
{
|
|
@@ -1096,9 +1089,7 @@ var schema_default = {
|
|
|
1096
1089
|
$ref: "#/definitions/HostConfig"
|
|
1097
1090
|
}
|
|
1098
1091
|
},
|
|
1099
|
-
required: [
|
|
1100
|
-
"production"
|
|
1101
|
-
],
|
|
1092
|
+
required: ["production"],
|
|
1102
1093
|
additionalProperties: false
|
|
1103
1094
|
},
|
|
1104
1095
|
Vercel: {
|
|
@@ -1109,9 +1100,7 @@ var schema_default = {
|
|
|
1109
1100
|
description: "Vercel project ID"
|
|
1110
1101
|
}
|
|
1111
1102
|
},
|
|
1112
|
-
required: [
|
|
1113
|
-
"projectId"
|
|
1114
|
-
],
|
|
1103
|
+
required: ["projectId"],
|
|
1115
1104
|
additionalProperties: false
|
|
1116
1105
|
},
|
|
1117
1106
|
Development: {
|
|
@@ -1141,10 +1130,7 @@ var schema_default = {
|
|
|
1141
1130
|
},
|
|
1142
1131
|
protocol: {
|
|
1143
1132
|
type: "string",
|
|
1144
|
-
enum: [
|
|
1145
|
-
"http",
|
|
1146
|
-
"https"
|
|
1147
|
-
],
|
|
1133
|
+
enum: ["http", "https"],
|
|
1148
1134
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1149
1135
|
},
|
|
1150
1136
|
port: {
|
|
@@ -1158,10 +1144,7 @@ var schema_default = {
|
|
|
1158
1144
|
properties: {
|
|
1159
1145
|
protocol: {
|
|
1160
1146
|
type: "string",
|
|
1161
|
-
enum: [
|
|
1162
|
-
"http",
|
|
1163
|
-
"https"
|
|
1164
|
-
],
|
|
1147
|
+
enum: ["http", "https"],
|
|
1165
1148
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1166
1149
|
},
|
|
1167
1150
|
host: {
|
|
@@ -1173,9 +1156,7 @@ var schema_default = {
|
|
|
1173
1156
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1174
1157
|
}
|
|
1175
1158
|
},
|
|
1176
|
-
required: [
|
|
1177
|
-
"host"
|
|
1178
|
-
],
|
|
1159
|
+
required: ["host"],
|
|
1179
1160
|
additionalProperties: false
|
|
1180
1161
|
},
|
|
1181
1162
|
ChildApplication: {
|
|
@@ -1195,9 +1176,7 @@ var schema_default = {
|
|
|
1195
1176
|
$ref: "#/definitions/HostConfig"
|
|
1196
1177
|
}
|
|
1197
1178
|
},
|
|
1198
|
-
required: [
|
|
1199
|
-
"routing"
|
|
1200
|
-
],
|
|
1179
|
+
required: ["routing"],
|
|
1201
1180
|
additionalProperties: false
|
|
1202
1181
|
},
|
|
1203
1182
|
Routing: {
|
|
@@ -1224,20 +1203,9 @@ var schema_default = {
|
|
|
1224
1203
|
}
|
|
1225
1204
|
}
|
|
1226
1205
|
},
|
|
1227
|
-
required: [
|
|
1228
|
-
"paths"
|
|
1229
|
-
],
|
|
1206
|
+
required: ["paths"],
|
|
1230
1207
|
additionalProperties: false
|
|
1231
1208
|
},
|
|
1232
|
-
ApplicationRouting: {
|
|
1233
|
-
type: "object",
|
|
1234
|
-
additionalProperties: {
|
|
1235
|
-
$ref: "#/definitions/Application"
|
|
1236
|
-
},
|
|
1237
|
-
propertyNames: {
|
|
1238
|
-
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1239
|
-
}
|
|
1240
|
-
},
|
|
1241
1209
|
ChildConfig: {
|
|
1242
1210
|
type: "object",
|
|
1243
1211
|
properties: {
|
|
@@ -1251,24 +1219,12 @@ var schema_default = {
|
|
|
1251
1219
|
options: {
|
|
1252
1220
|
$ref: "#/definitions/Options"
|
|
1253
1221
|
},
|
|
1254
|
-
remotes: {
|
|
1255
|
-
type: "object",
|
|
1256
|
-
additionalProperties: {
|
|
1257
|
-
$ref: "#/definitions/Application"
|
|
1258
|
-
},
|
|
1259
|
-
propertyNames: {
|
|
1260
|
-
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1261
|
-
},
|
|
1262
|
-
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."
|
|
1263
|
-
},
|
|
1264
1222
|
partOf: {
|
|
1265
1223
|
type: "string",
|
|
1266
1224
|
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
1225
|
}
|
|
1268
1226
|
},
|
|
1269
|
-
required: [
|
|
1270
|
-
"partOf"
|
|
1271
|
-
],
|
|
1227
|
+
required: ["partOf"],
|
|
1272
1228
|
additionalProperties: false
|
|
1273
1229
|
}
|
|
1274
1230
|
}
|
|
@@ -1278,6 +1234,14 @@ var schema_default = {
|
|
|
1278
1234
|
var SCHEMA = schema_default;
|
|
1279
1235
|
|
|
1280
1236
|
// src/config/microfrontends/server/validation.ts
|
|
1237
|
+
function filterAjvErrors(errors) {
|
|
1238
|
+
if (!errors) {
|
|
1239
|
+
return [];
|
|
1240
|
+
}
|
|
1241
|
+
return errors.filter((error) => {
|
|
1242
|
+
return error.keyword === "additionalProperties" || error.keyword === "required";
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1281
1245
|
function validateSchema(configString) {
|
|
1282
1246
|
const parsedConfig = parse3(configString);
|
|
1283
1247
|
const ajv = new Ajv();
|
|
@@ -1285,7 +1249,10 @@ function validateSchema(configString) {
|
|
|
1285
1249
|
const isValid = validate(parsedConfig);
|
|
1286
1250
|
if (!isValid) {
|
|
1287
1251
|
throw new MicrofrontendError(
|
|
1288
|
-
`Invalid config:
|
|
1252
|
+
`Invalid microfrontends config:
|
|
1253
|
+
- ${ajv.errorsText(filterAjvErrors(validate.errors), { separator: "\n - " })}
|
|
1254
|
+
|
|
1255
|
+
See https://openapi.vercel.sh/microfrontends.json for the schema.`,
|
|
1289
1256
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
1290
1257
|
);
|
|
1291
1258
|
}
|
|
@@ -1425,8 +1392,8 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1425
1392
|
throw new Error("Unable to infer");
|
|
1426
1393
|
} catch (e) {
|
|
1427
1394
|
throw new MicrofrontendError(
|
|
1428
|
-
"Unable to
|
|
1429
|
-
{ type: "config", subtype: "inference_failed" }
|
|
1395
|
+
"Unable to locate and parse microfrontends configuration",
|
|
1396
|
+
{ cause: e, type: "config", subtype: "inference_failed" }
|
|
1430
1397
|
);
|
|
1431
1398
|
}
|
|
1432
1399
|
}
|