@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.
- package/README.md +7 -159
- package/dist/bin/cli.cjs +202 -139
- package/dist/config.cjs +103 -57
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +103 -57
- package/dist/config.js.map +1 -1
- package/dist/{index-f094deb1.d.ts → index-09b1ddf9.d.ts} +16 -19
- package/dist/{index-5fcf0863.d.ts → index-2f78c0ca.d.ts} +44 -17
- package/dist/microfrontends/server.cjs +180 -133
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +4 -4
- package/dist/microfrontends/server.js +180 -133
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends.cjs +104 -58
- package/dist/microfrontends.cjs.map +1 -1
- package/dist/microfrontends.d.ts +4 -4
- package/dist/microfrontends.js +104 -58
- 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 +197 -145
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +197 -145
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/middleware.cjs +121 -80
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +121 -80
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +110 -63
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +110 -63
- 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-4ef2bddb.d.ts} +1 -1
- package/dist/{types-ecd7b91b.d.ts → types-b6d38aea.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +181 -134
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +181 -134
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +74 -73
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +74 -73
- package/dist/validation.js.map +1 -1
- package/package.json +19 -3
- package/schema/schema.json +80 -73
|
@@ -72,7 +72,7 @@ function parseOverrides(cookies) {
|
|
|
72
72
|
// src/config/errors.ts
|
|
73
73
|
var MicrofrontendError = class extends Error {
|
|
74
74
|
constructor(message, opts) {
|
|
75
|
-
super(message);
|
|
75
|
+
super(message, { cause: opts?.cause });
|
|
76
76
|
this.name = "MicrofrontendsError";
|
|
77
77
|
this.source = opts?.source ?? "@vercel/microfrontends";
|
|
78
78
|
this.type = opts?.type ?? "unknown";
|
|
@@ -264,7 +264,8 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
264
264
|
if (isDefaultApp(app)) {
|
|
265
265
|
continue;
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
const childApp = app;
|
|
268
|
+
for (const pathMatch of childApp.routing) {
|
|
268
269
|
for (const path5 of pathMatch.paths) {
|
|
269
270
|
const maybeError = validatePathExpression(path5);
|
|
270
271
|
if (maybeError) {
|
|
@@ -284,33 +285,31 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
const entries = Array.from(pathsByApplicationId.entries());
|
|
287
|
-
|
|
288
|
+
for (const [path5, { applications: ids, matcher, applicationId }] of entries) {
|
|
288
289
|
if (ids.length > 1) {
|
|
289
290
|
errors.push(
|
|
290
291
|
`Duplicate path "${path5}" for applications "${ids.join(", ")}"`
|
|
291
292
|
);
|
|
292
293
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
if (applicationId === matchApplicationId) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (matcher.test(matchPath)) {
|
|
305
|
-
const source = `"${path5}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
|
|
306
|
-
const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
|
|
307
|
-
errors.push(
|
|
308
|
-
`Overlapping path detected between ${source} and ${destination}`
|
|
309
|
-
);
|
|
310
|
-
}
|
|
294
|
+
for (const [
|
|
295
|
+
matchPath,
|
|
296
|
+
{ applications: matchIds, applicationId: matchApplicationId }
|
|
297
|
+
] of entries) {
|
|
298
|
+
if (path5 === matchPath) {
|
|
299
|
+
continue;
|
|
311
300
|
}
|
|
312
|
-
|
|
313
|
-
|
|
301
|
+
if (applicationId === matchApplicationId) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (matcher.test(matchPath)) {
|
|
305
|
+
const source = `"${path5}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
|
|
306
|
+
const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
|
|
307
|
+
errors.push(
|
|
308
|
+
`Overlapping path detected between ${source} and ${destination}`
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
314
313
|
if (errors.length) {
|
|
315
314
|
throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
|
|
316
315
|
type: "config",
|
|
@@ -379,7 +378,7 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
379
378
|
const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
|
|
380
379
|
if (numApplicationsWithoutRouting === 0) {
|
|
381
380
|
throw new MicrofrontendError(
|
|
382
|
-
|
|
381
|
+
"No default application found. At least one application needs to be the default by omitting routing.",
|
|
383
382
|
{ type: "config", subtype: "no_default_application" }
|
|
384
383
|
);
|
|
385
384
|
}
|
|
@@ -425,47 +424,80 @@ function generatePortFromName({
|
|
|
425
424
|
// src/config/microfrontends-config/isomorphic/host.ts
|
|
426
425
|
var Host = class {
|
|
427
426
|
constructor(hostConfig, options) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
427
|
+
if (typeof hostConfig === "string") {
|
|
428
|
+
({
|
|
429
|
+
protocol: this.protocol,
|
|
430
|
+
host: this.host,
|
|
431
|
+
port: this.port
|
|
432
|
+
} = Host.parseUrl(hostConfig));
|
|
433
|
+
} else {
|
|
434
|
+
const { protocol = "https", host, port } = hostConfig;
|
|
435
|
+
this.protocol = protocol;
|
|
436
|
+
this.host = host;
|
|
437
|
+
this.port = port;
|
|
438
|
+
}
|
|
432
439
|
this.local = options?.isLocal;
|
|
433
440
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
441
|
+
static parseUrl(url) {
|
|
442
|
+
let hostToParse = url;
|
|
443
|
+
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
444
|
+
hostToParse = `https://${hostToParse}`;
|
|
445
|
+
}
|
|
446
|
+
const parsed = new URL(hostToParse);
|
|
447
|
+
if (!parsed.hostname) {
|
|
448
|
+
throw new Error(Host.getMicrofrontendsError(url, "requires a host"));
|
|
449
|
+
}
|
|
450
|
+
if (parsed.hash) {
|
|
451
|
+
throw new Error(
|
|
452
|
+
Host.getMicrofrontendsError(url, "cannot have a fragment")
|
|
453
|
+
);
|
|
446
454
|
}
|
|
447
|
-
|
|
455
|
+
if (parsed.username || parsed.password) {
|
|
456
|
+
throw new Error(
|
|
457
|
+
Host.getMicrofrontendsError(
|
|
458
|
+
url,
|
|
459
|
+
"cannot have authentication credentials (username and/or password)"
|
|
460
|
+
)
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
if (parsed.pathname !== "/") {
|
|
464
|
+
throw new Error(Host.getMicrofrontendsError(url, "cannot have a path"));
|
|
465
|
+
}
|
|
466
|
+
if (parsed.search) {
|
|
467
|
+
throw new Error(
|
|
468
|
+
Host.getMicrofrontendsError(url, "cannot have query parameters")
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
const protocol = parsed.protocol.slice(0, -1);
|
|
472
|
+
return {
|
|
473
|
+
protocol,
|
|
474
|
+
host: parsed.hostname,
|
|
475
|
+
port: parsed.port ? Number.parseInt(parsed.port) : void 0
|
|
476
|
+
};
|
|
448
477
|
}
|
|
449
|
-
|
|
450
|
-
return
|
|
478
|
+
static getMicrofrontendsError(url, message) {
|
|
479
|
+
return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;
|
|
480
|
+
}
|
|
481
|
+
isLocal() {
|
|
482
|
+
return this.local || this.host === "localhost" || this.host === "127.0.0.1";
|
|
451
483
|
}
|
|
452
|
-
toString(
|
|
453
|
-
const url = this.toUrl(
|
|
484
|
+
toString() {
|
|
485
|
+
const url = this.toUrl();
|
|
454
486
|
return url.toString().replace(/\/$/, "");
|
|
455
487
|
}
|
|
456
|
-
toUrl(
|
|
457
|
-
const {
|
|
458
|
-
const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? "" : `:${this.port}`}`;
|
|
488
|
+
toUrl() {
|
|
489
|
+
const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ""}`;
|
|
459
490
|
return new URL(url);
|
|
460
491
|
}
|
|
461
492
|
};
|
|
462
493
|
var LocalHost = class extends Host {
|
|
463
494
|
constructor({
|
|
464
495
|
appName,
|
|
496
|
+
localPort,
|
|
465
497
|
...hostConfig
|
|
466
498
|
}) {
|
|
467
499
|
const host = hostConfig.host ?? "localhost";
|
|
468
|
-
const port = hostConfig.port ?? generatePortFromName({ name: appName });
|
|
500
|
+
const port = localPort ?? hostConfig.port ?? generatePortFromName({ name: appName });
|
|
469
501
|
const protocol = hostConfig.protocol ?? "http";
|
|
470
502
|
super({ protocol, host, port });
|
|
471
503
|
}
|
|
@@ -482,12 +514,17 @@ var Application = class {
|
|
|
482
514
|
this.development = {
|
|
483
515
|
local: new LocalHost({
|
|
484
516
|
appName: name,
|
|
517
|
+
localPort: app.development?.localPort,
|
|
485
518
|
...app.development?.local
|
|
486
519
|
}),
|
|
487
520
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
488
521
|
};
|
|
489
|
-
|
|
490
|
-
|
|
522
|
+
if (app.development?.fallback) {
|
|
523
|
+
this.fallback = new Host(app.development.fallback);
|
|
524
|
+
} else if (app.production) {
|
|
525
|
+
this.fallback = new Host(app.production);
|
|
526
|
+
}
|
|
527
|
+
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
491
528
|
this.overrides = overrides?.environment ? {
|
|
492
529
|
environment: new Host(overrides.environment)
|
|
493
530
|
} : void 0;
|
|
@@ -515,7 +552,16 @@ var DefaultApplication = class extends Application {
|
|
|
515
552
|
isDefault: true
|
|
516
553
|
});
|
|
517
554
|
this.default = true;
|
|
518
|
-
|
|
555
|
+
const fallbackHost = app.development?.fallback ?? app.production;
|
|
556
|
+
if (fallbackHost === void 0) {
|
|
557
|
+
throw new Error(
|
|
558
|
+
"`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
this.fallback = new Host(fallbackHost);
|
|
562
|
+
if (app.production) {
|
|
563
|
+
this.production = new Host(app.production);
|
|
564
|
+
}
|
|
519
565
|
}
|
|
520
566
|
getAssetPrefix() {
|
|
521
567
|
return "";
|
|
@@ -585,7 +631,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
585
631
|
}
|
|
586
632
|
if (isMainConfig(config) && !this.defaultApplication) {
|
|
587
633
|
throw new MicrofrontendError(
|
|
588
|
-
|
|
634
|
+
"Could not find default application in microfrontends configuration",
|
|
589
635
|
{
|
|
590
636
|
type: "application",
|
|
591
637
|
subtype: "not_found"
|
|
@@ -661,11 +707,11 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
661
707
|
return app;
|
|
662
708
|
}
|
|
663
709
|
getApplicationByProjectId(projectId) {
|
|
664
|
-
if (this.defaultApplication?.
|
|
710
|
+
if (this.defaultApplication?.projectId === projectId) {
|
|
665
711
|
return this.defaultApplication;
|
|
666
712
|
}
|
|
667
713
|
return Object.values(this.childApplications).find(
|
|
668
|
-
(app) => app.
|
|
714
|
+
(app) => app.projectId === projectId
|
|
669
715
|
);
|
|
670
716
|
}
|
|
671
717
|
/**
|
|
@@ -675,7 +721,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
675
721
|
getDefaultApplication() {
|
|
676
722
|
if (!this.defaultApplication) {
|
|
677
723
|
throw new MicrofrontendError(
|
|
678
|
-
|
|
724
|
+
"Could not find default application in microfrontends configuration",
|
|
679
725
|
{
|
|
680
726
|
type: "application",
|
|
681
727
|
subtype: "not_found"
|
|
@@ -688,7 +734,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
688
734
|
* Returns the configured port for the local proxy
|
|
689
735
|
*/
|
|
690
736
|
getLocalProxyPort() {
|
|
691
|
-
return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
737
|
+
return this.config.options?.localProxyPort ?? this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
692
738
|
}
|
|
693
739
|
/**
|
|
694
740
|
* Serializes the class back to the Schema type.
|
|
@@ -762,7 +808,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
762
808
|
}
|
|
763
809
|
if (!defaultApplication) {
|
|
764
810
|
throw new MicrofrontendError(
|
|
765
|
-
|
|
811
|
+
"Could not find default application in microfrontends configuration",
|
|
766
812
|
{
|
|
767
813
|
type: "application",
|
|
768
814
|
subtype: "not_found"
|
|
@@ -1049,24 +1095,12 @@ var schema_default = {
|
|
|
1049
1095
|
options: {
|
|
1050
1096
|
$ref: "#/definitions/Options"
|
|
1051
1097
|
},
|
|
1052
|
-
remotes: {
|
|
1053
|
-
type: "object",
|
|
1054
|
-
additionalProperties: {
|
|
1055
|
-
$ref: "#/definitions/Application"
|
|
1056
|
-
},
|
|
1057
|
-
propertyNames: {
|
|
1058
|
-
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1059
|
-
},
|
|
1060
|
-
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."
|
|
1061
|
-
},
|
|
1062
1098
|
applications: {
|
|
1063
1099
|
$ref: "#/definitions/ApplicationRouting",
|
|
1064
1100
|
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"
|
|
1065
1101
|
}
|
|
1066
1102
|
},
|
|
1067
|
-
required: [
|
|
1068
|
-
"applications"
|
|
1069
|
-
],
|
|
1103
|
+
required: ["applications"],
|
|
1070
1104
|
additionalProperties: false
|
|
1071
1105
|
},
|
|
1072
1106
|
Options: {
|
|
@@ -1074,11 +1108,21 @@ var schema_default = {
|
|
|
1074
1108
|
properties: {
|
|
1075
1109
|
vercel: {
|
|
1076
1110
|
$ref: "#/definitions/VercelOptions",
|
|
1077
|
-
description: "
|
|
1111
|
+
description: "Microfrontends wide options for Vercel.",
|
|
1112
|
+
deprecated: "This is being replaced by the `disableOverrides` field below."
|
|
1113
|
+
},
|
|
1114
|
+
disableOverrides: {
|
|
1115
|
+
type: "boolean",
|
|
1116
|
+
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."
|
|
1078
1117
|
},
|
|
1079
1118
|
localProxy: {
|
|
1080
1119
|
$ref: "#/definitions/LocalProxyOptions",
|
|
1081
|
-
description: "Options for local proxy."
|
|
1120
|
+
description: "Options for local proxy.",
|
|
1121
|
+
deprecated: "This is being replaced by the `localProxyPort` field below."
|
|
1122
|
+
},
|
|
1123
|
+
localProxyPort: {
|
|
1124
|
+
type: "number",
|
|
1125
|
+
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
1082
1126
|
}
|
|
1083
1127
|
},
|
|
1084
1128
|
additionalProperties: false
|
|
@@ -1086,10 +1130,6 @@ var schema_default = {
|
|
|
1086
1130
|
VercelOptions: {
|
|
1087
1131
|
type: "object",
|
|
1088
1132
|
properties: {
|
|
1089
|
-
teamSlug: {
|
|
1090
|
-
type: "string",
|
|
1091
|
-
description: "Team slug for the Vercel team"
|
|
1092
|
-
},
|
|
1093
1133
|
disableOverrides: {
|
|
1094
1134
|
type: "boolean",
|
|
1095
1135
|
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."
|
|
@@ -1107,6 +1147,15 @@ var schema_default = {
|
|
|
1107
1147
|
},
|
|
1108
1148
|
additionalProperties: false
|
|
1109
1149
|
},
|
|
1150
|
+
ApplicationRouting: {
|
|
1151
|
+
type: "object",
|
|
1152
|
+
additionalProperties: {
|
|
1153
|
+
$ref: "#/definitions/Application"
|
|
1154
|
+
},
|
|
1155
|
+
propertyNames: {
|
|
1156
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1157
|
+
}
|
|
1158
|
+
},
|
|
1110
1159
|
Application: {
|
|
1111
1160
|
anyOf: [
|
|
1112
1161
|
{
|
|
@@ -1121,18 +1170,22 @@ var schema_default = {
|
|
|
1121
1170
|
type: "object",
|
|
1122
1171
|
properties: {
|
|
1123
1172
|
vercel: {
|
|
1124
|
-
$ref: "#/definitions/Vercel"
|
|
1173
|
+
$ref: "#/definitions/Vercel",
|
|
1174
|
+
deprecated: "This is being replaced by the `projectId` field below."
|
|
1175
|
+
},
|
|
1176
|
+
projectId: {
|
|
1177
|
+
type: "string",
|
|
1178
|
+
description: "Vercel project ID"
|
|
1125
1179
|
},
|
|
1126
1180
|
development: {
|
|
1127
1181
|
$ref: "#/definitions/Development"
|
|
1128
1182
|
},
|
|
1129
1183
|
production: {
|
|
1130
|
-
$ref: "#/definitions/HostConfig"
|
|
1184
|
+
$ref: "#/definitions/HostConfig",
|
|
1185
|
+
deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
|
|
1131
1186
|
}
|
|
1132
1187
|
},
|
|
1133
|
-
required: [
|
|
1134
|
-
"production"
|
|
1135
|
-
],
|
|
1188
|
+
required: ["production"],
|
|
1136
1189
|
additionalProperties: false
|
|
1137
1190
|
},
|
|
1138
1191
|
Vercel: {
|
|
@@ -1143,20 +1196,30 @@ var schema_default = {
|
|
|
1143
1196
|
description: "Vercel project ID"
|
|
1144
1197
|
}
|
|
1145
1198
|
},
|
|
1146
|
-
required: [
|
|
1147
|
-
"projectId"
|
|
1148
|
-
],
|
|
1199
|
+
required: ["projectId"],
|
|
1149
1200
|
additionalProperties: false
|
|
1150
1201
|
},
|
|
1151
1202
|
Development: {
|
|
1152
1203
|
type: "object",
|
|
1153
1204
|
properties: {
|
|
1154
1205
|
local: {
|
|
1155
|
-
$ref: "#/definitions/LocalHostConfig"
|
|
1206
|
+
$ref: "#/definitions/LocalHostConfig",
|
|
1207
|
+
deprecated: "This is being replaced by the `localPort` field below."
|
|
1208
|
+
},
|
|
1209
|
+
localPort: {
|
|
1210
|
+
type: "number",
|
|
1211
|
+
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."
|
|
1156
1212
|
},
|
|
1157
1213
|
fallback: {
|
|
1158
|
-
|
|
1159
|
-
|
|
1214
|
+
anyOf: [
|
|
1215
|
+
{
|
|
1216
|
+
$ref: "#/definitions/HostConfig"
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
type: "string"
|
|
1220
|
+
}
|
|
1221
|
+
],
|
|
1222
|
+
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."
|
|
1160
1223
|
},
|
|
1161
1224
|
task: {
|
|
1162
1225
|
type: "string",
|
|
@@ -1175,10 +1238,7 @@ var schema_default = {
|
|
|
1175
1238
|
},
|
|
1176
1239
|
protocol: {
|
|
1177
1240
|
type: "string",
|
|
1178
|
-
enum: [
|
|
1179
|
-
"http",
|
|
1180
|
-
"https"
|
|
1181
|
-
],
|
|
1241
|
+
enum: ["http", "https"],
|
|
1182
1242
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1183
1243
|
},
|
|
1184
1244
|
port: {
|
|
@@ -1192,10 +1252,7 @@ var schema_default = {
|
|
|
1192
1252
|
properties: {
|
|
1193
1253
|
protocol: {
|
|
1194
1254
|
type: "string",
|
|
1195
|
-
enum: [
|
|
1196
|
-
"http",
|
|
1197
|
-
"https"
|
|
1198
|
-
],
|
|
1255
|
+
enum: ["http", "https"],
|
|
1199
1256
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1200
1257
|
},
|
|
1201
1258
|
host: {
|
|
@@ -1207,16 +1264,19 @@ var schema_default = {
|
|
|
1207
1264
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1208
1265
|
}
|
|
1209
1266
|
},
|
|
1210
|
-
required: [
|
|
1211
|
-
"host"
|
|
1212
|
-
],
|
|
1267
|
+
required: ["host"],
|
|
1213
1268
|
additionalProperties: false
|
|
1214
1269
|
},
|
|
1215
1270
|
ChildApplication: {
|
|
1216
1271
|
type: "object",
|
|
1217
1272
|
properties: {
|
|
1218
1273
|
vercel: {
|
|
1219
|
-
$ref: "#/definitions/Vercel"
|
|
1274
|
+
$ref: "#/definitions/Vercel",
|
|
1275
|
+
deprecated: "This is being replaced by the `projectId` field below."
|
|
1276
|
+
},
|
|
1277
|
+
projectId: {
|
|
1278
|
+
type: "string",
|
|
1279
|
+
description: "Vercel project ID"
|
|
1220
1280
|
},
|
|
1221
1281
|
development: {
|
|
1222
1282
|
$ref: "#/definitions/Development"
|
|
@@ -1226,12 +1286,11 @@ var schema_default = {
|
|
|
1226
1286
|
description: "Groups of path expressions that are routed to this application."
|
|
1227
1287
|
},
|
|
1228
1288
|
production: {
|
|
1229
|
-
$ref: "#/definitions/HostConfig"
|
|
1289
|
+
$ref: "#/definitions/HostConfig",
|
|
1290
|
+
deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
|
|
1230
1291
|
}
|
|
1231
1292
|
},
|
|
1232
|
-
required: [
|
|
1233
|
-
"routing"
|
|
1234
|
-
],
|
|
1293
|
+
required: ["routing"],
|
|
1235
1294
|
additionalProperties: false
|
|
1236
1295
|
},
|
|
1237
1296
|
Routing: {
|
|
@@ -1258,20 +1317,9 @@ var schema_default = {
|
|
|
1258
1317
|
}
|
|
1259
1318
|
}
|
|
1260
1319
|
},
|
|
1261
|
-
required: [
|
|
1262
|
-
"paths"
|
|
1263
|
-
],
|
|
1320
|
+
required: ["paths"],
|
|
1264
1321
|
additionalProperties: false
|
|
1265
1322
|
},
|
|
1266
|
-
ApplicationRouting: {
|
|
1267
|
-
type: "object",
|
|
1268
|
-
additionalProperties: {
|
|
1269
|
-
$ref: "#/definitions/Application"
|
|
1270
|
-
},
|
|
1271
|
-
propertyNames: {
|
|
1272
|
-
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1273
|
-
}
|
|
1274
|
-
},
|
|
1275
1323
|
ChildConfig: {
|
|
1276
1324
|
type: "object",
|
|
1277
1325
|
properties: {
|
|
@@ -1285,24 +1333,12 @@ var schema_default = {
|
|
|
1285
1333
|
options: {
|
|
1286
1334
|
$ref: "#/definitions/Options"
|
|
1287
1335
|
},
|
|
1288
|
-
remotes: {
|
|
1289
|
-
type: "object",
|
|
1290
|
-
additionalProperties: {
|
|
1291
|
-
$ref: "#/definitions/Application"
|
|
1292
|
-
},
|
|
1293
|
-
propertyNames: {
|
|
1294
|
-
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1295
|
-
},
|
|
1296
|
-
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."
|
|
1297
|
-
},
|
|
1298
1336
|
partOf: {
|
|
1299
1337
|
type: "string",
|
|
1300
1338
|
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."
|
|
1301
1339
|
}
|
|
1302
1340
|
},
|
|
1303
|
-
required: [
|
|
1304
|
-
"partOf"
|
|
1305
|
-
],
|
|
1341
|
+
required: ["partOf"],
|
|
1306
1342
|
additionalProperties: false
|
|
1307
1343
|
}
|
|
1308
1344
|
}
|
|
@@ -1312,6 +1348,14 @@ var schema_default = {
|
|
|
1312
1348
|
var SCHEMA = schema_default;
|
|
1313
1349
|
|
|
1314
1350
|
// src/config/microfrontends/server/validation.ts
|
|
1351
|
+
function filterAjvErrors(errors) {
|
|
1352
|
+
if (!errors) {
|
|
1353
|
+
return [];
|
|
1354
|
+
}
|
|
1355
|
+
return errors.filter((error) => {
|
|
1356
|
+
return error.keyword === "additionalProperties" || error.keyword === "required";
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1315
1359
|
function validateSchema(configString) {
|
|
1316
1360
|
const parsedConfig = (0, import_jsonc_parser3.parse)(configString);
|
|
1317
1361
|
const ajv = new import_ajv.Ajv();
|
|
@@ -1319,7 +1363,10 @@ function validateSchema(configString) {
|
|
|
1319
1363
|
const isValid = validate(parsedConfig);
|
|
1320
1364
|
if (!isValid) {
|
|
1321
1365
|
throw new MicrofrontendError(
|
|
1322
|
-
`Invalid config:
|
|
1366
|
+
`Invalid microfrontends config:
|
|
1367
|
+
- ${ajv.errorsText(filterAjvErrors(validate.errors), { separator: "\n - " })}
|
|
1368
|
+
|
|
1369
|
+
See https://openapi.vercel.sh/microfrontends.json for the schema.`,
|
|
1323
1370
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
1324
1371
|
);
|
|
1325
1372
|
}
|
|
@@ -1459,8 +1506,8 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1459
1506
|
throw new Error("Unable to infer");
|
|
1460
1507
|
} catch (e) {
|
|
1461
1508
|
throw new MicrofrontendError(
|
|
1462
|
-
"Unable to
|
|
1463
|
-
{ type: "config", subtype: "inference_failed" }
|
|
1509
|
+
"Unable to locate and parse microfrontends configuration",
|
|
1510
|
+
{ cause: e, type: "config", subtype: "inference_failed" }
|
|
1464
1511
|
);
|
|
1465
1512
|
}
|
|
1466
1513
|
}
|
|
@@ -1536,7 +1583,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1536
1583
|
const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
|
|
1537
1584
|
if (!defaultApplication) {
|
|
1538
1585
|
throw new MicrofrontendError(
|
|
1539
|
-
|
|
1586
|
+
"No default application found. At least one application needs to be the default by omitting routing.",
|
|
1540
1587
|
{ type: "config", subtype: "no_default_application" }
|
|
1541
1588
|
);
|
|
1542
1589
|
}
|