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