@vercel/microfrontends 0.17.1 → 0.17.3
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/LICENSE +21 -0
- package/README.md +48 -89
- package/dist/bin/cli.cjs +299 -200
- package/dist/config.cjs +22 -45
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +22 -45
- package/dist/config.js.map +1 -1
- package/dist/{types-a29d224a.d.ts → index-5fcf0863.d.ts} +2 -2
- package/dist/{index-4399aa8e.d.ts → index-f094deb1.d.ts} +5 -4
- package/dist/microfrontends/server.cjs +68 -75
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +4 -4
- package/dist/microfrontends/server.js +68 -75
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends.cjs +24 -48
- package/dist/microfrontends.cjs.map +1 -1
- package/dist/microfrontends.d.ts +4 -4
- package/dist/microfrontends.js +24 -48
- 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.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +86 -101
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +86 -101
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.cjs +1 -1
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/endpoints.js +1 -1
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +32 -63
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +32 -63
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +27 -54
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +27 -54
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +1 -2
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/overrides.js +1 -2
- package/dist/overrides.js.map +1 -1
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/{types-fc30696d.d.ts → types-5900be7c.d.ts} +1 -1
- package/dist/{types-cfe3308b.d.ts → types-ecd7b91b.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +68 -75
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +68 -75
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +46 -17
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +46 -17
- package/dist/validation.js.map +1 -1
- package/package.json +18 -22
- package/schema/schema.json +15 -8
package/dist/next/config.cjs
CHANGED
|
@@ -45,8 +45,7 @@ var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
|
|
|
45
45
|
|
|
46
46
|
// src/config/overrides/is-override-cookie.ts
|
|
47
47
|
function isOverrideCookie(cookie) {
|
|
48
|
-
|
|
49
|
-
return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
48
|
+
return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
// src/config/overrides/get-override-from-cookie.ts
|
|
@@ -78,9 +77,9 @@ var MicrofrontendError = class extends Error {
|
|
|
78
77
|
constructor(message, opts) {
|
|
79
78
|
super(message);
|
|
80
79
|
this.name = "MicrofrontendsError";
|
|
81
|
-
this.source =
|
|
82
|
-
this.type =
|
|
83
|
-
this.subtype = opts
|
|
80
|
+
this.source = opts?.source ?? "@vercel/microfrontends";
|
|
81
|
+
this.type = opts?.type ?? "unknown";
|
|
82
|
+
this.subtype = opts?.subtype;
|
|
84
83
|
Error.captureStackTrace(this, MicrofrontendError);
|
|
85
84
|
}
|
|
86
85
|
isKnown() {
|
|
@@ -95,7 +94,7 @@ var MicrofrontendError = class extends Error {
|
|
|
95
94
|
* @returns The converted MicrofrontendsError.
|
|
96
95
|
*/
|
|
97
96
|
static convert(original, opts) {
|
|
98
|
-
if (opts
|
|
97
|
+
if (opts?.fileName) {
|
|
99
98
|
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
100
99
|
if (err) {
|
|
101
100
|
return err;
|
|
@@ -196,7 +195,7 @@ var MicrofrontendConfigClient = class {
|
|
|
196
195
|
constructor(config, opts) {
|
|
197
196
|
this.pathCache = {};
|
|
198
197
|
this.serialized = config;
|
|
199
|
-
if (opts
|
|
198
|
+
if (opts?.removeFlaggedPaths) {
|
|
200
199
|
for (const app of Object.values(config.applications)) {
|
|
201
200
|
if (app.routing) {
|
|
202
201
|
app.routing = app.routing.filter((match) => !match.flag);
|
|
@@ -258,17 +257,6 @@ var MicrofrontendConfigClient = class {
|
|
|
258
257
|
|
|
259
258
|
// src/config/microfrontends-config/isomorphic/validation.ts
|
|
260
259
|
var import_path_to_regexp2 = require("path-to-regexp");
|
|
261
|
-
var SUPPORTED_VERSIONS = ["2"];
|
|
262
|
-
var validateConfigVersion = (version) => {
|
|
263
|
-
if (!SUPPORTED_VERSIONS.includes(version)) {
|
|
264
|
-
throw new MicrofrontendError(
|
|
265
|
-
`Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
|
|
266
|
-
", "
|
|
267
|
-
)}`,
|
|
268
|
-
{ type: "config", subtype: "unsupported_version" }
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
260
|
var validateConfigPaths = (applicationConfigsById) => {
|
|
273
261
|
if (!applicationConfigsById) {
|
|
274
262
|
return;
|
|
@@ -444,7 +432,7 @@ var Host = class {
|
|
|
444
432
|
this.protocol = protocol;
|
|
445
433
|
this.host = host;
|
|
446
434
|
this.port = Host.getPort({ port, protocol: this.protocol });
|
|
447
|
-
this.local = options
|
|
435
|
+
this.local = options?.isLocal;
|
|
448
436
|
}
|
|
449
437
|
isLocal() {
|
|
450
438
|
return this.local || this.host === "localhost" || this.host === "127.0.0.1";
|
|
@@ -493,18 +481,17 @@ var Application = class {
|
|
|
493
481
|
overrides,
|
|
494
482
|
isDefault
|
|
495
483
|
}) {
|
|
496
|
-
var _a, _b;
|
|
497
484
|
this.name = name;
|
|
498
485
|
this.development = {
|
|
499
486
|
local: new LocalHost({
|
|
500
487
|
appName: name,
|
|
501
|
-
...
|
|
488
|
+
...app.development?.local
|
|
502
489
|
}),
|
|
503
|
-
fallback:
|
|
490
|
+
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
504
491
|
};
|
|
505
492
|
this.production = app.production ? new Host(app.production) : void 0;
|
|
506
493
|
this.vercel = app.vercel;
|
|
507
|
-
this.overrides =
|
|
494
|
+
this.overrides = overrides?.environment ? {
|
|
508
495
|
environment: new Host(overrides.environment)
|
|
509
496
|
} : void 0;
|
|
510
497
|
this.default = isDefault ?? false;
|
|
@@ -564,17 +551,17 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
564
551
|
constructor({
|
|
565
552
|
config,
|
|
566
553
|
overrides,
|
|
567
|
-
meta
|
|
554
|
+
meta,
|
|
555
|
+
opts
|
|
568
556
|
}) {
|
|
569
557
|
this.childApplications = {};
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
|
|
558
|
+
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
559
|
+
const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
|
|
573
560
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
574
561
|
this.isMainConfig = isMainConfig(config);
|
|
575
562
|
if (isMainConfig(config)) {
|
|
576
563
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
577
|
-
const appOverrides = !disableOverrides ?
|
|
564
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
578
565
|
if (isDefaultApp(appConfig)) {
|
|
579
566
|
this.defaultApplication = new DefaultApplication(appId, {
|
|
580
567
|
app: appConfig,
|
|
@@ -589,7 +576,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
589
576
|
}
|
|
590
577
|
} else {
|
|
591
578
|
this.partOf = config.partOf;
|
|
592
|
-
const appOverrides = !disableOverrides ?
|
|
579
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
|
|
593
580
|
this.childApplications[meta.fromApp] = new ChildApplication(
|
|
594
581
|
meta.fromApp,
|
|
595
582
|
{
|
|
@@ -617,12 +604,9 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
617
604
|
};
|
|
618
605
|
}
|
|
619
606
|
static validate(config, opts) {
|
|
620
|
-
const skipValidation =
|
|
607
|
+
const skipValidation = opts?.skipValidation ?? [];
|
|
621
608
|
const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
|
|
622
609
|
if (isMainConfig(c)) {
|
|
623
|
-
if (!skipValidation.includes("version")) {
|
|
624
|
-
validateConfigVersion(c.version);
|
|
625
|
-
}
|
|
626
610
|
if (!skipValidation.includes("paths")) {
|
|
627
611
|
validateConfigPaths(c.applications);
|
|
628
612
|
}
|
|
@@ -643,8 +627,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
643
627
|
});
|
|
644
628
|
}
|
|
645
629
|
isOverridesDisabled() {
|
|
646
|
-
|
|
647
|
-
return ((_b = (_a = this.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
|
|
630
|
+
return this.options?.vercel?.disableOverrides ?? false;
|
|
648
631
|
}
|
|
649
632
|
getConfig() {
|
|
650
633
|
return this.config;
|
|
@@ -665,8 +648,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
665
648
|
].filter(Boolean);
|
|
666
649
|
}
|
|
667
650
|
getApplication(name) {
|
|
668
|
-
|
|
669
|
-
if (((_a = this.defaultApplication) == null ? void 0 : _a.name) === name) {
|
|
651
|
+
if (this.defaultApplication?.name === name) {
|
|
670
652
|
return this.defaultApplication;
|
|
671
653
|
}
|
|
672
654
|
const app = this.childApplications[name];
|
|
@@ -682,15 +664,11 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
682
664
|
return app;
|
|
683
665
|
}
|
|
684
666
|
getApplicationByProjectId(projectId) {
|
|
685
|
-
|
|
686
|
-
if (((_b = (_a = this.defaultApplication) == null ? void 0 : _a.vercel) == null ? void 0 : _b.projectId) === projectId) {
|
|
667
|
+
if (this.defaultApplication?.vercel?.projectId === projectId) {
|
|
687
668
|
return this.defaultApplication;
|
|
688
669
|
}
|
|
689
670
|
return Object.values(this.childApplications).find(
|
|
690
|
-
(app) =>
|
|
691
|
-
var _a2;
|
|
692
|
-
return ((_a2 = app.vercel) == null ? void 0 : _a2.projectId) === projectId;
|
|
693
|
-
}
|
|
671
|
+
(app) => app.vercel?.projectId === projectId
|
|
694
672
|
);
|
|
695
673
|
}
|
|
696
674
|
/**
|
|
@@ -713,8 +691,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
713
691
|
* Returns the configured port for the local proxy
|
|
714
692
|
*/
|
|
715
693
|
getLocalProxyPort() {
|
|
716
|
-
|
|
717
|
-
return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
694
|
+
return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
718
695
|
}
|
|
719
696
|
/**
|
|
720
697
|
* Serializes the class back to the Schema type.
|
|
@@ -768,13 +745,12 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
768
745
|
overrides,
|
|
769
746
|
meta
|
|
770
747
|
}) {
|
|
771
|
-
var _a, _b, _c;
|
|
772
748
|
super({ config, overrides, meta });
|
|
773
749
|
this.isMainConfig = true;
|
|
774
|
-
const disableOverrides =
|
|
750
|
+
const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
|
|
775
751
|
let defaultApplication;
|
|
776
752
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
777
|
-
const appOverrides = !disableOverrides ?
|
|
753
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
778
754
|
if (isDefaultApp(appConfig)) {
|
|
779
755
|
defaultApplication = new DefaultApplication(appId, {
|
|
780
756
|
app: appConfig,
|
|
@@ -967,7 +943,7 @@ function findDefaultMicrofrontendsPackage(opts) {
|
|
|
967
943
|
const result = findDefaultMicrofrontendsPackages(opts);
|
|
968
944
|
if (!result) {
|
|
969
945
|
throw new Error(
|
|
970
|
-
|
|
946
|
+
"Error trying to resolve the main microfrontends configuration"
|
|
971
947
|
);
|
|
972
948
|
}
|
|
973
949
|
configCache2[cacheKey] = result;
|
|
@@ -1039,20 +1015,8 @@ var import_node_path7 = __toESM(require("path"), 1);
|
|
|
1039
1015
|
var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
|
|
1040
1016
|
var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
|
|
1041
1017
|
|
|
1042
|
-
// src/utils/is-vercel.ts
|
|
1043
|
-
function isVercel() {
|
|
1044
|
-
return process.env.VERCEL === "1";
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
1018
|
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
1048
1019
|
function getOutputFilePath() {
|
|
1049
|
-
if (isVercel()) {
|
|
1050
|
-
return import_node_path7.default.join(
|
|
1051
|
-
".vercel",
|
|
1052
|
-
MFE_CONFIG_DEFAULT_FILE_PATH,
|
|
1053
|
-
MFE_CONFIG_DEFAULT_FILE_NAME
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
1056
1020
|
return import_node_path7.default.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
|
|
1057
1021
|
}
|
|
1058
1022
|
|
|
@@ -1083,7 +1047,7 @@ var schema_default = {
|
|
|
1083
1047
|
},
|
|
1084
1048
|
version: {
|
|
1085
1049
|
type: "string",
|
|
1086
|
-
const: "
|
|
1050
|
+
const: "1"
|
|
1087
1051
|
},
|
|
1088
1052
|
options: {
|
|
1089
1053
|
$ref: "#/definitions/Options"
|
|
@@ -1093,6 +1057,9 @@ var schema_default = {
|
|
|
1093
1057
|
additionalProperties: {
|
|
1094
1058
|
$ref: "#/definitions/Application"
|
|
1095
1059
|
},
|
|
1060
|
+
propertyNames: {
|
|
1061
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1062
|
+
},
|
|
1096
1063
|
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."
|
|
1097
1064
|
},
|
|
1098
1065
|
applications: {
|
|
@@ -1100,7 +1067,9 @@ var schema_default = {
|
|
|
1100
1067
|
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"
|
|
1101
1068
|
}
|
|
1102
1069
|
},
|
|
1103
|
-
required: [
|
|
1070
|
+
required: [
|
|
1071
|
+
"applications"
|
|
1072
|
+
],
|
|
1104
1073
|
additionalProperties: false
|
|
1105
1074
|
},
|
|
1106
1075
|
Options: {
|
|
@@ -1164,7 +1133,9 @@ var schema_default = {
|
|
|
1164
1133
|
$ref: "#/definitions/HostConfig"
|
|
1165
1134
|
}
|
|
1166
1135
|
},
|
|
1167
|
-
required: [
|
|
1136
|
+
required: [
|
|
1137
|
+
"production"
|
|
1138
|
+
],
|
|
1168
1139
|
additionalProperties: false
|
|
1169
1140
|
},
|
|
1170
1141
|
Vercel: {
|
|
@@ -1175,7 +1146,9 @@ var schema_default = {
|
|
|
1175
1146
|
description: "Vercel project ID"
|
|
1176
1147
|
}
|
|
1177
1148
|
},
|
|
1178
|
-
required: [
|
|
1149
|
+
required: [
|
|
1150
|
+
"projectId"
|
|
1151
|
+
],
|
|
1179
1152
|
additionalProperties: false
|
|
1180
1153
|
},
|
|
1181
1154
|
Development: {
|
|
@@ -1205,8 +1178,11 @@ var schema_default = {
|
|
|
1205
1178
|
},
|
|
1206
1179
|
protocol: {
|
|
1207
1180
|
type: "string",
|
|
1208
|
-
enum: [
|
|
1209
|
-
|
|
1181
|
+
enum: [
|
|
1182
|
+
"http",
|
|
1183
|
+
"https"
|
|
1184
|
+
],
|
|
1185
|
+
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1210
1186
|
},
|
|
1211
1187
|
port: {
|
|
1212
1188
|
type: "number",
|
|
@@ -1219,8 +1195,11 @@ var schema_default = {
|
|
|
1219
1195
|
properties: {
|
|
1220
1196
|
protocol: {
|
|
1221
1197
|
type: "string",
|
|
1222
|
-
enum: [
|
|
1223
|
-
|
|
1198
|
+
enum: [
|
|
1199
|
+
"http",
|
|
1200
|
+
"https"
|
|
1201
|
+
],
|
|
1202
|
+
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1224
1203
|
},
|
|
1225
1204
|
host: {
|
|
1226
1205
|
type: "string",
|
|
@@ -1231,7 +1210,9 @@ var schema_default = {
|
|
|
1231
1210
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1232
1211
|
}
|
|
1233
1212
|
},
|
|
1234
|
-
required: [
|
|
1213
|
+
required: [
|
|
1214
|
+
"host"
|
|
1215
|
+
],
|
|
1235
1216
|
additionalProperties: false
|
|
1236
1217
|
},
|
|
1237
1218
|
ChildApplication: {
|
|
@@ -1251,7 +1232,9 @@ var schema_default = {
|
|
|
1251
1232
|
$ref: "#/definitions/HostConfig"
|
|
1252
1233
|
}
|
|
1253
1234
|
},
|
|
1254
|
-
required: [
|
|
1235
|
+
required: [
|
|
1236
|
+
"routing"
|
|
1237
|
+
],
|
|
1255
1238
|
additionalProperties: false
|
|
1256
1239
|
},
|
|
1257
1240
|
Routing: {
|
|
@@ -1278,13 +1261,18 @@ var schema_default = {
|
|
|
1278
1261
|
}
|
|
1279
1262
|
}
|
|
1280
1263
|
},
|
|
1281
|
-
required: [
|
|
1264
|
+
required: [
|
|
1265
|
+
"paths"
|
|
1266
|
+
],
|
|
1282
1267
|
additionalProperties: false
|
|
1283
1268
|
},
|
|
1284
1269
|
ApplicationRouting: {
|
|
1285
1270
|
type: "object",
|
|
1286
1271
|
additionalProperties: {
|
|
1287
1272
|
$ref: "#/definitions/Application"
|
|
1273
|
+
},
|
|
1274
|
+
propertyNames: {
|
|
1275
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1288
1276
|
}
|
|
1289
1277
|
},
|
|
1290
1278
|
ChildConfig: {
|
|
@@ -1295,7 +1283,7 @@ var schema_default = {
|
|
|
1295
1283
|
},
|
|
1296
1284
|
version: {
|
|
1297
1285
|
type: "string",
|
|
1298
|
-
const: "
|
|
1286
|
+
const: "1"
|
|
1299
1287
|
},
|
|
1300
1288
|
options: {
|
|
1301
1289
|
$ref: "#/definitions/Options"
|
|
@@ -1305,6 +1293,9 @@ var schema_default = {
|
|
|
1305
1293
|
additionalProperties: {
|
|
1306
1294
|
$ref: "#/definitions/Application"
|
|
1307
1295
|
},
|
|
1296
|
+
propertyNames: {
|
|
1297
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1298
|
+
},
|
|
1308
1299
|
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."
|
|
1309
1300
|
},
|
|
1310
1301
|
partOf: {
|
|
@@ -1312,7 +1303,9 @@ var schema_default = {
|
|
|
1312
1303
|
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."
|
|
1313
1304
|
}
|
|
1314
1305
|
},
|
|
1315
|
-
required: [
|
|
1306
|
+
required: [
|
|
1307
|
+
"partOf"
|
|
1308
|
+
],
|
|
1316
1309
|
additionalProperties: false
|
|
1317
1310
|
}
|
|
1318
1311
|
}
|
|
@@ -1486,7 +1479,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1486
1479
|
try {
|
|
1487
1480
|
const configJson = import_node_fs7.default.readFileSync(filePath, "utf-8");
|
|
1488
1481
|
const config = MicrofrontendsServer.validate(configJson);
|
|
1489
|
-
if (!isMainConfig(config) &&
|
|
1482
|
+
if (!isMainConfig(config) && options?.resolveMainConfig) {
|
|
1490
1483
|
const repositoryRoot = findRepositoryRoot();
|
|
1491
1484
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1492
1485
|
if (isMonorepo2) {
|
|
@@ -1594,9 +1587,8 @@ function transform(args) {
|
|
|
1594
1587
|
|
|
1595
1588
|
// src/next/config/transforms/draft-mode.ts
|
|
1596
1589
|
function transform2(args) {
|
|
1597
|
-
var _a;
|
|
1598
1590
|
const { next } = args;
|
|
1599
|
-
if (
|
|
1591
|
+
if (next.experimental?.multiZoneDraftMode !== void 0) {
|
|
1600
1592
|
return {
|
|
1601
1593
|
next
|
|
1602
1594
|
};
|
|
@@ -1670,21 +1662,17 @@ function getDomainFromEnvironment({
|
|
|
1670
1662
|
app,
|
|
1671
1663
|
target
|
|
1672
1664
|
}) {
|
|
1673
|
-
var _a;
|
|
1674
1665
|
const mfeProjects = JSON.parse(
|
|
1675
1666
|
process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "[]"
|
|
1676
1667
|
);
|
|
1677
1668
|
if (mfeProjects.length === 0) {
|
|
1678
1669
|
throw new Error("Missing related microfrontends project information");
|
|
1679
1670
|
}
|
|
1680
|
-
if (!
|
|
1671
|
+
if (!app.vercel?.projectId) {
|
|
1681
1672
|
throw new Error(`Missing applications[${app.name}].vercel.projectId`);
|
|
1682
1673
|
}
|
|
1683
1674
|
const vercelProject = mfeProjects.find(
|
|
1684
|
-
(p) =>
|
|
1685
|
-
var _a2;
|
|
1686
|
-
return p.project.id === ((_a2 = app.vercel) == null ? void 0 : _a2.projectId);
|
|
1687
|
-
}
|
|
1675
|
+
(p) => p.project.id === app.vercel?.projectId
|
|
1688
1676
|
);
|
|
1689
1677
|
if (!vercelProject) {
|
|
1690
1678
|
throw new Error(
|
|
@@ -1727,9 +1715,8 @@ function getCurrentEnvironment() {
|
|
|
1727
1715
|
return { group: "custom", name: process.env.VERCEL_ENV };
|
|
1728
1716
|
}
|
|
1729
1717
|
function getDomainForCurrentEnvironment(config, appName, opts = {}) {
|
|
1730
|
-
var _a;
|
|
1731
1718
|
const app = config.getApplication(appName);
|
|
1732
|
-
if (!opts.ignoreOverride &&
|
|
1719
|
+
if (!opts.ignoreOverride && app.overrides?.environment) {
|
|
1733
1720
|
return app.overrides.environment.toString();
|
|
1734
1721
|
}
|
|
1735
1722
|
const { group } = getCurrentEnvironment();
|
|
@@ -1774,11 +1761,10 @@ ${table}
|
|
|
1774
1761
|
}
|
|
1775
1762
|
}
|
|
1776
1763
|
function pathToRewrites(path5) {
|
|
1777
|
-
var _a;
|
|
1778
1764
|
const regex = /(?<base>^.+)\/:.+\*$/;
|
|
1779
1765
|
const match = regex.exec(path5);
|
|
1780
1766
|
const paths = [path5];
|
|
1781
|
-
if (
|
|
1767
|
+
if (match?.groups?.base) {
|
|
1782
1768
|
paths.unshift(match.groups.base);
|
|
1783
1769
|
}
|
|
1784
1770
|
return paths;
|
|
@@ -1908,7 +1894,6 @@ ${table}
|
|
|
1908
1894
|
}
|
|
1909
1895
|
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1910
1896
|
function transform5(args) {
|
|
1911
|
-
var _a, _b;
|
|
1912
1897
|
const { next, app, microfrontend } = args;
|
|
1913
1898
|
if (microfrontend instanceof MicrofrontendChildConfig) {
|
|
1914
1899
|
console.warn(
|
|
@@ -1927,7 +1912,7 @@ function transform5(args) {
|
|
|
1927
1912
|
// that are in the default zone.
|
|
1928
1913
|
defaultApplication
|
|
1929
1914
|
];
|
|
1930
|
-
const existingServerActionConfig =
|
|
1915
|
+
const existingServerActionConfig = next.experimental?.serverActions;
|
|
1931
1916
|
next.experimental = {
|
|
1932
1917
|
...next.experimental,
|
|
1933
1918
|
serverActions: {
|
|
@@ -1935,7 +1920,7 @@ function transform5(args) {
|
|
|
1935
1920
|
allowedOrigins: Array.from(
|
|
1936
1921
|
/* @__PURE__ */ new Set([
|
|
1937
1922
|
// existing
|
|
1938
|
-
...
|
|
1923
|
+
...existingServerActionConfig?.allowedOrigins ?? [],
|
|
1939
1924
|
// this deployments host
|
|
1940
1925
|
...process.env.VERCEL_URL ? [formatDomainForServerAction(process.env.VERCEL_URL)] : [],
|
|
1941
1926
|
// default application host
|
|
@@ -1950,7 +1935,7 @@ function transform5(args) {
|
|
|
1950
1935
|
)
|
|
1951
1936
|
}
|
|
1952
1937
|
};
|
|
1953
|
-
debugRewrites2(
|
|
1938
|
+
debugRewrites2(next.experimental.serverActions?.allowedOrigins);
|
|
1954
1939
|
return {
|
|
1955
1940
|
next
|
|
1956
1941
|
};
|
|
@@ -2032,7 +2017,10 @@ function setEnvironment({
|
|
|
2032
2017
|
NEXT_PUBLIC_MFE_CURRENT_APPLICATION: app.name,
|
|
2033
2018
|
NEXT_PUBLIC_MFE_CLIENT_CONFIG: JSON.stringify(
|
|
2034
2019
|
microfrontends.config.toClientConfig().serialize()
|
|
2035
|
-
)
|
|
2020
|
+
),
|
|
2021
|
+
...process.env.ROUTE_OBSERVABILITY_TO_DEFAULT_APP || !app.getAssetPrefix() ? {} : {
|
|
2022
|
+
NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH: `/${app.getAssetPrefix()}/_vercel`
|
|
2023
|
+
}
|
|
2036
2024
|
};
|
|
2037
2025
|
const serverEnvs = {
|
|
2038
2026
|
MFE_CURRENT_APPLICATION: app.name,
|
|
@@ -2050,13 +2038,13 @@ function typedEntries(obj) {
|
|
|
2050
2038
|
return Object.entries(obj);
|
|
2051
2039
|
}
|
|
2052
2040
|
function isProduction(opts) {
|
|
2053
|
-
if (opts
|
|
2041
|
+
if (opts?.isProduction) {
|
|
2054
2042
|
return opts.isProduction();
|
|
2055
2043
|
}
|
|
2056
2044
|
return process.env.VERCEL_ENV === "production";
|
|
2057
2045
|
}
|
|
2058
2046
|
function getApplicationContext(opts) {
|
|
2059
|
-
if (opts
|
|
2047
|
+
if (opts?.appName) {
|
|
2060
2048
|
return { name: opts.appName };
|
|
2061
2049
|
}
|
|
2062
2050
|
try {
|
|
@@ -2080,13 +2068,12 @@ function getApplicationContext(opts) {
|
|
|
2080
2068
|
}
|
|
2081
2069
|
}
|
|
2082
2070
|
function withMicrofrontends(nextConfig, opts) {
|
|
2083
|
-
|
|
2084
|
-
if (opts == null ? void 0 : opts.debug) {
|
|
2071
|
+
if (opts?.debug) {
|
|
2085
2072
|
process.env.MFE_DEBUG = "true";
|
|
2086
2073
|
}
|
|
2087
2074
|
const { name: fromApp } = getApplicationContext(opts);
|
|
2088
2075
|
const microfrontends = MicrofrontendsServer.infer({
|
|
2089
|
-
filePath: opts
|
|
2076
|
+
filePath: opts?.configPath,
|
|
2090
2077
|
meta: {
|
|
2091
2078
|
fromApp
|
|
2092
2079
|
}
|
|
@@ -2095,7 +2082,7 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2095
2082
|
setEnvironment({ app, microfrontends });
|
|
2096
2083
|
let next = { ...nextConfig };
|
|
2097
2084
|
for (const [key, transform7] of typedEntries(transforms)) {
|
|
2098
|
-
if (
|
|
2085
|
+
if (opts?.skipTransforms?.includes(key)) {
|
|
2099
2086
|
console.log(`Skipping ${key} transform`);
|
|
2100
2087
|
continue;
|
|
2101
2088
|
}
|
|
@@ -2111,12 +2098,10 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2111
2098
|
next = transformedConfig.next;
|
|
2112
2099
|
} catch (e) {
|
|
2113
2100
|
console.error("Error transforming next config", e);
|
|
2101
|
+
throw e;
|
|
2114
2102
|
}
|
|
2115
2103
|
}
|
|
2116
2104
|
displayLocalProxyInfo(microfrontends.config.getLocalProxyPort());
|
|
2117
|
-
if (isVercel()) {
|
|
2118
|
-
microfrontends.writeConfig();
|
|
2119
|
-
}
|
|
2120
2105
|
return next;
|
|
2121
2106
|
}
|
|
2122
2107
|
// Annotate the CommonJS export names for ESM import in node:
|