@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.
Files changed (55) hide show
  1. package/dist/bin/cli.cjs +405 -204
  2. package/dist/config.cjs +25 -68
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +5 -5
  5. package/dist/config.js +25 -68
  6. package/dist/config.js.map +1 -1
  7. package/dist/experimental/sveltekit.cjs +64 -193
  8. package/dist/experimental/sveltekit.cjs.map +1 -1
  9. package/dist/experimental/sveltekit.js +64 -193
  10. package/dist/experimental/sveltekit.js.map +1 -1
  11. package/dist/experimental/vite.cjs +64 -193
  12. package/dist/experimental/vite.cjs.map +1 -1
  13. package/dist/experimental/vite.js +64 -193
  14. package/dist/experimental/vite.js.map +1 -1
  15. package/dist/microfrontends/server.cjs +64 -193
  16. package/dist/microfrontends/server.cjs.map +1 -1
  17. package/dist/microfrontends/server.d.ts +3 -3
  18. package/dist/microfrontends/server.js +64 -193
  19. package/dist/microfrontends/server.js.map +1 -1
  20. package/dist/next/config.cjs +69 -358
  21. package/dist/next/config.cjs.map +1 -1
  22. package/dist/next/config.d.ts +1 -1
  23. package/dist/next/config.js +69 -358
  24. package/dist/next/config.js.map +1 -1
  25. package/dist/next/endpoints.d.ts +2 -2
  26. package/dist/next/middleware.cjs +25 -68
  27. package/dist/next/middleware.cjs.map +1 -1
  28. package/dist/next/middleware.js +25 -68
  29. package/dist/next/middleware.js.map +1 -1
  30. package/dist/next/testing.cjs +123 -144
  31. package/dist/next/testing.cjs.map +1 -1
  32. package/dist/next/testing.d.ts +36 -5
  33. package/dist/next/testing.js +122 -143
  34. package/dist/next/testing.js.map +1 -1
  35. package/dist/overrides.d.ts +3 -3
  36. package/dist/schema.d.ts +2 -2
  37. package/dist/{types-f1260e44.d.ts → types-b970b583.d.ts} +1 -1
  38. package/dist/{types-a4add5ab.d.ts → types-bee19651.d.ts} +11 -2
  39. package/dist/{types-54064641.d.ts → types-c9f15465.d.ts} +31 -85
  40. package/dist/utils/mfe-port.cjs +64 -193
  41. package/dist/utils/mfe-port.cjs.map +1 -1
  42. package/dist/utils/mfe-port.js +64 -193
  43. package/dist/utils/mfe-port.js.map +1 -1
  44. package/dist/validation.cjs +39 -125
  45. package/dist/validation.cjs.map +1 -1
  46. package/dist/validation.d.ts +1 -1
  47. package/dist/validation.js +39 -125
  48. package/dist/validation.js.map +1 -1
  49. package/package.json +2 -8
  50. package/schema/schema.json +45 -131
  51. package/dist/routing.cjs +0 -19
  52. package/dist/routing.cjs.map +0 -1
  53. package/dist/routing.d.ts +0 -26
  54. package/dist/routing.js +0 -1
  55. package/dist/routing.js.map +0 -1
@@ -430,8 +430,7 @@ var validateConfigPaths = (applicationConfigsById) => {
430
430
  if (isDefaultApp(app)) {
431
431
  continue;
432
432
  }
433
- const childApp = app;
434
- for (const pathMatch of childApp.routing) {
433
+ for (const pathMatch of app.routing) {
435
434
  for (const path7 of pathMatch.paths) {
436
435
  const maybeError = validatePathExpression(path7);
437
436
  if (maybeError) {
@@ -579,64 +578,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
579
578
  };
580
579
  var validateDeprecatedFields = (config) => {
581
580
  const errors = [];
582
- if (config.options?.vercel) {
583
- errors.push(
584
- `Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
585
- );
586
- }
587
- if (config.options?.localProxy) {
588
- errors.push(
589
- `Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
590
- );
591
- }
592
581
  for (const [applicationId, application] of Object.entries(
593
582
  config.applications
594
583
  )) {
595
- if (application.vercel) {
596
- errors.push(
597
- `Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
598
- );
599
- }
600
- if (application.production) {
601
- errors.push(
602
- `Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
603
- );
604
- }
605
584
  if (application.development?.localPort) {
606
585
  errors.push(
607
586
  `Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
608
587
  );
609
588
  }
610
- if (application.development?.fallback && typeof application.development.fallback !== "string") {
611
- const fallback = application.development.fallback;
612
- let asString = fallback.host;
613
- if (fallback.protocol) {
614
- asString = `${fallback.protocol}://${asString}`;
615
- }
616
- if (fallback.port) {
617
- asString = `${asString}:${fallback.port}`;
618
- }
619
- errors.push(
620
- `Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
621
- );
622
- }
623
- if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
624
- const local = application.development.local;
625
- let asString;
626
- if (local.port && !local.protocol && !local.host) {
627
- asString = String(local.port);
628
- } else {
629
- asString = local.host ?? "localhost";
630
- if (local.protocol) {
631
- asString = `${local.protocol}://${asString}`;
632
- }
633
- if (local.port) {
634
- asString = `${asString}:${local.port}`;
635
- }
636
- }
637
- errors.push(
638
- `Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
639
- );
589
+ if (application.projectId) {
640
590
  }
641
591
  }
642
592
  if (errors.length) {
@@ -791,6 +741,13 @@ var LocalHost = class extends Host {
791
741
  }
792
742
  };
793
743
 
744
+ // src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
745
+ function generateAutomationBypassEnvVarName({
746
+ name
747
+ }) {
748
+ return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
749
+ }
750
+
794
751
  // src/config/microfrontends-config/isomorphic/application.ts
795
752
  var Application = class {
796
753
  constructor(name, {
@@ -809,10 +766,8 @@ var Application = class {
809
766
  };
810
767
  if (app.development?.fallback) {
811
768
  this.fallback = new Host(app.development.fallback);
812
- } else if (app.production) {
813
- this.fallback = new Host(app.production);
814
769
  }
815
- this.projectId = app.projectId ?? app.vercel?.projectId;
770
+ this.projectId = app.projectId;
816
771
  this.packageName = app.packageName;
817
772
  this.overrides = overrides?.environment ? {
818
773
  environment: new Host(overrides.environment)
@@ -826,6 +781,9 @@ var Application = class {
826
781
  getAssetPrefix() {
827
782
  return generateAssetPrefixFromName({ name: this.name });
828
783
  }
784
+ getAutomationBypassEnvVarName() {
785
+ return generateAutomationBypassEnvVarName({ name: this.name });
786
+ }
829
787
  serialize() {
830
788
  return this.serialized;
831
789
  }
@@ -841,16 +799,7 @@ var DefaultApplication = class extends Application {
841
799
  isDefault: true
842
800
  });
843
801
  this.default = true;
844
- const fallbackHost = app.development?.fallback ?? app.production;
845
- if (fallbackHost === void 0) {
846
- throw new Error(
847
- "`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
848
- );
849
- }
850
- this.fallback = new Host(fallbackHost);
851
- if (app.production) {
852
- this.production = new Host(app.production);
853
- }
802
+ this.fallback = new Host(app.development.fallback);
854
803
  }
855
804
  getAssetPrefix() {
856
805
  return "";
@@ -887,7 +836,7 @@ var MicrofrontendConfigIsomorphic = class {
887
836
  }) {
888
837
  this.childApplications = {};
889
838
  MicrofrontendConfigIsomorphic.validate(config, opts);
890
- const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
839
+ const disableOverrides = config.options?.disableOverrides ?? false;
891
840
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
892
841
  let defaultApplication;
893
842
  for (const [appId, appConfig] of Object.entries(config.applications)) {
@@ -940,7 +889,7 @@ var MicrofrontendConfigIsomorphic = class {
940
889
  });
941
890
  }
942
891
  isOverridesDisabled() {
943
- return this.options?.vercel?.disableOverrides ?? false;
892
+ return this.options?.disableOverrides ?? false;
944
893
  }
945
894
  getConfig() {
946
895
  return this.config;
@@ -978,6 +927,14 @@ var MicrofrontendConfigIsomorphic = class {
978
927
  }
979
928
  return app;
980
929
  }
930
+ hasApplication(name) {
931
+ try {
932
+ this.getApplication(name);
933
+ return true;
934
+ } catch {
935
+ return false;
936
+ }
937
+ }
981
938
  getApplicationByProjectId(projectId) {
982
939
  if (this.defaultApplication.projectId === projectId) {
983
940
  return this.defaultApplication;
@@ -996,7 +953,7 @@ var MicrofrontendConfigIsomorphic = class {
996
953
  * Returns the configured port for the local proxy
997
954
  */
998
955
  getLocalProxyPort() {
999
- return this.config.options?.localProxyPort ?? this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
956
+ return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
1000
957
  }
1001
958
  /**
1002
959
  * Serializes the class back to the Schema type.
@@ -1107,20 +1064,10 @@ var schema_default = {
1107
1064
  Options: {
1108
1065
  type: "object",
1109
1066
  properties: {
1110
- vercel: {
1111
- $ref: "#/definitions/VercelOptions",
1112
- description: "Microfrontends wide options for Vercel.",
1113
- deprecated: "This is being replaced by the `disableOverrides` field below."
1114
- },
1115
1067
  disableOverrides: {
1116
1068
  type: "boolean",
1117
1069
  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."
1118
1070
  },
1119
- localProxy: {
1120
- $ref: "#/definitions/LocalProxyOptions",
1121
- description: "Options for local proxy.",
1122
- deprecated: "This is being replaced by the `localProxyPort` field below."
1123
- },
1124
1071
  localProxyPort: {
1125
1072
  type: "number",
1126
1073
  description: "The port number used by the local proxy server.\n\nThe default is `3024`."
@@ -1128,26 +1075,6 @@ var schema_default = {
1128
1075
  },
1129
1076
  additionalProperties: false
1130
1077
  },
1131
- VercelOptions: {
1132
- type: "object",
1133
- properties: {
1134
- disableOverrides: {
1135
- type: "boolean",
1136
- 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."
1137
- }
1138
- },
1139
- additionalProperties: false
1140
- },
1141
- LocalProxyOptions: {
1142
- type: "object",
1143
- properties: {
1144
- port: {
1145
- type: "number",
1146
- description: "The port number used by the local proxy server.\n\nThe default is `3024`."
1147
- }
1148
- },
1149
- additionalProperties: false
1150
- },
1151
1078
  ApplicationRouting: {
1152
1079
  type: "object",
1153
1080
  additionalProperties: {
@@ -1170,141 +1097,62 @@ var schema_default = {
1170
1097
  DefaultApplication: {
1171
1098
  type: "object",
1172
1099
  properties: {
1173
- vercel: {
1174
- $ref: "#/definitions/Vercel",
1175
- deprecated: "This is being replaced by the `projectId` field below."
1176
- },
1177
1100
  projectId: {
1178
1101
  type: "string",
1179
1102
  description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
1180
- deprecated: "Instead, the application id should match the Vercel project name."
1103
+ 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)."
1181
1104
  },
1182
1105
  packageName: {
1183
1106
  type: "string",
1184
1107
  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`."
1185
1108
  },
1186
- production: {
1187
- $ref: "#/definitions/HostConfig",
1188
- deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
1189
- },
1190
1109
  development: {
1191
- $ref: "#/definitions/Development"
1110
+ $ref: "#/definitions/DefaultDevelopment",
1111
+ description: "Development configuration for the default application."
1192
1112
  }
1193
1113
  },
1114
+ required: ["development"],
1194
1115
  additionalProperties: false
1195
1116
  },
1196
- Vercel: {
1197
- type: "object",
1198
- properties: {
1199
- projectId: {
1200
- type: "string",
1201
- description: "Vercel project ID"
1202
- }
1203
- },
1204
- required: ["projectId"],
1205
- additionalProperties: false
1206
- },
1207
- HostConfig: {
1208
- type: "object",
1209
- properties: {
1210
- protocol: {
1211
- type: "string",
1212
- enum: ["http", "https"],
1213
- description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1214
- },
1215
- host: {
1216
- type: "string",
1217
- 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`)."
1218
- },
1219
- port: {
1220
- type: "number",
1221
- description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1222
- }
1223
- },
1224
- required: ["host"],
1225
- additionalProperties: false
1226
- },
1227
- Development: {
1117
+ DefaultDevelopment: {
1228
1118
  type: "object",
1229
1119
  properties: {
1230
1120
  local: {
1231
- anyOf: [
1232
- {
1233
- type: "number"
1234
- },
1235
- {
1236
- type: "string"
1237
- },
1238
- {
1239
- $ref: "#/definitions/LocalHostConfig"
1240
- }
1241
- ],
1242
- 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."
1121
+ type: ["number", "string"],
1122
+ 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"
1243
1123
  },
1244
1124
  localPort: {
1245
1125
  type: "number",
1246
1126
  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.",
1247
1127
  deprecated: "Please set the port with the 'local' field instead."
1248
1128
  },
1249
- fallback: {
1250
- anyOf: [
1251
- {
1252
- $ref: "#/definitions/HostConfig"
1253
- },
1254
- {
1255
- type: "string"
1256
- }
1257
- ],
1258
- 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."
1259
- },
1260
1129
  task: {
1261
1130
  type: "string",
1262
1131
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1263
- }
1264
- },
1265
- additionalProperties: false
1266
- },
1267
- LocalHostConfig: {
1268
- type: "object",
1269
- additionalProperties: false,
1270
- properties: {
1271
- host: {
1272
- type: "string",
1273
- 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`)."
1274
1132
  },
1275
- protocol: {
1133
+ fallback: {
1276
1134
  type: "string",
1277
- enum: ["http", "https"],
1278
- description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1279
- },
1280
- port: {
1281
- type: "number",
1282
- description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1135
+ 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."
1283
1136
  }
1284
- }
1137
+ },
1138
+ required: ["fallback"],
1139
+ additionalProperties: false
1285
1140
  },
1286
1141
  ChildApplication: {
1287
1142
  type: "object",
1288
1143
  properties: {
1289
- vercel: {
1290
- $ref: "#/definitions/Vercel",
1291
- deprecated: "This is being replaced by the `projectId` field below."
1292
- },
1293
1144
  projectId: {
1294
1145
  type: "string",
1295
1146
  description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
1296
- deprecated: "Instead, the application id should match the Vercel project name."
1147
+ 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)."
1297
1148
  },
1298
1149
  packageName: {
1299
1150
  type: "string",
1300
1151
  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`."
1301
1152
  },
1302
- production: {
1303
- $ref: "#/definitions/HostConfig",
1304
- deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
1305
- },
1306
1153
  development: {
1307
- $ref: "#/definitions/Development"
1154
+ $ref: "#/definitions/ChildDevelopment",
1155
+ description: "Development configuration for the child application."
1308
1156
  },
1309
1157
  routing: {
1310
1158
  $ref: "#/definitions/Routing",
@@ -1314,6 +1162,29 @@ var schema_default = {
1314
1162
  required: ["routing"],
1315
1163
  additionalProperties: false
1316
1164
  },
1165
+ ChildDevelopment: {
1166
+ type: "object",
1167
+ properties: {
1168
+ local: {
1169
+ type: ["number", "string"],
1170
+ 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"
1171
+ },
1172
+ localPort: {
1173
+ type: "number",
1174
+ 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.",
1175
+ deprecated: "Please set the port with the 'local' field instead."
1176
+ },
1177
+ task: {
1178
+ type: "string",
1179
+ description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1180
+ },
1181
+ fallback: {
1182
+ type: "string",
1183
+ 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."
1184
+ }
1185
+ },
1186
+ additionalProperties: false
1187
+ },
1317
1188
  Routing: {
1318
1189
  type: "array",
1319
1190
  items: {
@@ -1399,7 +1270,7 @@ function formatAjvErrors(errors) {
1399
1270
  }
1400
1271
  function validateSchema(configString) {
1401
1272
  const parsedConfig = (0, import_jsonc_parser3.parse)(configString);
1402
- const ajv = new import_ajv.Ajv();
1273
+ const ajv = new import_ajv.Ajv({ allowUnionTypes: true });
1403
1274
  const validate = ajv.compile(SCHEMA);
1404
1275
  const isValid = validate(parsedConfig);
1405
1276
  if (!isValid) {