@vercel/microfrontends 1.1.1-canary.6 → 1.2.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/dist/bin/cli.cjs +405 -204
- package/dist/config.cjs +25 -68
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +5 -5
- package/dist/config.js +25 -68
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +64 -193
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +64 -193
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +64 -193
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +64 -193
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +64 -193
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +3 -3
- package/dist/microfrontends/server.js +64 -193
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/next/config.cjs +69 -358
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +69 -358
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/middleware.cjs +25 -68
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +25 -68
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +123 -144
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +36 -5
- package/dist/next/testing.js +122 -143
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.d.ts +2 -2
- package/dist/{types-f1260e44.d.ts → types-b970b583.d.ts} +1 -1
- package/dist/{types-a4add5ab.d.ts → types-bee19651.d.ts} +11 -2
- package/dist/{types-54064641.d.ts → types-c9f15465.d.ts} +31 -85
- package/dist/utils/mfe-port.cjs +64 -193
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +64 -193
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +39 -125
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +39 -125
- package/dist/validation.js.map +1 -1
- package/package.json +2 -8
- package/schema/schema.json +45 -131
- package/dist/routing.cjs +0 -19
- package/dist/routing.cjs.map +0 -1
- package/dist/routing.d.ts +0 -26
- package/dist/routing.js +0 -1
- package/dist/routing.js.map +0 -1
package/dist/next/config.cjs
CHANGED
|
@@ -437,8 +437,7 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
437
437
|
if (isDefaultApp(app)) {
|
|
438
438
|
continue;
|
|
439
439
|
}
|
|
440
|
-
const
|
|
441
|
-
for (const pathMatch of childApp.routing) {
|
|
440
|
+
for (const pathMatch of app.routing) {
|
|
442
441
|
for (const path6 of pathMatch.paths) {
|
|
443
442
|
const maybeError = validatePathExpression(path6);
|
|
444
443
|
if (maybeError) {
|
|
@@ -586,64 +585,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
586
585
|
};
|
|
587
586
|
var validateDeprecatedFields = (config) => {
|
|
588
587
|
const errors = [];
|
|
589
|
-
if (config.options?.vercel) {
|
|
590
|
-
errors.push(
|
|
591
|
-
`Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
if (config.options?.localProxy) {
|
|
595
|
-
errors.push(
|
|
596
|
-
`Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
588
|
for (const [applicationId, application] of Object.entries(
|
|
600
589
|
config.applications
|
|
601
590
|
)) {
|
|
602
|
-
if (application.vercel) {
|
|
603
|
-
errors.push(
|
|
604
|
-
`Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
if (application.production) {
|
|
608
|
-
errors.push(
|
|
609
|
-
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
591
|
if (application.development?.localPort) {
|
|
613
592
|
errors.push(
|
|
614
593
|
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
615
594
|
);
|
|
616
595
|
}
|
|
617
|
-
if (application.
|
|
618
|
-
const fallback = application.development.fallback;
|
|
619
|
-
let asString = fallback.host;
|
|
620
|
-
if (fallback.protocol) {
|
|
621
|
-
asString = `${fallback.protocol}://${asString}`;
|
|
622
|
-
}
|
|
623
|
-
if (fallback.port) {
|
|
624
|
-
asString = `${asString}:${fallback.port}`;
|
|
625
|
-
}
|
|
626
|
-
errors.push(
|
|
627
|
-
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
631
|
-
const local = application.development.local;
|
|
632
|
-
let asString;
|
|
633
|
-
if (local.port && !local.protocol && !local.host) {
|
|
634
|
-
asString = String(local.port);
|
|
635
|
-
} else {
|
|
636
|
-
asString = local.host ?? "localhost";
|
|
637
|
-
if (local.protocol) {
|
|
638
|
-
asString = `${local.protocol}://${asString}`;
|
|
639
|
-
}
|
|
640
|
-
if (local.port) {
|
|
641
|
-
asString = `${asString}:${local.port}`;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
errors.push(
|
|
645
|
-
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
646
|
-
);
|
|
596
|
+
if (application.projectId) {
|
|
647
597
|
}
|
|
648
598
|
}
|
|
649
599
|
if (errors.length) {
|
|
@@ -798,6 +748,13 @@ var LocalHost = class extends Host {
|
|
|
798
748
|
}
|
|
799
749
|
};
|
|
800
750
|
|
|
751
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
|
|
752
|
+
function generateAutomationBypassEnvVarName({
|
|
753
|
+
name
|
|
754
|
+
}) {
|
|
755
|
+
return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
756
|
+
}
|
|
757
|
+
|
|
801
758
|
// src/config/microfrontends-config/isomorphic/application.ts
|
|
802
759
|
var Application = class {
|
|
803
760
|
constructor(name, {
|
|
@@ -816,10 +773,8 @@ var Application = class {
|
|
|
816
773
|
};
|
|
817
774
|
if (app.development?.fallback) {
|
|
818
775
|
this.fallback = new Host(app.development.fallback);
|
|
819
|
-
} else if (app.production) {
|
|
820
|
-
this.fallback = new Host(app.production);
|
|
821
776
|
}
|
|
822
|
-
this.projectId = app.projectId
|
|
777
|
+
this.projectId = app.projectId;
|
|
823
778
|
this.packageName = app.packageName;
|
|
824
779
|
this.overrides = overrides?.environment ? {
|
|
825
780
|
environment: new Host(overrides.environment)
|
|
@@ -833,6 +788,9 @@ var Application = class {
|
|
|
833
788
|
getAssetPrefix() {
|
|
834
789
|
return generateAssetPrefixFromName({ name: this.name });
|
|
835
790
|
}
|
|
791
|
+
getAutomationBypassEnvVarName() {
|
|
792
|
+
return generateAutomationBypassEnvVarName({ name: this.name });
|
|
793
|
+
}
|
|
836
794
|
serialize() {
|
|
837
795
|
return this.serialized;
|
|
838
796
|
}
|
|
@@ -848,16 +806,7 @@ var DefaultApplication = class extends Application {
|
|
|
848
806
|
isDefault: true
|
|
849
807
|
});
|
|
850
808
|
this.default = true;
|
|
851
|
-
|
|
852
|
-
if (fallbackHost === void 0) {
|
|
853
|
-
throw new Error(
|
|
854
|
-
"`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
|
|
855
|
-
);
|
|
856
|
-
}
|
|
857
|
-
this.fallback = new Host(fallbackHost);
|
|
858
|
-
if (app.production) {
|
|
859
|
-
this.production = new Host(app.production);
|
|
860
|
-
}
|
|
809
|
+
this.fallback = new Host(app.development.fallback);
|
|
861
810
|
}
|
|
862
811
|
getAssetPrefix() {
|
|
863
812
|
return "";
|
|
@@ -894,7 +843,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
894
843
|
}) {
|
|
895
844
|
this.childApplications = {};
|
|
896
845
|
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
897
|
-
const disableOverrides = config.options?.disableOverrides ??
|
|
846
|
+
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
898
847
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
899
848
|
let defaultApplication;
|
|
900
849
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
@@ -947,7 +896,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
947
896
|
});
|
|
948
897
|
}
|
|
949
898
|
isOverridesDisabled() {
|
|
950
|
-
return this.options?.
|
|
899
|
+
return this.options?.disableOverrides ?? false;
|
|
951
900
|
}
|
|
952
901
|
getConfig() {
|
|
953
902
|
return this.config;
|
|
@@ -985,6 +934,14 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
985
934
|
}
|
|
986
935
|
return app;
|
|
987
936
|
}
|
|
937
|
+
hasApplication(name) {
|
|
938
|
+
try {
|
|
939
|
+
this.getApplication(name);
|
|
940
|
+
return true;
|
|
941
|
+
} catch {
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
988
945
|
getApplicationByProjectId(projectId) {
|
|
989
946
|
if (this.defaultApplication.projectId === projectId) {
|
|
990
947
|
return this.defaultApplication;
|
|
@@ -1003,7 +960,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
1003
960
|
* Returns the configured port for the local proxy
|
|
1004
961
|
*/
|
|
1005
962
|
getLocalProxyPort() {
|
|
1006
|
-
return this.config.options?.localProxyPort ??
|
|
963
|
+
return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
1007
964
|
}
|
|
1008
965
|
/**
|
|
1009
966
|
* Serializes the class back to the Schema type.
|
|
@@ -1114,20 +1071,10 @@ var schema_default = {
|
|
|
1114
1071
|
Options: {
|
|
1115
1072
|
type: "object",
|
|
1116
1073
|
properties: {
|
|
1117
|
-
vercel: {
|
|
1118
|
-
$ref: "#/definitions/VercelOptions",
|
|
1119
|
-
description: "Microfrontends wide options for Vercel.",
|
|
1120
|
-
deprecated: "This is being replaced by the `disableOverrides` field below."
|
|
1121
|
-
},
|
|
1122
1074
|
disableOverrides: {
|
|
1123
1075
|
type: "boolean",
|
|
1124
1076
|
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."
|
|
1125
1077
|
},
|
|
1126
|
-
localProxy: {
|
|
1127
|
-
$ref: "#/definitions/LocalProxyOptions",
|
|
1128
|
-
description: "Options for local proxy.",
|
|
1129
|
-
deprecated: "This is being replaced by the `localProxyPort` field below."
|
|
1130
|
-
},
|
|
1131
1078
|
localProxyPort: {
|
|
1132
1079
|
type: "number",
|
|
1133
1080
|
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
@@ -1135,26 +1082,6 @@ var schema_default = {
|
|
|
1135
1082
|
},
|
|
1136
1083
|
additionalProperties: false
|
|
1137
1084
|
},
|
|
1138
|
-
VercelOptions: {
|
|
1139
|
-
type: "object",
|
|
1140
|
-
properties: {
|
|
1141
|
-
disableOverrides: {
|
|
1142
|
-
type: "boolean",
|
|
1143
|
-
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."
|
|
1144
|
-
}
|
|
1145
|
-
},
|
|
1146
|
-
additionalProperties: false
|
|
1147
|
-
},
|
|
1148
|
-
LocalProxyOptions: {
|
|
1149
|
-
type: "object",
|
|
1150
|
-
properties: {
|
|
1151
|
-
port: {
|
|
1152
|
-
type: "number",
|
|
1153
|
-
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
1154
|
-
}
|
|
1155
|
-
},
|
|
1156
|
-
additionalProperties: false
|
|
1157
|
-
},
|
|
1158
1085
|
ApplicationRouting: {
|
|
1159
1086
|
type: "object",
|
|
1160
1087
|
additionalProperties: {
|
|
@@ -1177,141 +1104,62 @@ var schema_default = {
|
|
|
1177
1104
|
DefaultApplication: {
|
|
1178
1105
|
type: "object",
|
|
1179
1106
|
properties: {
|
|
1180
|
-
vercel: {
|
|
1181
|
-
$ref: "#/definitions/Vercel",
|
|
1182
|
-
deprecated: "This is being replaced by the `projectId` field below."
|
|
1183
|
-
},
|
|
1184
1107
|
projectId: {
|
|
1185
1108
|
type: "string",
|
|
1186
1109
|
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1187
|
-
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1110
|
+
deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
|
|
1188
1111
|
},
|
|
1189
1112
|
packageName: {
|
|
1190
1113
|
type: "string",
|
|
1191
1114
|
description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
|
|
1192
1115
|
},
|
|
1193
|
-
production: {
|
|
1194
|
-
$ref: "#/definitions/HostConfig",
|
|
1195
|
-
deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
|
|
1196
|
-
},
|
|
1197
1116
|
development: {
|
|
1198
|
-
$ref: "#/definitions/
|
|
1199
|
-
|
|
1200
|
-
},
|
|
1201
|
-
additionalProperties: false
|
|
1202
|
-
},
|
|
1203
|
-
Vercel: {
|
|
1204
|
-
type: "object",
|
|
1205
|
-
properties: {
|
|
1206
|
-
projectId: {
|
|
1207
|
-
type: "string",
|
|
1208
|
-
description: "Vercel project ID"
|
|
1117
|
+
$ref: "#/definitions/DefaultDevelopment",
|
|
1118
|
+
description: "Development configuration for the default application."
|
|
1209
1119
|
}
|
|
1210
1120
|
},
|
|
1211
|
-
required: ["
|
|
1121
|
+
required: ["development"],
|
|
1212
1122
|
additionalProperties: false
|
|
1213
1123
|
},
|
|
1214
|
-
|
|
1215
|
-
type: "object",
|
|
1216
|
-
properties: {
|
|
1217
|
-
protocol: {
|
|
1218
|
-
type: "string",
|
|
1219
|
-
enum: ["http", "https"],
|
|
1220
|
-
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1221
|
-
},
|
|
1222
|
-
host: {
|
|
1223
|
-
type: "string",
|
|
1224
|
-
description: "The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`)."
|
|
1225
|
-
},
|
|
1226
|
-
port: {
|
|
1227
|
-
type: "number",
|
|
1228
|
-
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1229
|
-
}
|
|
1230
|
-
},
|
|
1231
|
-
required: ["host"],
|
|
1232
|
-
additionalProperties: false
|
|
1233
|
-
},
|
|
1234
|
-
Development: {
|
|
1124
|
+
DefaultDevelopment: {
|
|
1235
1125
|
type: "object",
|
|
1236
1126
|
properties: {
|
|
1237
1127
|
local: {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
type: "number"
|
|
1241
|
-
},
|
|
1242
|
-
{
|
|
1243
|
-
type: "string"
|
|
1244
|
-
},
|
|
1245
|
-
{
|
|
1246
|
-
$ref: "#/definitions/LocalHostConfig"
|
|
1247
|
-
}
|
|
1248
|
-
],
|
|
1249
|
-
description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080\n\nPassing a LocalHostConfig is deprecated and will go away soon, please pass a number or string."
|
|
1128
|
+
type: ["number", "string"],
|
|
1129
|
+
description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
|
|
1250
1130
|
},
|
|
1251
1131
|
localPort: {
|
|
1252
1132
|
type: "number",
|
|
1253
1133
|
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. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
|
|
1254
1134
|
deprecated: "Please set the port with the 'local' field instead."
|
|
1255
1135
|
},
|
|
1256
|
-
fallback: {
|
|
1257
|
-
anyOf: [
|
|
1258
|
-
{
|
|
1259
|
-
$ref: "#/definitions/HostConfig"
|
|
1260
|
-
},
|
|
1261
|
-
{
|
|
1262
|
-
type: "string"
|
|
1263
|
-
}
|
|
1264
|
-
],
|
|
1265
|
-
description: "Fallback for local development, could point 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.\n\nPassing a HostConfig is deprecated and will go away soon, please pass a string."
|
|
1266
|
-
},
|
|
1267
1136
|
task: {
|
|
1268
1137
|
type: "string",
|
|
1269
1138
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
1270
|
-
}
|
|
1271
|
-
},
|
|
1272
|
-
additionalProperties: false
|
|
1273
|
-
},
|
|
1274
|
-
LocalHostConfig: {
|
|
1275
|
-
type: "object",
|
|
1276
|
-
additionalProperties: false,
|
|
1277
|
-
properties: {
|
|
1278
|
-
host: {
|
|
1279
|
-
type: "string",
|
|
1280
|
-
description: "The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`)."
|
|
1281
1139
|
},
|
|
1282
|
-
|
|
1140
|
+
fallback: {
|
|
1283
1141
|
type: "string",
|
|
1284
|
-
|
|
1285
|
-
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1286
|
-
},
|
|
1287
|
-
port: {
|
|
1288
|
-
type: "number",
|
|
1289
|
-
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1142
|
+
description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\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."
|
|
1290
1143
|
}
|
|
1291
|
-
}
|
|
1144
|
+
},
|
|
1145
|
+
required: ["fallback"],
|
|
1146
|
+
additionalProperties: false
|
|
1292
1147
|
},
|
|
1293
1148
|
ChildApplication: {
|
|
1294
1149
|
type: "object",
|
|
1295
1150
|
properties: {
|
|
1296
|
-
vercel: {
|
|
1297
|
-
$ref: "#/definitions/Vercel",
|
|
1298
|
-
deprecated: "This is being replaced by the `projectId` field below."
|
|
1299
|
-
},
|
|
1300
1151
|
projectId: {
|
|
1301
1152
|
type: "string",
|
|
1302
1153
|
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1303
|
-
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1154
|
+
deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
|
|
1304
1155
|
},
|
|
1305
1156
|
packageName: {
|
|
1306
1157
|
type: "string",
|
|
1307
1158
|
description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
|
|
1308
1159
|
},
|
|
1309
|
-
production: {
|
|
1310
|
-
$ref: "#/definitions/HostConfig",
|
|
1311
|
-
deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
|
|
1312
|
-
},
|
|
1313
1160
|
development: {
|
|
1314
|
-
$ref: "#/definitions/
|
|
1161
|
+
$ref: "#/definitions/ChildDevelopment",
|
|
1162
|
+
description: "Development configuration for the child application."
|
|
1315
1163
|
},
|
|
1316
1164
|
routing: {
|
|
1317
1165
|
$ref: "#/definitions/Routing",
|
|
@@ -1321,6 +1169,29 @@ var schema_default = {
|
|
|
1321
1169
|
required: ["routing"],
|
|
1322
1170
|
additionalProperties: false
|
|
1323
1171
|
},
|
|
1172
|
+
ChildDevelopment: {
|
|
1173
|
+
type: "object",
|
|
1174
|
+
properties: {
|
|
1175
|
+
local: {
|
|
1176
|
+
type: ["number", "string"],
|
|
1177
|
+
description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
|
|
1178
|
+
},
|
|
1179
|
+
localPort: {
|
|
1180
|
+
type: "number",
|
|
1181
|
+
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. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
|
|
1182
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1183
|
+
},
|
|
1184
|
+
task: {
|
|
1185
|
+
type: "string",
|
|
1186
|
+
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
1187
|
+
},
|
|
1188
|
+
fallback: {
|
|
1189
|
+
type: "string",
|
|
1190
|
+
description: "Fallback for local development, could point to any environment. This is optional for child apps. If not provided, the fallback of the default app will be used.\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."
|
|
1191
|
+
}
|
|
1192
|
+
},
|
|
1193
|
+
additionalProperties: false
|
|
1194
|
+
},
|
|
1324
1195
|
Routing: {
|
|
1325
1196
|
type: "array",
|
|
1326
1197
|
items: {
|
|
@@ -1406,7 +1277,7 @@ function formatAjvErrors(errors) {
|
|
|
1406
1277
|
}
|
|
1407
1278
|
function validateSchema(configString) {
|
|
1408
1279
|
const parsedConfig = (0, import_jsonc_parser3.parse)(configString);
|
|
1409
|
-
const ajv = new import_ajv.Ajv();
|
|
1280
|
+
const ajv = new import_ajv.Ajv({ allowUnionTypes: true });
|
|
1410
1281
|
const validate = ajv.compile(SCHEMA);
|
|
1411
1282
|
const isValid = validate(parsedConfig);
|
|
1412
1283
|
if (!isValid) {
|
|
@@ -1700,88 +1571,6 @@ ${indent} - Automatically redirecting all requests to local microfrontends proxy
|
|
|
1700
1571
|
return { next };
|
|
1701
1572
|
}
|
|
1702
1573
|
|
|
1703
|
-
// src/routing/get-domain-from-environment.ts
|
|
1704
|
-
function getDomainFromEnvironment({
|
|
1705
|
-
app,
|
|
1706
|
-
target
|
|
1707
|
-
}) {
|
|
1708
|
-
const mfeProjects = JSON.parse(
|
|
1709
|
-
process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "[]"
|
|
1710
|
-
);
|
|
1711
|
-
if (mfeProjects.length === 0) {
|
|
1712
|
-
throw new Error("Missing related microfrontends project information");
|
|
1713
|
-
}
|
|
1714
|
-
const vercelProject = mfeProjects.find(
|
|
1715
|
-
(p) => p.project.name === app.name || p.project.id === app.projectId
|
|
1716
|
-
);
|
|
1717
|
-
if (!vercelProject) {
|
|
1718
|
-
throw new Error(
|
|
1719
|
-
`Could not find the Vercel project for application "${app.name}". If the name does not match the Vercel project name, set the \`projectId\` field in the application config.`
|
|
1720
|
-
);
|
|
1721
|
-
}
|
|
1722
|
-
const domain = target === "preview" && vercelProject.preview.branch ? vercelProject.preview.branch : vercelProject.production.alias ?? vercelProject.production.url;
|
|
1723
|
-
if (!domain) {
|
|
1724
|
-
throw new Error(
|
|
1725
|
-
`Missing domain for target "${target}" in application "${app.name}"`
|
|
1726
|
-
);
|
|
1727
|
-
}
|
|
1728
|
-
return domain.startsWith("https://") ? domain : `https://${domain}`;
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
// src/routing/get-domain-for-current-environment.ts
|
|
1732
|
-
function debugDomains(zone, env, domain) {
|
|
1733
|
-
if (process.env.MFE_DEBUG === "true") {
|
|
1734
|
-
const indent = " ".repeat(4);
|
|
1735
|
-
const header = "domains (zone (env) -> domain)";
|
|
1736
|
-
const separator = "\u23AF".repeat(header.length);
|
|
1737
|
-
const line = `${indent} 1. ${zone} (${env}) -> ${domain}`;
|
|
1738
|
-
console.log(`${indent}${header}
|
|
1739
|
-
${indent}${separator}
|
|
1740
|
-
${line}
|
|
1741
|
-
`);
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
function getCurrentEnvironment() {
|
|
1745
|
-
const isDevelopment = !process.env.VERCEL_ENV || process.env.VERCEL_ENV === "development";
|
|
1746
|
-
const isPreview = process.env.VERCEL_ENV === "preview";
|
|
1747
|
-
const isProduction2 = process.env.VERCEL_ENV === "production";
|
|
1748
|
-
if (isDevelopment) {
|
|
1749
|
-
return { group: "development" };
|
|
1750
|
-
}
|
|
1751
|
-
if (isProduction2) {
|
|
1752
|
-
return { group: "production" };
|
|
1753
|
-
}
|
|
1754
|
-
if (isPreview) {
|
|
1755
|
-
return { group: "preview" };
|
|
1756
|
-
}
|
|
1757
|
-
return { group: "custom", name: process.env.VERCEL_ENV };
|
|
1758
|
-
}
|
|
1759
|
-
function getDomainForCurrentEnvironment(config, appName, opts = {}) {
|
|
1760
|
-
const app = config.getApplication(appName);
|
|
1761
|
-
if (!opts.ignoreOverride && app.overrides?.environment) {
|
|
1762
|
-
return app.overrides.environment.toString();
|
|
1763
|
-
}
|
|
1764
|
-
const { group } = getCurrentEnvironment();
|
|
1765
|
-
const fallbackHost = config.getDefaultApplication().fallback.toString();
|
|
1766
|
-
switch (group) {
|
|
1767
|
-
case "development": {
|
|
1768
|
-
const domain = ["test", "development"].includes(process.env.NODE_ENV) ? app.development.local.toString() : fallbackHost;
|
|
1769
|
-
debugDomains(appName, "development", domain);
|
|
1770
|
-
return domain;
|
|
1771
|
-
}
|
|
1772
|
-
case "preview": {
|
|
1773
|
-
return getDomainFromEnvironment({ app, target: "preview" });
|
|
1774
|
-
}
|
|
1775
|
-
case "production": {
|
|
1776
|
-
return getDomainFromEnvironment({ app, target: "production" });
|
|
1777
|
-
}
|
|
1778
|
-
case "custom":
|
|
1779
|
-
throw new Error(
|
|
1780
|
-
"Custom environments are not supported in getDomainForCurrentEnvironment"
|
|
1781
|
-
);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
1574
|
// src/next/config/transforms/rewrites.ts
|
|
1786
1575
|
function debugRewrites(rewrites) {
|
|
1787
1576
|
if (process.env.MFE_DEBUG) {
|
|
@@ -1815,7 +1604,7 @@ function rewritesMapToArr(rewrites) {
|
|
|
1815
1604
|
});
|
|
1816
1605
|
}
|
|
1817
1606
|
function transform5(args) {
|
|
1818
|
-
const { app,
|
|
1607
|
+
const { app, next } = args;
|
|
1819
1608
|
const buildBeforeFiles = () => {
|
|
1820
1609
|
const rewrites = /* @__PURE__ */ new Map();
|
|
1821
1610
|
if (!app.isDefault()) {
|
|
@@ -1834,15 +1623,6 @@ function transform5(args) {
|
|
|
1834
1623
|
pathname: "/_vercel/:path*"
|
|
1835
1624
|
}
|
|
1836
1625
|
});
|
|
1837
|
-
} else if (opts?.supportPagesRouter) {
|
|
1838
|
-
for (const child of microfrontend.getChildApplications()) {
|
|
1839
|
-
rewrites.set(`/_next/data/${child.getAssetPrefix()}-:buildId/:path*`, {
|
|
1840
|
-
destination: {
|
|
1841
|
-
domain: getDomainForCurrentEnvironment(microfrontend, child.name),
|
|
1842
|
-
pathname: `/_next/data/${child.getAssetPrefix()}-:buildId/:path*`
|
|
1843
|
-
}
|
|
1844
|
-
});
|
|
1845
|
-
}
|
|
1846
1626
|
}
|
|
1847
1627
|
return rewritesMapToArr(rewrites);
|
|
1848
1628
|
};
|
|
@@ -1878,76 +1658,8 @@ function transform5(args) {
|
|
|
1878
1658
|
};
|
|
1879
1659
|
}
|
|
1880
1660
|
|
|
1881
|
-
// src/next/config/transforms/server-actions.ts
|
|
1882
|
-
function debugRewrites2(allowedOrigins) {
|
|
1883
|
-
if (process.env.MFE_DEBUG === "true" && allowedOrigins) {
|
|
1884
|
-
const indent = " ".repeat(4);
|
|
1885
|
-
const header = "server actions allowed origins";
|
|
1886
|
-
const separator = "\u23AF".repeat(header.length);
|
|
1887
|
-
const maxSourceLength = Math.max(
|
|
1888
|
-
...allowedOrigins.map((key) => key.length)
|
|
1889
|
-
);
|
|
1890
|
-
const table = allowedOrigins.map((origin, idx) => {
|
|
1891
|
-
const paddedSource = origin.padEnd(maxSourceLength);
|
|
1892
|
-
return `${indent} ${idx + 1}. ${paddedSource}`;
|
|
1893
|
-
}).join("\n");
|
|
1894
|
-
console.log(`${indent}${header}
|
|
1895
|
-
${indent}${separator}
|
|
1896
|
-
${table}
|
|
1897
|
-
`);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1901
|
-
function transform6(args) {
|
|
1902
|
-
const { next, app, microfrontend } = args;
|
|
1903
|
-
const defaultApplication = microfrontend.getDefaultApplication();
|
|
1904
|
-
const appsToAllow = [
|
|
1905
|
-
// this zone - this is included by default unless allowedOrigins is overridden (which we are)
|
|
1906
|
-
// so we re-add it here.
|
|
1907
|
-
app,
|
|
1908
|
-
// this is the default zone for the microfrontend. Allow child zones to call server actions
|
|
1909
|
-
// that are in the default zone.
|
|
1910
|
-
defaultApplication
|
|
1911
|
-
];
|
|
1912
|
-
const existingServerActionConfig = next.experimental?.serverActions;
|
|
1913
|
-
next.experimental = {
|
|
1914
|
-
...next.experimental,
|
|
1915
|
-
serverActions: {
|
|
1916
|
-
...existingServerActionConfig,
|
|
1917
|
-
allowedOrigins: Array.from(
|
|
1918
|
-
/* @__PURE__ */ new Set([
|
|
1919
|
-
// existing
|
|
1920
|
-
...existingServerActionConfig?.allowedOrigins ?? [],
|
|
1921
|
-
// this deployments host
|
|
1922
|
-
...process.env.VERCEL_URL ? [formatDomainForServerAction(process.env.VERCEL_URL)] : [],
|
|
1923
|
-
// default application host
|
|
1924
|
-
...process.env.VERCEL_MICROFRONTENDS_PROJECTS ? [
|
|
1925
|
-
formatDomainForServerAction(
|
|
1926
|
-
getDomainFromEnvironment({
|
|
1927
|
-
app: defaultApplication,
|
|
1928
|
-
target: "production"
|
|
1929
|
-
})
|
|
1930
|
-
)
|
|
1931
|
-
] : [],
|
|
1932
|
-
formatDomainForServerAction(defaultApplication.fallback.toString()),
|
|
1933
|
-
// environment specific microfrontend hosts
|
|
1934
|
-
...appsToAllow.flatMap((a) => [
|
|
1935
|
-
formatDomainForServerAction(
|
|
1936
|
-
getDomainForCurrentEnvironment(microfrontend, a.name)
|
|
1937
|
-
)
|
|
1938
|
-
])
|
|
1939
|
-
])
|
|
1940
|
-
)
|
|
1941
|
-
}
|
|
1942
|
-
};
|
|
1943
|
-
debugRewrites2(next.experimental.serverActions?.allowedOrigins);
|
|
1944
|
-
return {
|
|
1945
|
-
next
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
1661
|
// src/next/config/transforms/webpack.ts
|
|
1950
|
-
function
|
|
1662
|
+
function transform6(args) {
|
|
1951
1663
|
const { next, microfrontend, opts } = args;
|
|
1952
1664
|
const configWithWebpack = {
|
|
1953
1665
|
...next,
|
|
@@ -2026,8 +1738,7 @@ var transforms = {
|
|
|
2026
1738
|
draftMode: transform3,
|
|
2027
1739
|
redirects: transform4,
|
|
2028
1740
|
rewrites: transform5,
|
|
2029
|
-
|
|
2030
|
-
webpack: transform7
|
|
1741
|
+
webpack: transform6
|
|
2031
1742
|
};
|
|
2032
1743
|
|
|
2033
1744
|
// src/next/config/env.ts
|
|
@@ -2092,13 +1803,13 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2092
1803
|
const app = microfrontends.config.getApplication(fromApp);
|
|
2093
1804
|
setEnvironment({ app, microfrontends });
|
|
2094
1805
|
let next = { ...nextConfig };
|
|
2095
|
-
for (const [key,
|
|
1806
|
+
for (const [key, transform7] of typedEntries(transforms)) {
|
|
2096
1807
|
if (opts?.skipTransforms?.includes(key)) {
|
|
2097
1808
|
console.log(`Skipping ${key} transform`);
|
|
2098
1809
|
continue;
|
|
2099
1810
|
}
|
|
2100
1811
|
try {
|
|
2101
|
-
const transformedConfig =
|
|
1812
|
+
const transformedConfig = transform7({
|
|
2102
1813
|
app,
|
|
2103
1814
|
next,
|
|
2104
1815
|
microfrontend: microfrontends.config,
|