@vercel/microfrontends 1.1.1-canary.6 → 1.1.1-canary.7

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 +4 -10
  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
@@ -437,8 +437,7 @@ var validateConfigPaths = (applicationConfigsById) => {
437
437
  if (isDefaultApp(app)) {
438
438
  continue;
439
439
  }
440
- const childApp = app;
441
- for (const pathMatch of childApp.routing) {
440
+ for (const pathMatch of app.routing) {
442
441
  for (const path6 of pathMatch.paths) {
443
442
  const maybeError = validatePathExpression(path6);
444
443
  if (maybeError) {
@@ -586,64 +585,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
586
585
  };
587
586
  var validateDeprecatedFields = (config) => {
588
587
  const errors = [];
589
- if (config.options?.vercel) {
590
- errors.push(
591
- `Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
592
- );
593
- }
594
- if (config.options?.localProxy) {
595
- errors.push(
596
- `Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
597
- );
598
- }
599
588
  for (const [applicationId, application] of Object.entries(
600
589
  config.applications
601
590
  )) {
602
- if (application.vercel) {
603
- errors.push(
604
- `Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
605
- );
606
- }
607
- if (application.production) {
608
- errors.push(
609
- `Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
610
- );
611
- }
612
591
  if (application.development?.localPort) {
613
592
  errors.push(
614
593
  `Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
615
594
  );
616
595
  }
617
- if (application.development?.fallback && typeof application.development.fallback !== "string") {
618
- const fallback = application.development.fallback;
619
- let asString = fallback.host;
620
- if (fallback.protocol) {
621
- asString = `${fallback.protocol}://${asString}`;
622
- }
623
- if (fallback.port) {
624
- asString = `${asString}:${fallback.port}`;
625
- }
626
- errors.push(
627
- `Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
628
- );
629
- }
630
- if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
631
- const local = application.development.local;
632
- let asString;
633
- if (local.port && !local.protocol && !local.host) {
634
- asString = String(local.port);
635
- } else {
636
- asString = local.host ?? "localhost";
637
- if (local.protocol) {
638
- asString = `${local.protocol}://${asString}`;
639
- }
640
- if (local.port) {
641
- asString = `${asString}:${local.port}`;
642
- }
643
- }
644
- errors.push(
645
- `Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
646
- );
596
+ if (application.projectId) {
647
597
  }
648
598
  }
649
599
  if (errors.length) {
@@ -798,6 +748,13 @@ var LocalHost = class extends Host {
798
748
  }
799
749
  };
800
750
 
751
+ // src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
752
+ function generateAutomationBypassEnvVarName({
753
+ name
754
+ }) {
755
+ return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
756
+ }
757
+
801
758
  // src/config/microfrontends-config/isomorphic/application.ts
802
759
  var Application = class {
803
760
  constructor(name, {
@@ -816,10 +773,8 @@ var Application = class {
816
773
  };
817
774
  if (app.development?.fallback) {
818
775
  this.fallback = new Host(app.development.fallback);
819
- } else if (app.production) {
820
- this.fallback = new Host(app.production);
821
776
  }
822
- this.projectId = app.projectId ?? app.vercel?.projectId;
777
+ this.projectId = app.projectId;
823
778
  this.packageName = app.packageName;
824
779
  this.overrides = overrides?.environment ? {
825
780
  environment: new Host(overrides.environment)
@@ -833,6 +788,9 @@ var Application = class {
833
788
  getAssetPrefix() {
834
789
  return generateAssetPrefixFromName({ name: this.name });
835
790
  }
791
+ getAutomationBypassEnvVarName() {
792
+ return generateAutomationBypassEnvVarName({ name: this.name });
793
+ }
836
794
  serialize() {
837
795
  return this.serialized;
838
796
  }
@@ -848,16 +806,7 @@ var DefaultApplication = class extends Application {
848
806
  isDefault: true
849
807
  });
850
808
  this.default = true;
851
- const fallbackHost = app.development?.fallback ?? app.production;
852
- if (fallbackHost === void 0) {
853
- throw new Error(
854
- "`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
855
- );
856
- }
857
- this.fallback = new Host(fallbackHost);
858
- if (app.production) {
859
- this.production = new Host(app.production);
860
- }
809
+ this.fallback = new Host(app.development.fallback);
861
810
  }
862
811
  getAssetPrefix() {
863
812
  return "";
@@ -894,7 +843,7 @@ var MicrofrontendConfigIsomorphic = class {
894
843
  }) {
895
844
  this.childApplications = {};
896
845
  MicrofrontendConfigIsomorphic.validate(config, opts);
897
- const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
846
+ const disableOverrides = config.options?.disableOverrides ?? false;
898
847
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
899
848
  let defaultApplication;
900
849
  for (const [appId, appConfig] of Object.entries(config.applications)) {
@@ -947,7 +896,7 @@ var MicrofrontendConfigIsomorphic = class {
947
896
  });
948
897
  }
949
898
  isOverridesDisabled() {
950
- return this.options?.vercel?.disableOverrides ?? false;
899
+ return this.options?.disableOverrides ?? false;
951
900
  }
952
901
  getConfig() {
953
902
  return this.config;
@@ -985,6 +934,14 @@ var MicrofrontendConfigIsomorphic = class {
985
934
  }
986
935
  return app;
987
936
  }
937
+ hasApplication(name) {
938
+ try {
939
+ this.getApplication(name);
940
+ return true;
941
+ } catch {
942
+ return false;
943
+ }
944
+ }
988
945
  getApplicationByProjectId(projectId) {
989
946
  if (this.defaultApplication.projectId === projectId) {
990
947
  return this.defaultApplication;
@@ -1003,7 +960,7 @@ var MicrofrontendConfigIsomorphic = class {
1003
960
  * Returns the configured port for the local proxy
1004
961
  */
1005
962
  getLocalProxyPort() {
1006
- return this.config.options?.localProxyPort ?? this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
963
+ return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
1007
964
  }
1008
965
  /**
1009
966
  * Serializes the class back to the Schema type.
@@ -1114,20 +1071,10 @@ var schema_default = {
1114
1071
  Options: {
1115
1072
  type: "object",
1116
1073
  properties: {
1117
- vercel: {
1118
- $ref: "#/definitions/VercelOptions",
1119
- description: "Microfrontends wide options for Vercel.",
1120
- deprecated: "This is being replaced by the `disableOverrides` field below."
1121
- },
1122
1074
  disableOverrides: {
1123
1075
  type: "boolean",
1124
1076
  description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
1125
1077
  },
1126
- localProxy: {
1127
- $ref: "#/definitions/LocalProxyOptions",
1128
- description: "Options for local proxy.",
1129
- deprecated: "This is being replaced by the `localProxyPort` field below."
1130
- },
1131
1078
  localProxyPort: {
1132
1079
  type: "number",
1133
1080
  description: "The port number used by the local proxy server.\n\nThe default is `3024`."
@@ -1135,26 +1082,6 @@ var schema_default = {
1135
1082
  },
1136
1083
  additionalProperties: false
1137
1084
  },
1138
- VercelOptions: {
1139
- type: "object",
1140
- properties: {
1141
- disableOverrides: {
1142
- type: "boolean",
1143
- description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
1144
- }
1145
- },
1146
- additionalProperties: false
1147
- },
1148
- LocalProxyOptions: {
1149
- type: "object",
1150
- properties: {
1151
- port: {
1152
- type: "number",
1153
- description: "The port number used by the local proxy server.\n\nThe default is `3024`."
1154
- }
1155
- },
1156
- additionalProperties: false
1157
- },
1158
1085
  ApplicationRouting: {
1159
1086
  type: "object",
1160
1087
  additionalProperties: {
@@ -1177,141 +1104,62 @@ var schema_default = {
1177
1104
  DefaultApplication: {
1178
1105
  type: "object",
1179
1106
  properties: {
1180
- vercel: {
1181
- $ref: "#/definitions/Vercel",
1182
- deprecated: "This is being replaced by the `projectId` field below."
1183
- },
1184
1107
  projectId: {
1185
1108
  type: "string",
1186
1109
  description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
1187
- deprecated: "Instead, the application id should match the Vercel project name."
1110
+ deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
1188
1111
  },
1189
1112
  packageName: {
1190
1113
  type: "string",
1191
1114
  description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
1192
1115
  },
1193
- production: {
1194
- $ref: "#/definitions/HostConfig",
1195
- deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
1196
- },
1197
1116
  development: {
1198
- $ref: "#/definitions/Development"
1117
+ $ref: "#/definitions/DefaultDevelopment",
1118
+ description: "Development configuration for the default application."
1199
1119
  }
1200
1120
  },
1121
+ required: ["development"],
1201
1122
  additionalProperties: false
1202
1123
  },
1203
- Vercel: {
1204
- type: "object",
1205
- properties: {
1206
- projectId: {
1207
- type: "string",
1208
- description: "Vercel project ID"
1209
- }
1210
- },
1211
- required: ["projectId"],
1212
- additionalProperties: false
1213
- },
1214
- HostConfig: {
1215
- type: "object",
1216
- properties: {
1217
- protocol: {
1218
- type: "string",
1219
- enum: ["http", "https"],
1220
- description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1221
- },
1222
- host: {
1223
- type: "string",
1224
- description: "The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`)."
1225
- },
1226
- port: {
1227
- type: "number",
1228
- description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1229
- }
1230
- },
1231
- required: ["host"],
1232
- additionalProperties: false
1233
- },
1234
- Development: {
1124
+ DefaultDevelopment: {
1235
1125
  type: "object",
1236
1126
  properties: {
1237
1127
  local: {
1238
- anyOf: [
1239
- {
1240
- type: "number"
1241
- },
1242
- {
1243
- type: "string"
1244
- },
1245
- {
1246
- $ref: "#/definitions/LocalHostConfig"
1247
- }
1248
- ],
1249
- description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080\n\nPassing a LocalHostConfig is deprecated and will go away soon, please pass a number or string."
1128
+ type: ["number", "string"],
1129
+ description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1250
1130
  },
1251
1131
  localPort: {
1252
1132
  type: "number",
1253
1133
  description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
1254
1134
  deprecated: "Please set the port with the 'local' field instead."
1255
1135
  },
1256
- fallback: {
1257
- anyOf: [
1258
- {
1259
- $ref: "#/definitions/HostConfig"
1260
- },
1261
- {
1262
- type: "string"
1263
- }
1264
- ],
1265
- description: "Fallback for local development, could point to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\n\nPassing a HostConfig is deprecated and will go away soon, please pass a string."
1266
- },
1267
1136
  task: {
1268
1137
  type: "string",
1269
1138
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1270
- }
1271
- },
1272
- additionalProperties: false
1273
- },
1274
- LocalHostConfig: {
1275
- type: "object",
1276
- additionalProperties: false,
1277
- properties: {
1278
- host: {
1279
- type: "string",
1280
- description: "The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`)."
1281
1139
  },
1282
- protocol: {
1140
+ fallback: {
1283
1141
  type: "string",
1284
- enum: ["http", "https"],
1285
- description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
1286
- },
1287
- port: {
1288
- type: "number",
1289
- description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1142
+ description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1290
1143
  }
1291
- }
1144
+ },
1145
+ required: ["fallback"],
1146
+ additionalProperties: false
1292
1147
  },
1293
1148
  ChildApplication: {
1294
1149
  type: "object",
1295
1150
  properties: {
1296
- vercel: {
1297
- $ref: "#/definitions/Vercel",
1298
- deprecated: "This is being replaced by the `projectId` field below."
1299
- },
1300
1151
  projectId: {
1301
1152
  type: "string",
1302
1153
  description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
1303
- deprecated: "Instead, the application id should match the Vercel project name."
1154
+ deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
1304
1155
  },
1305
1156
  packageName: {
1306
1157
  type: "string",
1307
1158
  description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
1308
1159
  },
1309
- production: {
1310
- $ref: "#/definitions/HostConfig",
1311
- deprecated: "This is a duplicate of the `development.fallback` field and this will be removed soon."
1312
- },
1313
1160
  development: {
1314
- $ref: "#/definitions/Development"
1161
+ $ref: "#/definitions/ChildDevelopment",
1162
+ description: "Development configuration for the child application."
1315
1163
  },
1316
1164
  routing: {
1317
1165
  $ref: "#/definitions/Routing",
@@ -1321,6 +1169,29 @@ var schema_default = {
1321
1169
  required: ["routing"],
1322
1170
  additionalProperties: false
1323
1171
  },
1172
+ ChildDevelopment: {
1173
+ type: "object",
1174
+ properties: {
1175
+ local: {
1176
+ type: ["number", "string"],
1177
+ description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1178
+ },
1179
+ localPort: {
1180
+ type: "number",
1181
+ description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
1182
+ deprecated: "Please set the port with the 'local' field instead."
1183
+ },
1184
+ task: {
1185
+ type: "string",
1186
+ description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1187
+ },
1188
+ fallback: {
1189
+ type: "string",
1190
+ description: "Fallback for local development, could point to any environment. This is optional for child apps. If not provided, the fallback of the default app will be used.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1191
+ }
1192
+ },
1193
+ additionalProperties: false
1194
+ },
1324
1195
  Routing: {
1325
1196
  type: "array",
1326
1197
  items: {
@@ -1406,7 +1277,7 @@ function formatAjvErrors(errors) {
1406
1277
  }
1407
1278
  function validateSchema(configString) {
1408
1279
  const parsedConfig = (0, import_jsonc_parser3.parse)(configString);
1409
- const ajv = new import_ajv.Ajv();
1280
+ const ajv = new import_ajv.Ajv({ allowUnionTypes: true });
1410
1281
  const validate = ajv.compile(SCHEMA);
1411
1282
  const isValid = validate(parsedConfig);
1412
1283
  if (!isValid) {