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