@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.js
CHANGED
|
@@ -11,8 +11,7 @@ var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
|
|
|
11
11
|
|
|
12
12
|
// src/config/overrides/is-override-cookie.ts
|
|
13
13
|
function isOverrideCookie(cookie) {
|
|
14
|
-
|
|
15
|
-
return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
14
|
+
return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
// src/config/overrides/get-override-from-cookie.ts
|
|
@@ -44,9 +43,9 @@ var MicrofrontendError = class extends Error {
|
|
|
44
43
|
constructor(message, opts) {
|
|
45
44
|
super(message);
|
|
46
45
|
this.name = "MicrofrontendsError";
|
|
47
|
-
this.source =
|
|
48
|
-
this.type =
|
|
49
|
-
this.subtype = opts
|
|
46
|
+
this.source = opts?.source ?? "@vercel/microfrontends";
|
|
47
|
+
this.type = opts?.type ?? "unknown";
|
|
48
|
+
this.subtype = opts?.subtype;
|
|
50
49
|
Error.captureStackTrace(this, MicrofrontendError);
|
|
51
50
|
}
|
|
52
51
|
isKnown() {
|
|
@@ -61,7 +60,7 @@ var MicrofrontendError = class extends Error {
|
|
|
61
60
|
* @returns The converted MicrofrontendsError.
|
|
62
61
|
*/
|
|
63
62
|
static convert(original, opts) {
|
|
64
|
-
if (opts
|
|
63
|
+
if (opts?.fileName) {
|
|
65
64
|
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
66
65
|
if (err) {
|
|
67
66
|
return err;
|
|
@@ -162,7 +161,7 @@ var MicrofrontendConfigClient = class {
|
|
|
162
161
|
constructor(config, opts) {
|
|
163
162
|
this.pathCache = {};
|
|
164
163
|
this.serialized = config;
|
|
165
|
-
if (opts
|
|
164
|
+
if (opts?.removeFlaggedPaths) {
|
|
166
165
|
for (const app of Object.values(config.applications)) {
|
|
167
166
|
if (app.routing) {
|
|
168
167
|
app.routing = app.routing.filter((match) => !match.flag);
|
|
@@ -224,17 +223,6 @@ var MicrofrontendConfigClient = class {
|
|
|
224
223
|
|
|
225
224
|
// src/config/microfrontends-config/isomorphic/validation.ts
|
|
226
225
|
import { pathToRegexp as pathToRegexp2, parse as parsePathRegexp } from "path-to-regexp";
|
|
227
|
-
var SUPPORTED_VERSIONS = ["2"];
|
|
228
|
-
var validateConfigVersion = (version) => {
|
|
229
|
-
if (!SUPPORTED_VERSIONS.includes(version)) {
|
|
230
|
-
throw new MicrofrontendError(
|
|
231
|
-
`Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
|
|
232
|
-
", "
|
|
233
|
-
)}`,
|
|
234
|
-
{ type: "config", subtype: "unsupported_version" }
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
226
|
var validateConfigPaths = (applicationConfigsById) => {
|
|
239
227
|
if (!applicationConfigsById) {
|
|
240
228
|
return;
|
|
@@ -410,7 +398,7 @@ var Host = class {
|
|
|
410
398
|
this.protocol = protocol;
|
|
411
399
|
this.host = host;
|
|
412
400
|
this.port = Host.getPort({ port, protocol: this.protocol });
|
|
413
|
-
this.local = options
|
|
401
|
+
this.local = options?.isLocal;
|
|
414
402
|
}
|
|
415
403
|
isLocal() {
|
|
416
404
|
return this.local || this.host === "localhost" || this.host === "127.0.0.1";
|
|
@@ -459,18 +447,17 @@ var Application = class {
|
|
|
459
447
|
overrides,
|
|
460
448
|
isDefault
|
|
461
449
|
}) {
|
|
462
|
-
var _a, _b;
|
|
463
450
|
this.name = name;
|
|
464
451
|
this.development = {
|
|
465
452
|
local: new LocalHost({
|
|
466
453
|
appName: name,
|
|
467
|
-
...
|
|
454
|
+
...app.development?.local
|
|
468
455
|
}),
|
|
469
|
-
fallback:
|
|
456
|
+
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
470
457
|
};
|
|
471
458
|
this.production = app.production ? new Host(app.production) : void 0;
|
|
472
459
|
this.vercel = app.vercel;
|
|
473
|
-
this.overrides =
|
|
460
|
+
this.overrides = overrides?.environment ? {
|
|
474
461
|
environment: new Host(overrides.environment)
|
|
475
462
|
} : void 0;
|
|
476
463
|
this.default = isDefault ?? false;
|
|
@@ -530,17 +517,17 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
530
517
|
constructor({
|
|
531
518
|
config,
|
|
532
519
|
overrides,
|
|
533
|
-
meta
|
|
520
|
+
meta,
|
|
521
|
+
opts
|
|
534
522
|
}) {
|
|
535
523
|
this.childApplications = {};
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
|
|
524
|
+
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
525
|
+
const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
|
|
539
526
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
540
527
|
this.isMainConfig = isMainConfig(config);
|
|
541
528
|
if (isMainConfig(config)) {
|
|
542
529
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
543
|
-
const appOverrides = !disableOverrides ?
|
|
530
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
544
531
|
if (isDefaultApp(appConfig)) {
|
|
545
532
|
this.defaultApplication = new DefaultApplication(appId, {
|
|
546
533
|
app: appConfig,
|
|
@@ -555,7 +542,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
555
542
|
}
|
|
556
543
|
} else {
|
|
557
544
|
this.partOf = config.partOf;
|
|
558
|
-
const appOverrides = !disableOverrides ?
|
|
545
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
|
|
559
546
|
this.childApplications[meta.fromApp] = new ChildApplication(
|
|
560
547
|
meta.fromApp,
|
|
561
548
|
{
|
|
@@ -583,12 +570,9 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
583
570
|
};
|
|
584
571
|
}
|
|
585
572
|
static validate(config, opts) {
|
|
586
|
-
const skipValidation =
|
|
573
|
+
const skipValidation = opts?.skipValidation ?? [];
|
|
587
574
|
const c = typeof config === "string" ? parse(config) : config;
|
|
588
575
|
if (isMainConfig(c)) {
|
|
589
|
-
if (!skipValidation.includes("version")) {
|
|
590
|
-
validateConfigVersion(c.version);
|
|
591
|
-
}
|
|
592
576
|
if (!skipValidation.includes("paths")) {
|
|
593
577
|
validateConfigPaths(c.applications);
|
|
594
578
|
}
|
|
@@ -609,8 +593,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
609
593
|
});
|
|
610
594
|
}
|
|
611
595
|
isOverridesDisabled() {
|
|
612
|
-
|
|
613
|
-
return ((_b = (_a = this.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
|
|
596
|
+
return this.options?.vercel?.disableOverrides ?? false;
|
|
614
597
|
}
|
|
615
598
|
getConfig() {
|
|
616
599
|
return this.config;
|
|
@@ -631,8 +614,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
631
614
|
].filter(Boolean);
|
|
632
615
|
}
|
|
633
616
|
getApplication(name) {
|
|
634
|
-
|
|
635
|
-
if (((_a = this.defaultApplication) == null ? void 0 : _a.name) === name) {
|
|
617
|
+
if (this.defaultApplication?.name === name) {
|
|
636
618
|
return this.defaultApplication;
|
|
637
619
|
}
|
|
638
620
|
const app = this.childApplications[name];
|
|
@@ -648,15 +630,11 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
648
630
|
return app;
|
|
649
631
|
}
|
|
650
632
|
getApplicationByProjectId(projectId) {
|
|
651
|
-
|
|
652
|
-
if (((_b = (_a = this.defaultApplication) == null ? void 0 : _a.vercel) == null ? void 0 : _b.projectId) === projectId) {
|
|
633
|
+
if (this.defaultApplication?.vercel?.projectId === projectId) {
|
|
653
634
|
return this.defaultApplication;
|
|
654
635
|
}
|
|
655
636
|
return Object.values(this.childApplications).find(
|
|
656
|
-
(app) =>
|
|
657
|
-
var _a2;
|
|
658
|
-
return ((_a2 = app.vercel) == null ? void 0 : _a2.projectId) === projectId;
|
|
659
|
-
}
|
|
637
|
+
(app) => app.vercel?.projectId === projectId
|
|
660
638
|
);
|
|
661
639
|
}
|
|
662
640
|
/**
|
|
@@ -679,8 +657,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
679
657
|
* Returns the configured port for the local proxy
|
|
680
658
|
*/
|
|
681
659
|
getLocalProxyPort() {
|
|
682
|
-
|
|
683
|
-
return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
660
|
+
return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
684
661
|
}
|
|
685
662
|
/**
|
|
686
663
|
* Serializes the class back to the Schema type.
|
|
@@ -734,13 +711,12 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
734
711
|
overrides,
|
|
735
712
|
meta
|
|
736
713
|
}) {
|
|
737
|
-
var _a, _b, _c;
|
|
738
714
|
super({ config, overrides, meta });
|
|
739
715
|
this.isMainConfig = true;
|
|
740
|
-
const disableOverrides =
|
|
716
|
+
const disableOverrides = config.options?.vercel?.disableOverrides ?? false;
|
|
741
717
|
let defaultApplication;
|
|
742
718
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
743
|
-
const appOverrides = !disableOverrides ?
|
|
719
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
744
720
|
if (isDefaultApp(appConfig)) {
|
|
745
721
|
defaultApplication = new DefaultApplication(appId, {
|
|
746
722
|
app: appConfig,
|
|
@@ -933,7 +909,7 @@ function findDefaultMicrofrontendsPackage(opts) {
|
|
|
933
909
|
const result = findDefaultMicrofrontendsPackages(opts);
|
|
934
910
|
if (!result) {
|
|
935
911
|
throw new Error(
|
|
936
|
-
|
|
912
|
+
"Error trying to resolve the main microfrontends configuration"
|
|
937
913
|
);
|
|
938
914
|
}
|
|
939
915
|
configCache2[cacheKey] = result;
|
|
@@ -1005,20 +981,8 @@ import path4 from "node:path";
|
|
|
1005
981
|
var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
|
|
1006
982
|
var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
|
|
1007
983
|
|
|
1008
|
-
// src/utils/is-vercel.ts
|
|
1009
|
-
function isVercel() {
|
|
1010
|
-
return process.env.VERCEL === "1";
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
984
|
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
1014
985
|
function getOutputFilePath() {
|
|
1015
|
-
if (isVercel()) {
|
|
1016
|
-
return path4.join(
|
|
1017
|
-
".vercel",
|
|
1018
|
-
MFE_CONFIG_DEFAULT_FILE_PATH,
|
|
1019
|
-
MFE_CONFIG_DEFAULT_FILE_NAME
|
|
1020
|
-
);
|
|
1021
|
-
}
|
|
1022
986
|
return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
|
|
1023
987
|
}
|
|
1024
988
|
|
|
@@ -1049,7 +1013,7 @@ var schema_default = {
|
|
|
1049
1013
|
},
|
|
1050
1014
|
version: {
|
|
1051
1015
|
type: "string",
|
|
1052
|
-
const: "
|
|
1016
|
+
const: "1"
|
|
1053
1017
|
},
|
|
1054
1018
|
options: {
|
|
1055
1019
|
$ref: "#/definitions/Options"
|
|
@@ -1059,6 +1023,9 @@ var schema_default = {
|
|
|
1059
1023
|
additionalProperties: {
|
|
1060
1024
|
$ref: "#/definitions/Application"
|
|
1061
1025
|
},
|
|
1026
|
+
propertyNames: {
|
|
1027
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1028
|
+
},
|
|
1062
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."
|
|
1063
1030
|
},
|
|
1064
1031
|
applications: {
|
|
@@ -1066,7 +1033,9 @@ var schema_default = {
|
|
|
1066
1033
|
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"
|
|
1067
1034
|
}
|
|
1068
1035
|
},
|
|
1069
|
-
required: [
|
|
1036
|
+
required: [
|
|
1037
|
+
"applications"
|
|
1038
|
+
],
|
|
1070
1039
|
additionalProperties: false
|
|
1071
1040
|
},
|
|
1072
1041
|
Options: {
|
|
@@ -1130,7 +1099,9 @@ var schema_default = {
|
|
|
1130
1099
|
$ref: "#/definitions/HostConfig"
|
|
1131
1100
|
}
|
|
1132
1101
|
},
|
|
1133
|
-
required: [
|
|
1102
|
+
required: [
|
|
1103
|
+
"production"
|
|
1104
|
+
],
|
|
1134
1105
|
additionalProperties: false
|
|
1135
1106
|
},
|
|
1136
1107
|
Vercel: {
|
|
@@ -1141,7 +1112,9 @@ var schema_default = {
|
|
|
1141
1112
|
description: "Vercel project ID"
|
|
1142
1113
|
}
|
|
1143
1114
|
},
|
|
1144
|
-
required: [
|
|
1115
|
+
required: [
|
|
1116
|
+
"projectId"
|
|
1117
|
+
],
|
|
1145
1118
|
additionalProperties: false
|
|
1146
1119
|
},
|
|
1147
1120
|
Development: {
|
|
@@ -1171,8 +1144,11 @@ var schema_default = {
|
|
|
1171
1144
|
},
|
|
1172
1145
|
protocol: {
|
|
1173
1146
|
type: "string",
|
|
1174
|
-
enum: [
|
|
1175
|
-
|
|
1147
|
+
enum: [
|
|
1148
|
+
"http",
|
|
1149
|
+
"https"
|
|
1150
|
+
],
|
|
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*"
|
|
1176
1152
|
},
|
|
1177
1153
|
port: {
|
|
1178
1154
|
type: "number",
|
|
@@ -1185,8 +1161,11 @@ var schema_default = {
|
|
|
1185
1161
|
properties: {
|
|
1186
1162
|
protocol: {
|
|
1187
1163
|
type: "string",
|
|
1188
|
-
enum: [
|
|
1189
|
-
|
|
1164
|
+
enum: [
|
|
1165
|
+
"http",
|
|
1166
|
+
"https"
|
|
1167
|
+
],
|
|
1168
|
+
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1190
1169
|
},
|
|
1191
1170
|
host: {
|
|
1192
1171
|
type: "string",
|
|
@@ -1197,7 +1176,9 @@ var schema_default = {
|
|
|
1197
1176
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1198
1177
|
}
|
|
1199
1178
|
},
|
|
1200
|
-
required: [
|
|
1179
|
+
required: [
|
|
1180
|
+
"host"
|
|
1181
|
+
],
|
|
1201
1182
|
additionalProperties: false
|
|
1202
1183
|
},
|
|
1203
1184
|
ChildApplication: {
|
|
@@ -1217,7 +1198,9 @@ var schema_default = {
|
|
|
1217
1198
|
$ref: "#/definitions/HostConfig"
|
|
1218
1199
|
}
|
|
1219
1200
|
},
|
|
1220
|
-
required: [
|
|
1201
|
+
required: [
|
|
1202
|
+
"routing"
|
|
1203
|
+
],
|
|
1221
1204
|
additionalProperties: false
|
|
1222
1205
|
},
|
|
1223
1206
|
Routing: {
|
|
@@ -1244,13 +1227,18 @@ var schema_default = {
|
|
|
1244
1227
|
}
|
|
1245
1228
|
}
|
|
1246
1229
|
},
|
|
1247
|
-
required: [
|
|
1230
|
+
required: [
|
|
1231
|
+
"paths"
|
|
1232
|
+
],
|
|
1248
1233
|
additionalProperties: false
|
|
1249
1234
|
},
|
|
1250
1235
|
ApplicationRouting: {
|
|
1251
1236
|
type: "object",
|
|
1252
1237
|
additionalProperties: {
|
|
1253
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`."
|
|
1254
1242
|
}
|
|
1255
1243
|
},
|
|
1256
1244
|
ChildConfig: {
|
|
@@ -1261,7 +1249,7 @@ var schema_default = {
|
|
|
1261
1249
|
},
|
|
1262
1250
|
version: {
|
|
1263
1251
|
type: "string",
|
|
1264
|
-
const: "
|
|
1252
|
+
const: "1"
|
|
1265
1253
|
},
|
|
1266
1254
|
options: {
|
|
1267
1255
|
$ref: "#/definitions/Options"
|
|
@@ -1271,6 +1259,9 @@ var schema_default = {
|
|
|
1271
1259
|
additionalProperties: {
|
|
1272
1260
|
$ref: "#/definitions/Application"
|
|
1273
1261
|
},
|
|
1262
|
+
propertyNames: {
|
|
1263
|
+
description: "The unique identifier for a Microfrontend Application. Must match the `name` field of the application's `package.json`."
|
|
1264
|
+
},
|
|
1274
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."
|
|
1275
1266
|
},
|
|
1276
1267
|
partOf: {
|
|
@@ -1278,7 +1269,9 @@ var schema_default = {
|
|
|
1278
1269
|
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."
|
|
1279
1270
|
}
|
|
1280
1271
|
},
|
|
1281
|
-
required: [
|
|
1272
|
+
required: [
|
|
1273
|
+
"partOf"
|
|
1274
|
+
],
|
|
1282
1275
|
additionalProperties: false
|
|
1283
1276
|
}
|
|
1284
1277
|
}
|
|
@@ -1452,7 +1445,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1452
1445
|
try {
|
|
1453
1446
|
const configJson = fs5.readFileSync(filePath, "utf-8");
|
|
1454
1447
|
const config = MicrofrontendsServer.validate(configJson);
|
|
1455
|
-
if (!isMainConfig(config) &&
|
|
1448
|
+
if (!isMainConfig(config) && options?.resolveMainConfig) {
|
|
1456
1449
|
const repositoryRoot = findRepositoryRoot();
|
|
1457
1450
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1458
1451
|
if (isMonorepo2) {
|
|
@@ -1560,9 +1553,8 @@ function transform(args) {
|
|
|
1560
1553
|
|
|
1561
1554
|
// src/next/config/transforms/draft-mode.ts
|
|
1562
1555
|
function transform2(args) {
|
|
1563
|
-
var _a;
|
|
1564
1556
|
const { next } = args;
|
|
1565
|
-
if (
|
|
1557
|
+
if (next.experimental?.multiZoneDraftMode !== void 0) {
|
|
1566
1558
|
return {
|
|
1567
1559
|
next
|
|
1568
1560
|
};
|
|
@@ -1636,21 +1628,17 @@ function getDomainFromEnvironment({
|
|
|
1636
1628
|
app,
|
|
1637
1629
|
target
|
|
1638
1630
|
}) {
|
|
1639
|
-
var _a;
|
|
1640
1631
|
const mfeProjects = JSON.parse(
|
|
1641
1632
|
process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "[]"
|
|
1642
1633
|
);
|
|
1643
1634
|
if (mfeProjects.length === 0) {
|
|
1644
1635
|
throw new Error("Missing related microfrontends project information");
|
|
1645
1636
|
}
|
|
1646
|
-
if (!
|
|
1637
|
+
if (!app.vercel?.projectId) {
|
|
1647
1638
|
throw new Error(`Missing applications[${app.name}].vercel.projectId`);
|
|
1648
1639
|
}
|
|
1649
1640
|
const vercelProject = mfeProjects.find(
|
|
1650
|
-
(p) =>
|
|
1651
|
-
var _a2;
|
|
1652
|
-
return p.project.id === ((_a2 = app.vercel) == null ? void 0 : _a2.projectId);
|
|
1653
|
-
}
|
|
1641
|
+
(p) => p.project.id === app.vercel?.projectId
|
|
1654
1642
|
);
|
|
1655
1643
|
if (!vercelProject) {
|
|
1656
1644
|
throw new Error(
|
|
@@ -1693,9 +1681,8 @@ function getCurrentEnvironment() {
|
|
|
1693
1681
|
return { group: "custom", name: process.env.VERCEL_ENV };
|
|
1694
1682
|
}
|
|
1695
1683
|
function getDomainForCurrentEnvironment(config, appName, opts = {}) {
|
|
1696
|
-
var _a;
|
|
1697
1684
|
const app = config.getApplication(appName);
|
|
1698
|
-
if (!opts.ignoreOverride &&
|
|
1685
|
+
if (!opts.ignoreOverride && app.overrides?.environment) {
|
|
1699
1686
|
return app.overrides.environment.toString();
|
|
1700
1687
|
}
|
|
1701
1688
|
const { group } = getCurrentEnvironment();
|
|
@@ -1740,11 +1727,10 @@ ${table}
|
|
|
1740
1727
|
}
|
|
1741
1728
|
}
|
|
1742
1729
|
function pathToRewrites(path5) {
|
|
1743
|
-
var _a;
|
|
1744
1730
|
const regex = /(?<base>^.+)\/:.+\*$/;
|
|
1745
1731
|
const match = regex.exec(path5);
|
|
1746
1732
|
const paths = [path5];
|
|
1747
|
-
if (
|
|
1733
|
+
if (match?.groups?.base) {
|
|
1748
1734
|
paths.unshift(match.groups.base);
|
|
1749
1735
|
}
|
|
1750
1736
|
return paths;
|
|
@@ -1874,7 +1860,6 @@ ${table}
|
|
|
1874
1860
|
}
|
|
1875
1861
|
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1876
1862
|
function transform5(args) {
|
|
1877
|
-
var _a, _b;
|
|
1878
1863
|
const { next, app, microfrontend } = args;
|
|
1879
1864
|
if (microfrontend instanceof MicrofrontendChildConfig) {
|
|
1880
1865
|
console.warn(
|
|
@@ -1893,7 +1878,7 @@ function transform5(args) {
|
|
|
1893
1878
|
// that are in the default zone.
|
|
1894
1879
|
defaultApplication
|
|
1895
1880
|
];
|
|
1896
|
-
const existingServerActionConfig =
|
|
1881
|
+
const existingServerActionConfig = next.experimental?.serverActions;
|
|
1897
1882
|
next.experimental = {
|
|
1898
1883
|
...next.experimental,
|
|
1899
1884
|
serverActions: {
|
|
@@ -1901,7 +1886,7 @@ function transform5(args) {
|
|
|
1901
1886
|
allowedOrigins: Array.from(
|
|
1902
1887
|
/* @__PURE__ */ new Set([
|
|
1903
1888
|
// existing
|
|
1904
|
-
...
|
|
1889
|
+
...existingServerActionConfig?.allowedOrigins ?? [],
|
|
1905
1890
|
// this deployments host
|
|
1906
1891
|
...process.env.VERCEL_URL ? [formatDomainForServerAction(process.env.VERCEL_URL)] : [],
|
|
1907
1892
|
// default application host
|
|
@@ -1916,7 +1901,7 @@ function transform5(args) {
|
|
|
1916
1901
|
)
|
|
1917
1902
|
}
|
|
1918
1903
|
};
|
|
1919
|
-
debugRewrites2(
|
|
1904
|
+
debugRewrites2(next.experimental.serverActions?.allowedOrigins);
|
|
1920
1905
|
return {
|
|
1921
1906
|
next
|
|
1922
1907
|
};
|
|
@@ -1998,7 +1983,10 @@ function setEnvironment({
|
|
|
1998
1983
|
NEXT_PUBLIC_MFE_CURRENT_APPLICATION: app.name,
|
|
1999
1984
|
NEXT_PUBLIC_MFE_CLIENT_CONFIG: JSON.stringify(
|
|
2000
1985
|
microfrontends.config.toClientConfig().serialize()
|
|
2001
|
-
)
|
|
1986
|
+
),
|
|
1987
|
+
...process.env.ROUTE_OBSERVABILITY_TO_DEFAULT_APP || !app.getAssetPrefix() ? {} : {
|
|
1988
|
+
NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH: `/${app.getAssetPrefix()}/_vercel`
|
|
1989
|
+
}
|
|
2002
1990
|
};
|
|
2003
1991
|
const serverEnvs = {
|
|
2004
1992
|
MFE_CURRENT_APPLICATION: app.name,
|
|
@@ -2016,13 +2004,13 @@ function typedEntries(obj) {
|
|
|
2016
2004
|
return Object.entries(obj);
|
|
2017
2005
|
}
|
|
2018
2006
|
function isProduction(opts) {
|
|
2019
|
-
if (opts
|
|
2007
|
+
if (opts?.isProduction) {
|
|
2020
2008
|
return opts.isProduction();
|
|
2021
2009
|
}
|
|
2022
2010
|
return process.env.VERCEL_ENV === "production";
|
|
2023
2011
|
}
|
|
2024
2012
|
function getApplicationContext(opts) {
|
|
2025
|
-
if (opts
|
|
2013
|
+
if (opts?.appName) {
|
|
2026
2014
|
return { name: opts.appName };
|
|
2027
2015
|
}
|
|
2028
2016
|
try {
|
|
@@ -2046,13 +2034,12 @@ function getApplicationContext(opts) {
|
|
|
2046
2034
|
}
|
|
2047
2035
|
}
|
|
2048
2036
|
function withMicrofrontends(nextConfig, opts) {
|
|
2049
|
-
|
|
2050
|
-
if (opts == null ? void 0 : opts.debug) {
|
|
2037
|
+
if (opts?.debug) {
|
|
2051
2038
|
process.env.MFE_DEBUG = "true";
|
|
2052
2039
|
}
|
|
2053
2040
|
const { name: fromApp } = getApplicationContext(opts);
|
|
2054
2041
|
const microfrontends = MicrofrontendsServer.infer({
|
|
2055
|
-
filePath: opts
|
|
2042
|
+
filePath: opts?.configPath,
|
|
2056
2043
|
meta: {
|
|
2057
2044
|
fromApp
|
|
2058
2045
|
}
|
|
@@ -2061,7 +2048,7 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2061
2048
|
setEnvironment({ app, microfrontends });
|
|
2062
2049
|
let next = { ...nextConfig };
|
|
2063
2050
|
for (const [key, transform7] of typedEntries(transforms)) {
|
|
2064
|
-
if (
|
|
2051
|
+
if (opts?.skipTransforms?.includes(key)) {
|
|
2065
2052
|
console.log(`Skipping ${key} transform`);
|
|
2066
2053
|
continue;
|
|
2067
2054
|
}
|
|
@@ -2077,12 +2064,10 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2077
2064
|
next = transformedConfig.next;
|
|
2078
2065
|
} catch (e) {
|
|
2079
2066
|
console.error("Error transforming next config", e);
|
|
2067
|
+
throw e;
|
|
2080
2068
|
}
|
|
2081
2069
|
}
|
|
2082
2070
|
displayLocalProxyInfo(microfrontends.config.getLocalProxyPort());
|
|
2083
|
-
if (isVercel()) {
|
|
2084
|
-
microfrontends.writeConfig();
|
|
2085
|
-
}
|
|
2086
2071
|
return next;
|
|
2087
2072
|
}
|
|
2088
2073
|
export {
|