@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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextConfig } from 'next';
|
|
2
2
|
|
|
3
|
-
type TransformKeys = 'assetPrefix' | 'buildId' | 'draftMode' | 'redirects' | 'rewrites' | '
|
|
3
|
+
type TransformKeys = 'assetPrefix' | 'buildId' | 'draftMode' | 'redirects' | 'rewrites' | 'webpack';
|
|
4
4
|
|
|
5
5
|
interface WithMicrofrontendsOptions {
|
|
6
6
|
/**
|
package/dist/next/config.js
CHANGED
|
@@ -401,8 +401,7 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
401
401
|
if (isDefaultApp(app)) {
|
|
402
402
|
continue;
|
|
403
403
|
}
|
|
404
|
-
const
|
|
405
|
-
for (const pathMatch of childApp.routing) {
|
|
404
|
+
for (const pathMatch of app.routing) {
|
|
406
405
|
for (const path6 of pathMatch.paths) {
|
|
407
406
|
const maybeError = validatePathExpression(path6);
|
|
408
407
|
if (maybeError) {
|
|
@@ -550,64 +549,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
550
549
|
};
|
|
551
550
|
var validateDeprecatedFields = (config) => {
|
|
552
551
|
const errors = [];
|
|
553
|
-
if (config.options?.vercel) {
|
|
554
|
-
errors.push(
|
|
555
|
-
`Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
|
|
556
|
-
);
|
|
557
|
-
}
|
|
558
|
-
if (config.options?.localProxy) {
|
|
559
|
-
errors.push(
|
|
560
|
-
`Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
552
|
for (const [applicationId, application] of Object.entries(
|
|
564
553
|
config.applications
|
|
565
554
|
)) {
|
|
566
|
-
if (application.vercel) {
|
|
567
|
-
errors.push(
|
|
568
|
-
`Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
if (application.production) {
|
|
572
|
-
errors.push(
|
|
573
|
-
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
574
|
-
);
|
|
575
|
-
}
|
|
576
555
|
if (application.development?.localPort) {
|
|
577
556
|
errors.push(
|
|
578
557
|
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
579
558
|
);
|
|
580
559
|
}
|
|
581
|
-
if (application.
|
|
582
|
-
const fallback = application.development.fallback;
|
|
583
|
-
let asString = fallback.host;
|
|
584
|
-
if (fallback.protocol) {
|
|
585
|
-
asString = `${fallback.protocol}://${asString}`;
|
|
586
|
-
}
|
|
587
|
-
if (fallback.port) {
|
|
588
|
-
asString = `${asString}:${fallback.port}`;
|
|
589
|
-
}
|
|
590
|
-
errors.push(
|
|
591
|
-
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
595
|
-
const local = application.development.local;
|
|
596
|
-
let asString;
|
|
597
|
-
if (local.port && !local.protocol && !local.host) {
|
|
598
|
-
asString = String(local.port);
|
|
599
|
-
} else {
|
|
600
|
-
asString = local.host ?? "localhost";
|
|
601
|
-
if (local.protocol) {
|
|
602
|
-
asString = `${local.protocol}://${asString}`;
|
|
603
|
-
}
|
|
604
|
-
if (local.port) {
|
|
605
|
-
asString = `${asString}:${local.port}`;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
errors.push(
|
|
609
|
-
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
610
|
-
);
|
|
560
|
+
if (application.projectId) {
|
|
611
561
|
}
|
|
612
562
|
}
|
|
613
563
|
if (errors.length) {
|
|
@@ -762,6 +712,13 @@ var LocalHost = class extends Host {
|
|
|
762
712
|
}
|
|
763
713
|
};
|
|
764
714
|
|
|
715
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
|
|
716
|
+
function generateAutomationBypassEnvVarName({
|
|
717
|
+
name
|
|
718
|
+
}) {
|
|
719
|
+
return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
720
|
+
}
|
|
721
|
+
|
|
765
722
|
// src/config/microfrontends-config/isomorphic/application.ts
|
|
766
723
|
var Application = class {
|
|
767
724
|
constructor(name, {
|
|
@@ -780,10 +737,8 @@ var Application = class {
|
|
|
780
737
|
};
|
|
781
738
|
if (app.development?.fallback) {
|
|
782
739
|
this.fallback = new Host(app.development.fallback);
|
|
783
|
-
} else if (app.production) {
|
|
784
|
-
this.fallback = new Host(app.production);
|
|
785
740
|
}
|
|
786
|
-
this.projectId = app.projectId
|
|
741
|
+
this.projectId = app.projectId;
|
|
787
742
|
this.packageName = app.packageName;
|
|
788
743
|
this.overrides = overrides?.environment ? {
|
|
789
744
|
environment: new Host(overrides.environment)
|
|
@@ -797,6 +752,9 @@ var Application = class {
|
|
|
797
752
|
getAssetPrefix() {
|
|
798
753
|
return generateAssetPrefixFromName({ name: this.name });
|
|
799
754
|
}
|
|
755
|
+
getAutomationBypassEnvVarName() {
|
|
756
|
+
return generateAutomationBypassEnvVarName({ name: this.name });
|
|
757
|
+
}
|
|
800
758
|
serialize() {
|
|
801
759
|
return this.serialized;
|
|
802
760
|
}
|
|
@@ -812,16 +770,7 @@ var DefaultApplication = class extends Application {
|
|
|
812
770
|
isDefault: true
|
|
813
771
|
});
|
|
814
772
|
this.default = true;
|
|
815
|
-
|
|
816
|
-
if (fallbackHost === void 0) {
|
|
817
|
-
throw new Error(
|
|
818
|
-
"`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
|
|
819
|
-
);
|
|
820
|
-
}
|
|
821
|
-
this.fallback = new Host(fallbackHost);
|
|
822
|
-
if (app.production) {
|
|
823
|
-
this.production = new Host(app.production);
|
|
824
|
-
}
|
|
773
|
+
this.fallback = new Host(app.development.fallback);
|
|
825
774
|
}
|
|
826
775
|
getAssetPrefix() {
|
|
827
776
|
return "";
|
|
@@ -858,7 +807,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
858
807
|
}) {
|
|
859
808
|
this.childApplications = {};
|
|
860
809
|
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
861
|
-
const disableOverrides = config.options?.disableOverrides ??
|
|
810
|
+
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
862
811
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
863
812
|
let defaultApplication;
|
|
864
813
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
@@ -911,7 +860,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
911
860
|
});
|
|
912
861
|
}
|
|
913
862
|
isOverridesDisabled() {
|
|
914
|
-
return this.options?.
|
|
863
|
+
return this.options?.disableOverrides ?? false;
|
|
915
864
|
}
|
|
916
865
|
getConfig() {
|
|
917
866
|
return this.config;
|
|
@@ -949,6 +898,14 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
949
898
|
}
|
|
950
899
|
return app;
|
|
951
900
|
}
|
|
901
|
+
hasApplication(name) {
|
|
902
|
+
try {
|
|
903
|
+
this.getApplication(name);
|
|
904
|
+
return true;
|
|
905
|
+
} catch {
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
952
909
|
getApplicationByProjectId(projectId) {
|
|
953
910
|
if (this.defaultApplication.projectId === projectId) {
|
|
954
911
|
return this.defaultApplication;
|
|
@@ -967,7 +924,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
967
924
|
* Returns the configured port for the local proxy
|
|
968
925
|
*/
|
|
969
926
|
getLocalProxyPort() {
|
|
970
|
-
return this.config.options?.localProxyPort ??
|
|
927
|
+
return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
971
928
|
}
|
|
972
929
|
/**
|
|
973
930
|
* Serializes the class back to the Schema type.
|
|
@@ -1078,20 +1035,10 @@ var schema_default = {
|
|
|
1078
1035
|
Options: {
|
|
1079
1036
|
type: "object",
|
|
1080
1037
|
properties: {
|
|
1081
|
-
vercel: {
|
|
1082
|
-
$ref: "#/definitions/VercelOptions",
|
|
1083
|
-
description: "Microfrontends wide options for Vercel.",
|
|
1084
|
-
deprecated: "This is being replaced by the `disableOverrides` field below."
|
|
1085
|
-
},
|
|
1086
1038
|
disableOverrides: {
|
|
1087
1039
|
type: "boolean",
|
|
1088
1040
|
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."
|
|
1089
1041
|
},
|
|
1090
|
-
localProxy: {
|
|
1091
|
-
$ref: "#/definitions/LocalProxyOptions",
|
|
1092
|
-
description: "Options for local proxy.",
|
|
1093
|
-
deprecated: "This is being replaced by the `localProxyPort` field below."
|
|
1094
|
-
},
|
|
1095
1042
|
localProxyPort: {
|
|
1096
1043
|
type: "number",
|
|
1097
1044
|
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
@@ -1099,26 +1046,6 @@ var schema_default = {
|
|
|
1099
1046
|
},
|
|
1100
1047
|
additionalProperties: false
|
|
1101
1048
|
},
|
|
1102
|
-
VercelOptions: {
|
|
1103
|
-
type: "object",
|
|
1104
|
-
properties: {
|
|
1105
|
-
disableOverrides: {
|
|
1106
|
-
type: "boolean",
|
|
1107
|
-
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."
|
|
1108
|
-
}
|
|
1109
|
-
},
|
|
1110
|
-
additionalProperties: false
|
|
1111
|
-
},
|
|
1112
|
-
LocalProxyOptions: {
|
|
1113
|
-
type: "object",
|
|
1114
|
-
properties: {
|
|
1115
|
-
port: {
|
|
1116
|
-
type: "number",
|
|
1117
|
-
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
1118
|
-
}
|
|
1119
|
-
},
|
|
1120
|
-
additionalProperties: false
|
|
1121
|
-
},
|
|
1122
1049
|
ApplicationRouting: {
|
|
1123
1050
|
type: "object",
|
|
1124
1051
|
additionalProperties: {
|
|
@@ -1141,141 +1068,62 @@ var schema_default = {
|
|
|
1141
1068
|
DefaultApplication: {
|
|
1142
1069
|
type: "object",
|
|
1143
1070
|
properties: {
|
|
1144
|
-
vercel: {
|
|
1145
|
-
$ref: "#/definitions/Vercel",
|
|
1146
|
-
deprecated: "This is being replaced by the `projectId` field below."
|
|
1147
|
-
},
|
|
1148
1071
|
projectId: {
|
|
1149
1072
|
type: "string",
|
|
1150
1073
|
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1151
|
-
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1074
|
+
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)."
|
|
1152
1075
|
},
|
|
1153
1076
|
packageName: {
|
|
1154
1077
|
type: "string",
|
|
1155
1078
|
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`."
|
|
1156
1079
|
},
|
|
1157
|
-
production: {
|
|
1158
|
-
$ref: "#/definitions/HostConfig",
|
|
1159
|
-
deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
|
|
1160
|
-
},
|
|
1161
1080
|
development: {
|
|
1162
|
-
$ref: "#/definitions/
|
|
1163
|
-
|
|
1164
|
-
},
|
|
1165
|
-
additionalProperties: false
|
|
1166
|
-
},
|
|
1167
|
-
Vercel: {
|
|
1168
|
-
type: "object",
|
|
1169
|
-
properties: {
|
|
1170
|
-
projectId: {
|
|
1171
|
-
type: "string",
|
|
1172
|
-
description: "Vercel project ID"
|
|
1081
|
+
$ref: "#/definitions/DefaultDevelopment",
|
|
1082
|
+
description: "Development configuration for the default application."
|
|
1173
1083
|
}
|
|
1174
1084
|
},
|
|
1175
|
-
required: ["
|
|
1085
|
+
required: ["development"],
|
|
1176
1086
|
additionalProperties: false
|
|
1177
1087
|
},
|
|
1178
|
-
|
|
1179
|
-
type: "object",
|
|
1180
|
-
properties: {
|
|
1181
|
-
protocol: {
|
|
1182
|
-
type: "string",
|
|
1183
|
-
enum: ["http", "https"],
|
|
1184
|
-
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1185
|
-
},
|
|
1186
|
-
host: {
|
|
1187
|
-
type: "string",
|
|
1188
|
-
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`)."
|
|
1189
|
-
},
|
|
1190
|
-
port: {
|
|
1191
|
-
type: "number",
|
|
1192
|
-
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1193
|
-
}
|
|
1194
|
-
},
|
|
1195
|
-
required: ["host"],
|
|
1196
|
-
additionalProperties: false
|
|
1197
|
-
},
|
|
1198
|
-
Development: {
|
|
1088
|
+
DefaultDevelopment: {
|
|
1199
1089
|
type: "object",
|
|
1200
1090
|
properties: {
|
|
1201
1091
|
local: {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
type: "number"
|
|
1205
|
-
},
|
|
1206
|
-
{
|
|
1207
|
-
type: "string"
|
|
1208
|
-
},
|
|
1209
|
-
{
|
|
1210
|
-
$ref: "#/definitions/LocalHostConfig"
|
|
1211
|
-
}
|
|
1212
|
-
],
|
|
1213
|
-
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."
|
|
1092
|
+
type: ["number", "string"],
|
|
1093
|
+
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"
|
|
1214
1094
|
},
|
|
1215
1095
|
localPort: {
|
|
1216
1096
|
type: "number",
|
|
1217
1097
|
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.",
|
|
1218
1098
|
deprecated: "Please set the port with the 'local' field instead."
|
|
1219
1099
|
},
|
|
1220
|
-
fallback: {
|
|
1221
|
-
anyOf: [
|
|
1222
|
-
{
|
|
1223
|
-
$ref: "#/definitions/HostConfig"
|
|
1224
|
-
},
|
|
1225
|
-
{
|
|
1226
|
-
type: "string"
|
|
1227
|
-
}
|
|
1228
|
-
],
|
|
1229
|
-
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."
|
|
1230
|
-
},
|
|
1231
1100
|
task: {
|
|
1232
1101
|
type: "string",
|
|
1233
1102
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
1234
|
-
}
|
|
1235
|
-
},
|
|
1236
|
-
additionalProperties: false
|
|
1237
|
-
},
|
|
1238
|
-
LocalHostConfig: {
|
|
1239
|
-
type: "object",
|
|
1240
|
-
additionalProperties: false,
|
|
1241
|
-
properties: {
|
|
1242
|
-
host: {
|
|
1243
|
-
type: "string",
|
|
1244
|
-
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`)."
|
|
1245
1103
|
},
|
|
1246
|
-
|
|
1104
|
+
fallback: {
|
|
1247
1105
|
type: "string",
|
|
1248
|
-
|
|
1249
|
-
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1250
|
-
},
|
|
1251
|
-
port: {
|
|
1252
|
-
type: "number",
|
|
1253
|
-
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1106
|
+
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."
|
|
1254
1107
|
}
|
|
1255
|
-
}
|
|
1108
|
+
},
|
|
1109
|
+
required: ["fallback"],
|
|
1110
|
+
additionalProperties: false
|
|
1256
1111
|
},
|
|
1257
1112
|
ChildApplication: {
|
|
1258
1113
|
type: "object",
|
|
1259
1114
|
properties: {
|
|
1260
|
-
vercel: {
|
|
1261
|
-
$ref: "#/definitions/Vercel",
|
|
1262
|
-
deprecated: "This is being replaced by the `projectId` field below."
|
|
1263
|
-
},
|
|
1264
1115
|
projectId: {
|
|
1265
1116
|
type: "string",
|
|
1266
1117
|
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1267
|
-
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1118
|
+
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)."
|
|
1268
1119
|
},
|
|
1269
1120
|
packageName: {
|
|
1270
1121
|
type: "string",
|
|
1271
1122
|
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`."
|
|
1272
1123
|
},
|
|
1273
|
-
production: {
|
|
1274
|
-
$ref: "#/definitions/HostConfig",
|
|
1275
|
-
deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
|
|
1276
|
-
},
|
|
1277
1124
|
development: {
|
|
1278
|
-
$ref: "#/definitions/
|
|
1125
|
+
$ref: "#/definitions/ChildDevelopment",
|
|
1126
|
+
description: "Development configuration for the child application."
|
|
1279
1127
|
},
|
|
1280
1128
|
routing: {
|
|
1281
1129
|
$ref: "#/definitions/Routing",
|
|
@@ -1285,6 +1133,29 @@ var schema_default = {
|
|
|
1285
1133
|
required: ["routing"],
|
|
1286
1134
|
additionalProperties: false
|
|
1287
1135
|
},
|
|
1136
|
+
ChildDevelopment: {
|
|
1137
|
+
type: "object",
|
|
1138
|
+
properties: {
|
|
1139
|
+
local: {
|
|
1140
|
+
type: ["number", "string"],
|
|
1141
|
+
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"
|
|
1142
|
+
},
|
|
1143
|
+
localPort: {
|
|
1144
|
+
type: "number",
|
|
1145
|
+
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.",
|
|
1146
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1147
|
+
},
|
|
1148
|
+
task: {
|
|
1149
|
+
type: "string",
|
|
1150
|
+
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
1151
|
+
},
|
|
1152
|
+
fallback: {
|
|
1153
|
+
type: "string",
|
|
1154
|
+
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."
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
additionalProperties: false
|
|
1158
|
+
},
|
|
1288
1159
|
Routing: {
|
|
1289
1160
|
type: "array",
|
|
1290
1161
|
items: {
|
|
@@ -1370,7 +1241,7 @@ function formatAjvErrors(errors) {
|
|
|
1370
1241
|
}
|
|
1371
1242
|
function validateSchema(configString) {
|
|
1372
1243
|
const parsedConfig = parse3(configString);
|
|
1373
|
-
const ajv = new Ajv();
|
|
1244
|
+
const ajv = new Ajv({ allowUnionTypes: true });
|
|
1374
1245
|
const validate = ajv.compile(SCHEMA);
|
|
1375
1246
|
const isValid = validate(parsedConfig);
|
|
1376
1247
|
if (!isValid) {
|
|
@@ -1664,88 +1535,6 @@ ${indent} - Automatically redirecting all requests to local microfrontends proxy
|
|
|
1664
1535
|
return { next };
|
|
1665
1536
|
}
|
|
1666
1537
|
|
|
1667
|
-
// src/routing/get-domain-from-environment.ts
|
|
1668
|
-
function getDomainFromEnvironment({
|
|
1669
|
-
app,
|
|
1670
|
-
target
|
|
1671
|
-
}) {
|
|
1672
|
-
const mfeProjects = JSON.parse(
|
|
1673
|
-
process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "[]"
|
|
1674
|
-
);
|
|
1675
|
-
if (mfeProjects.length === 0) {
|
|
1676
|
-
throw new Error("Missing related microfrontends project information");
|
|
1677
|
-
}
|
|
1678
|
-
const vercelProject = mfeProjects.find(
|
|
1679
|
-
(p) => p.project.name === app.name || p.project.id === app.projectId
|
|
1680
|
-
);
|
|
1681
|
-
if (!vercelProject) {
|
|
1682
|
-
throw new Error(
|
|
1683
|
-
`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.`
|
|
1684
|
-
);
|
|
1685
|
-
}
|
|
1686
|
-
const domain = target === "preview" && vercelProject.preview.branch ? vercelProject.preview.branch : vercelProject.production.alias ?? vercelProject.production.url;
|
|
1687
|
-
if (!domain) {
|
|
1688
|
-
throw new Error(
|
|
1689
|
-
`Missing domain for target "${target}" in application "${app.name}"`
|
|
1690
|
-
);
|
|
1691
|
-
}
|
|
1692
|
-
return domain.startsWith("https://") ? domain : `https://${domain}`;
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
// src/routing/get-domain-for-current-environment.ts
|
|
1696
|
-
function debugDomains(zone, env, domain) {
|
|
1697
|
-
if (process.env.MFE_DEBUG === "true") {
|
|
1698
|
-
const indent = " ".repeat(4);
|
|
1699
|
-
const header = "domains (zone (env) -> domain)";
|
|
1700
|
-
const separator = "\u23AF".repeat(header.length);
|
|
1701
|
-
const line = `${indent} 1. ${zone} (${env}) -> ${domain}`;
|
|
1702
|
-
console.log(`${indent}${header}
|
|
1703
|
-
${indent}${separator}
|
|
1704
|
-
${line}
|
|
1705
|
-
`);
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
function getCurrentEnvironment() {
|
|
1709
|
-
const isDevelopment = !process.env.VERCEL_ENV || process.env.VERCEL_ENV === "development";
|
|
1710
|
-
const isPreview = process.env.VERCEL_ENV === "preview";
|
|
1711
|
-
const isProduction2 = process.env.VERCEL_ENV === "production";
|
|
1712
|
-
if (isDevelopment) {
|
|
1713
|
-
return { group: "development" };
|
|
1714
|
-
}
|
|
1715
|
-
if (isProduction2) {
|
|
1716
|
-
return { group: "production" };
|
|
1717
|
-
}
|
|
1718
|
-
if (isPreview) {
|
|
1719
|
-
return { group: "preview" };
|
|
1720
|
-
}
|
|
1721
|
-
return { group: "custom", name: process.env.VERCEL_ENV };
|
|
1722
|
-
}
|
|
1723
|
-
function getDomainForCurrentEnvironment(config, appName, opts = {}) {
|
|
1724
|
-
const app = config.getApplication(appName);
|
|
1725
|
-
if (!opts.ignoreOverride && app.overrides?.environment) {
|
|
1726
|
-
return app.overrides.environment.toString();
|
|
1727
|
-
}
|
|
1728
|
-
const { group } = getCurrentEnvironment();
|
|
1729
|
-
const fallbackHost = config.getDefaultApplication().fallback.toString();
|
|
1730
|
-
switch (group) {
|
|
1731
|
-
case "development": {
|
|
1732
|
-
const domain = ["test", "development"].includes(process.env.NODE_ENV) ? app.development.local.toString() : fallbackHost;
|
|
1733
|
-
debugDomains(appName, "development", domain);
|
|
1734
|
-
return domain;
|
|
1735
|
-
}
|
|
1736
|
-
case "preview": {
|
|
1737
|
-
return getDomainFromEnvironment({ app, target: "preview" });
|
|
1738
|
-
}
|
|
1739
|
-
case "production": {
|
|
1740
|
-
return getDomainFromEnvironment({ app, target: "production" });
|
|
1741
|
-
}
|
|
1742
|
-
case "custom":
|
|
1743
|
-
throw new Error(
|
|
1744
|
-
"Custom environments are not supported in getDomainForCurrentEnvironment"
|
|
1745
|
-
);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
1538
|
// src/next/config/transforms/rewrites.ts
|
|
1750
1539
|
function debugRewrites(rewrites) {
|
|
1751
1540
|
if (process.env.MFE_DEBUG) {
|
|
@@ -1779,7 +1568,7 @@ function rewritesMapToArr(rewrites) {
|
|
|
1779
1568
|
});
|
|
1780
1569
|
}
|
|
1781
1570
|
function transform5(args) {
|
|
1782
|
-
const { app,
|
|
1571
|
+
const { app, next } = args;
|
|
1783
1572
|
const buildBeforeFiles = () => {
|
|
1784
1573
|
const rewrites = /* @__PURE__ */ new Map();
|
|
1785
1574
|
if (!app.isDefault()) {
|
|
@@ -1798,15 +1587,6 @@ function transform5(args) {
|
|
|
1798
1587
|
pathname: "/_vercel/:path*"
|
|
1799
1588
|
}
|
|
1800
1589
|
});
|
|
1801
|
-
} else if (opts?.supportPagesRouter) {
|
|
1802
|
-
for (const child of microfrontend.getChildApplications()) {
|
|
1803
|
-
rewrites.set(`/_next/data/${child.getAssetPrefix()}-:buildId/:path*`, {
|
|
1804
|
-
destination: {
|
|
1805
|
-
domain: getDomainForCurrentEnvironment(microfrontend, child.name),
|
|
1806
|
-
pathname: `/_next/data/${child.getAssetPrefix()}-:buildId/:path*`
|
|
1807
|
-
}
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
1590
|
}
|
|
1811
1591
|
return rewritesMapToArr(rewrites);
|
|
1812
1592
|
};
|
|
@@ -1842,76 +1622,8 @@ function transform5(args) {
|
|
|
1842
1622
|
};
|
|
1843
1623
|
}
|
|
1844
1624
|
|
|
1845
|
-
// src/next/config/transforms/server-actions.ts
|
|
1846
|
-
function debugRewrites2(allowedOrigins) {
|
|
1847
|
-
if (process.env.MFE_DEBUG === "true" && allowedOrigins) {
|
|
1848
|
-
const indent = " ".repeat(4);
|
|
1849
|
-
const header = "server actions allowed origins";
|
|
1850
|
-
const separator = "\u23AF".repeat(header.length);
|
|
1851
|
-
const maxSourceLength = Math.max(
|
|
1852
|
-
...allowedOrigins.map((key) => key.length)
|
|
1853
|
-
);
|
|
1854
|
-
const table = allowedOrigins.map((origin, idx) => {
|
|
1855
|
-
const paddedSource = origin.padEnd(maxSourceLength);
|
|
1856
|
-
return `${indent} ${idx + 1}. ${paddedSource}`;
|
|
1857
|
-
}).join("\n");
|
|
1858
|
-
console.log(`${indent}${header}
|
|
1859
|
-
${indent}${separator}
|
|
1860
|
-
${table}
|
|
1861
|
-
`);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1865
|
-
function transform6(args) {
|
|
1866
|
-
const { next, app, microfrontend } = args;
|
|
1867
|
-
const defaultApplication = microfrontend.getDefaultApplication();
|
|
1868
|
-
const appsToAllow = [
|
|
1869
|
-
// this zone - this is included by default unless allowedOrigins is overridden (which we are)
|
|
1870
|
-
// so we re-add it here.
|
|
1871
|
-
app,
|
|
1872
|
-
// this is the default zone for the microfrontend. Allow child zones to call server actions
|
|
1873
|
-
// that are in the default zone.
|
|
1874
|
-
defaultApplication
|
|
1875
|
-
];
|
|
1876
|
-
const existingServerActionConfig = next.experimental?.serverActions;
|
|
1877
|
-
next.experimental = {
|
|
1878
|
-
...next.experimental,
|
|
1879
|
-
serverActions: {
|
|
1880
|
-
...existingServerActionConfig,
|
|
1881
|
-
allowedOrigins: Array.from(
|
|
1882
|
-
/* @__PURE__ */ new Set([
|
|
1883
|
-
// existing
|
|
1884
|
-
...existingServerActionConfig?.allowedOrigins ?? [],
|
|
1885
|
-
// this deployments host
|
|
1886
|
-
...process.env.VERCEL_URL ? [formatDomainForServerAction(process.env.VERCEL_URL)] : [],
|
|
1887
|
-
// default application host
|
|
1888
|
-
...process.env.VERCEL_MICROFRONTENDS_PROJECTS ? [
|
|
1889
|
-
formatDomainForServerAction(
|
|
1890
|
-
getDomainFromEnvironment({
|
|
1891
|
-
app: defaultApplication,
|
|
1892
|
-
target: "production"
|
|
1893
|
-
})
|
|
1894
|
-
)
|
|
1895
|
-
] : [],
|
|
1896
|
-
formatDomainForServerAction(defaultApplication.fallback.toString()),
|
|
1897
|
-
// environment specific microfrontend hosts
|
|
1898
|
-
...appsToAllow.flatMap((a) => [
|
|
1899
|
-
formatDomainForServerAction(
|
|
1900
|
-
getDomainForCurrentEnvironment(microfrontend, a.name)
|
|
1901
|
-
)
|
|
1902
|
-
])
|
|
1903
|
-
])
|
|
1904
|
-
)
|
|
1905
|
-
}
|
|
1906
|
-
};
|
|
1907
|
-
debugRewrites2(next.experimental.serverActions?.allowedOrigins);
|
|
1908
|
-
return {
|
|
1909
|
-
next
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
1625
|
// src/next/config/transforms/webpack.ts
|
|
1914
|
-
function
|
|
1626
|
+
function transform6(args) {
|
|
1915
1627
|
const { next, microfrontend, opts } = args;
|
|
1916
1628
|
const configWithWebpack = {
|
|
1917
1629
|
...next,
|
|
@@ -1990,8 +1702,7 @@ var transforms = {
|
|
|
1990
1702
|
draftMode: transform3,
|
|
1991
1703
|
redirects: transform4,
|
|
1992
1704
|
rewrites: transform5,
|
|
1993
|
-
|
|
1994
|
-
webpack: transform7
|
|
1705
|
+
webpack: transform6
|
|
1995
1706
|
};
|
|
1996
1707
|
|
|
1997
1708
|
// src/next/config/env.ts
|
|
@@ -2056,13 +1767,13 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2056
1767
|
const app = microfrontends.config.getApplication(fromApp);
|
|
2057
1768
|
setEnvironment({ app, microfrontends });
|
|
2058
1769
|
let next = { ...nextConfig };
|
|
2059
|
-
for (const [key,
|
|
1770
|
+
for (const [key, transform7] of typedEntries(transforms)) {
|
|
2060
1771
|
if (opts?.skipTransforms?.includes(key)) {
|
|
2061
1772
|
console.log(`Skipping ${key} transform`);
|
|
2062
1773
|
continue;
|
|
2063
1774
|
}
|
|
2064
1775
|
try {
|
|
2065
|
-
const transformedConfig =
|
|
1776
|
+
const transformedConfig = transform7({
|
|
2066
1777
|
app,
|
|
2067
1778
|
next,
|
|
2068
1779
|
microfrontend: microfrontends.config,
|