@vercel/microfrontends 1.1.1-canary.2 → 1.1.1-canary.4

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 (64) hide show
  1. package/dist/bin/cli.cjs +303 -512
  2. package/dist/config.cjs +43 -71
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +153 -4
  5. package/dist/config.js +43 -71
  6. package/dist/config.js.map +1 -1
  7. package/dist/experimental/sveltekit.cjs +296 -489
  8. package/dist/experimental/sveltekit.cjs.map +1 -1
  9. package/dist/experimental/sveltekit.js +286 -479
  10. package/dist/experimental/sveltekit.js.map +1 -1
  11. package/dist/experimental/vite.cjs +326 -511
  12. package/dist/experimental/vite.cjs.map +1 -1
  13. package/dist/experimental/vite.js +312 -497
  14. package/dist/experimental/vite.js.map +1 -1
  15. package/dist/microfrontends/server.cjs +295 -485
  16. package/dist/microfrontends/server.cjs.map +1 -1
  17. package/dist/microfrontends/server.d.ts +14 -20
  18. package/dist/microfrontends/server.js +285 -475
  19. package/dist/microfrontends/server.js.map +1 -1
  20. package/dist/next/config.cjs +297 -498
  21. package/dist/next/config.cjs.map +1 -1
  22. package/dist/next/config.js +287 -488
  23. package/dist/next/config.js.map +1 -1
  24. package/dist/next/endpoints.cjs +2 -0
  25. package/dist/next/endpoints.cjs.map +1 -1
  26. package/dist/next/endpoints.d.ts +13 -3
  27. package/dist/next/endpoints.js +1 -0
  28. package/dist/next/endpoints.js.map +1 -1
  29. package/dist/next/middleware.cjs +58 -171
  30. package/dist/next/middleware.cjs.map +1 -1
  31. package/dist/next/middleware.d.ts +2 -4
  32. package/dist/next/middleware.js +58 -171
  33. package/dist/next/middleware.js.map +1 -1
  34. package/dist/next/testing.cjs +44 -73
  35. package/dist/next/testing.cjs.map +1 -1
  36. package/dist/next/testing.d.ts +4 -4
  37. package/dist/next/testing.js +44 -73
  38. package/dist/next/testing.js.map +1 -1
  39. package/dist/overrides.d.ts +3 -3
  40. package/dist/schema.cjs +2 -9
  41. package/dist/schema.cjs.map +1 -1
  42. package/dist/schema.d.ts +3 -4
  43. package/dist/schema.js +1 -7
  44. package/dist/schema.js.map +1 -1
  45. package/dist/{types-6ee19ccc.d.ts → types-54064641.d.ts} +2 -13
  46. package/dist/{types-73527280.d.ts → types-a4add5ab.d.ts} +1 -1
  47. package/dist/{types-74e3336c.d.ts → types-f1260e44.d.ts} +1 -1
  48. package/dist/utils/mfe-port.cjs +300 -492
  49. package/dist/utils/mfe-port.cjs.map +1 -1
  50. package/dist/utils/mfe-port.js +286 -478
  51. package/dist/utils/mfe-port.js.map +1 -1
  52. package/dist/validation.cjs +49 -37
  53. package/dist/validation.cjs.map +1 -1
  54. package/dist/validation.d.ts +1 -1
  55. package/dist/validation.js +49 -37
  56. package/dist/validation.js.map +1 -1
  57. package/package.json +2 -9
  58. package/schema/schema.json +0 -33
  59. package/dist/index-7e69650e.d.ts +0 -165
  60. package/dist/microfrontends.cjs +0 -962
  61. package/dist/microfrontends.cjs.map +0 -1
  62. package/dist/microfrontends.d.ts +0 -45
  63. package/dist/microfrontends.js +0 -935
  64. package/dist/microfrontends.js.map +0 -1
package/dist/bin/cli.cjs CHANGED
@@ -29,7 +29,7 @@ var import_commander = require("commander");
29
29
  // package.json
30
30
  var package_default = {
31
31
  name: "@vercel/microfrontends",
32
- version: "1.1.1-canary.2",
32
+ version: "1.1.1-canary.4",
33
33
  private: false,
34
34
  description: "Defines configuration and utilities for microfrontends development",
35
35
  keywords: [
@@ -62,10 +62,6 @@ var package_default = {
62
62
  import: "./dist/experimental/vite.js",
63
63
  require: "./dist/experimental/vite.cjs"
64
64
  },
65
- "./microfrontends": {
66
- import: "./dist/microfrontends.js",
67
- require: "./dist/microfrontends.cjs"
68
- },
69
65
  "./overrides": {
70
66
  import: "./dist/overrides.js",
71
67
  require: "./dist/overrides.cjs"
@@ -125,9 +121,6 @@ var package_default = {
125
121
  "experimental/vite": [
126
122
  "./dist/experimental/vite.d.ts"
127
123
  ],
128
- microfrontends: [
129
- "./dist/microfrontends.d.ts"
130
- ],
131
124
  overrides: [
132
125
  "./dist/overrides.d.ts"
133
126
  ],
@@ -216,7 +209,7 @@ var package_default = {
216
209
  tsup: "^6.6.2",
217
210
  tsx: "^4.6.2",
218
211
  typescript: "5.7.3",
219
- vite: "^5.1.6",
212
+ vite: "5.4.11",
220
213
  webpack: "5"
221
214
  },
222
215
  peerDependencies: {
@@ -261,10 +254,8 @@ var import_cookie = require("cookie");
261
254
  var import_path_to_regexp3 = require("path-to-regexp");
262
255
  var import_http_proxy = __toESM(require("http-proxy"), 1);
263
256
 
264
- // src/config/schema/utils/is-default-app.ts
265
- function isDefaultApp(a) {
266
- return !("routing" in a);
267
- }
257
+ // src/config/microfrontends-config/isomorphic/index.ts
258
+ var import_jsonc_parser = require("jsonc-parser");
268
259
 
269
260
  // src/config/errors.ts
270
261
  var MicrofrontendError = class extends Error {
@@ -358,8 +349,128 @@ var MicrofrontendError = class extends Error {
358
349
  }
359
350
  };
360
351
 
361
- // src/config/microfrontends-config/isomorphic/validation.ts
352
+ // src/config/microfrontends-config/utils/get-config-from-env.ts
353
+ function getConfigStringFromEnv() {
354
+ const config = process.env.MFE_CONFIG;
355
+ if (!config) {
356
+ throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
357
+ type: "config",
358
+ subtype: "not_found_in_env"
359
+ });
360
+ }
361
+ return config;
362
+ }
363
+
364
+ // src/config/schema/utils/is-default-app.ts
365
+ function isDefaultApp(a) {
366
+ return !("routing" in a);
367
+ }
368
+
369
+ // src/config/microfrontends-config/client/index.ts
362
370
  var import_path_to_regexp = require("path-to-regexp");
371
+ var MicrofrontendConfigClient = class {
372
+ constructor(config, opts) {
373
+ this.pathCache = {};
374
+ this.serialized = config;
375
+ if (opts?.removeFlaggedPaths) {
376
+ for (const app of Object.values(config.applications)) {
377
+ if (app.routing) {
378
+ app.routing = app.routing.filter((match) => !match.flag);
379
+ }
380
+ }
381
+ }
382
+ this.applications = config.applications;
383
+ }
384
+ /**
385
+ * Create a new `MicrofrontendConfigClient` from a JSON string.
386
+ * Config must be passed in to remain framework agnostic
387
+ */
388
+ static fromEnv(config, opts) {
389
+ if (!config) {
390
+ throw new Error("No microfrontends configuration found");
391
+ }
392
+ return new MicrofrontendConfigClient(
393
+ JSON.parse(config),
394
+ opts
395
+ );
396
+ }
397
+ isEqual(other) {
398
+ return JSON.stringify(this.applications) === JSON.stringify(other.applications);
399
+ }
400
+ getApplicationNameForPath(path7) {
401
+ if (!path7.startsWith("/")) {
402
+ throw new Error(`Path must start with a /`);
403
+ }
404
+ if (this.pathCache[path7]) {
405
+ return this.pathCache[path7];
406
+ }
407
+ const pathname = new URL(path7, "https://example.com").pathname;
408
+ for (const [name, application] of Object.entries(this.applications)) {
409
+ if (application.routing) {
410
+ for (const group of application.routing) {
411
+ for (const childPath of group.paths) {
412
+ const regexp = (0, import_path_to_regexp.pathToRegexp)(childPath);
413
+ if (regexp.test(pathname)) {
414
+ this.pathCache[path7] = name;
415
+ return name;
416
+ }
417
+ }
418
+ }
419
+ }
420
+ }
421
+ const defaultApplication = Object.entries(this.applications).find(
422
+ ([, application]) => application.default
423
+ );
424
+ if (!defaultApplication) {
425
+ return null;
426
+ }
427
+ this.pathCache[path7] = defaultApplication[0];
428
+ return defaultApplication[0];
429
+ }
430
+ serialize() {
431
+ return this.serialized;
432
+ }
433
+ };
434
+
435
+ // src/config/overrides/constants.ts
436
+ var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
437
+ var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
438
+
439
+ // src/config/overrides/is-override-cookie.ts
440
+ function isOverrideCookie(cookie) {
441
+ return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
442
+ }
443
+
444
+ // src/config/overrides/get-override-from-cookie.ts
445
+ function getOverrideFromCookie(cookie) {
446
+ if (!isOverrideCookie(cookie) || !cookie.value)
447
+ return;
448
+ return {
449
+ application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ""),
450
+ host: cookie.value
451
+ };
452
+ }
453
+
454
+ // src/config/overrides/parse-overrides.ts
455
+ function parseOverrides(cookies) {
456
+ const overridesConfig = { applications: {} };
457
+ cookies.forEach((cookie) => {
458
+ const override = getOverrideFromCookie(cookie);
459
+ if (!override)
460
+ return;
461
+ overridesConfig.applications[override.application] = {
462
+ environment: { host: override.host }
463
+ };
464
+ });
465
+ return overridesConfig;
466
+ }
467
+
468
+ // src/config/microfrontends-config/isomorphic/validation.ts
469
+ var import_path_to_regexp2 = require("path-to-regexp");
470
+ var LIST_FORMATTER = new Intl.ListFormat("en", {
471
+ style: "long",
472
+ type: "conjunction"
473
+ });
363
474
  var validateConfigPaths = (applicationConfigsById) => {
364
475
  if (!applicationConfigsById) {
365
476
  return;
@@ -383,7 +494,7 @@ var validateConfigPaths = (applicationConfigsById) => {
383
494
  } else {
384
495
  pathsByApplicationId.set(path7, {
385
496
  applications: [id],
386
- matcher: (0, import_path_to_regexp.pathToRegexp)(path7),
497
+ matcher: (0, import_path_to_regexp2.pathToRegexp)(path7),
387
498
  applicationId: id
388
499
  });
389
500
  }
@@ -430,7 +541,7 @@ var validateConfigPaths = (applicationConfigsById) => {
430
541
  var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
431
542
  function validatePathExpression(path7) {
432
543
  try {
433
- const tokens = (0, import_path_to_regexp.parse)(path7);
544
+ const tokens = (0, import_path_to_regexp2.parse)(path7);
434
545
  if (/(?<!\\)\{/.test(path7)) {
435
546
  return `Optional paths are not supported: ${path7}`;
436
547
  }
@@ -492,15 +603,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
492
603
  if (!applicationConfigsById) {
493
604
  return;
494
605
  }
495
- const applicationsWithRouting = Object.entries(applicationConfigsById).filter(
496
- ([, app]) => !isDefaultApp(app)
497
- );
498
- const applicationsWithRoutingNames = applicationsWithRouting.map(
499
- ([key]) => key
606
+ const applicationsWithoutRouting = Object.entries(
607
+ applicationConfigsById
608
+ ).filter(([, app]) => isDefaultApp(app));
609
+ const numApplicationsWithoutRouting = applicationsWithoutRouting.reduce(
610
+ (acc) => {
611
+ return acc + 1;
612
+ },
613
+ 0
500
614
  );
501
- const numApplications = Object.keys(applicationConfigsById).length;
502
- const numApplicationsWithRouting = applicationsWithRoutingNames.length;
503
- const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
504
615
  if (numApplicationsWithoutRouting === 0) {
505
616
  throw new MicrofrontendError(
506
617
  "No default application found. At least one application needs to be the default by omitting routing.",
@@ -508,8 +619,11 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
508
619
  );
509
620
  }
510
621
  if (numApplicationsWithoutRouting > 1) {
622
+ const applicationNamesMissingRouting = applicationsWithoutRouting.map(
623
+ ([name]) => name
624
+ );
511
625
  throw new MicrofrontendError(
512
- `Only one application can omit "routing". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,
626
+ `All applications except for the default app must contain the "routing" field. Applications that are missing routing: ${LIST_FORMATTER.format(applicationNamesMissingRouting)}.`,
513
627
  { type: "config", subtype: "multiple_default_applications" }
514
628
  );
515
629
  }
@@ -812,125 +926,6 @@ var ChildApplication = class extends Application {
812
926
  }
813
927
  };
814
928
 
815
- // src/config/microfrontends-config/isomorphic/index.ts
816
- var import_jsonc_parser = require("jsonc-parser");
817
-
818
- // src/config/microfrontends-config/utils/get-config-from-env.ts
819
- function getConfigStringFromEnv() {
820
- const config = process.env.MFE_CONFIG;
821
- if (!config) {
822
- throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
823
- type: "config",
824
- subtype: "not_found_in_env"
825
- });
826
- }
827
- return config;
828
- }
829
-
830
- // src/config/schema/utils/is-main-config.ts
831
- function isMainConfig(c) {
832
- return !("partOf" in c);
833
- }
834
-
835
- // src/config/microfrontends-config/client/index.ts
836
- var import_path_to_regexp2 = require("path-to-regexp");
837
- var MicrofrontendConfigClient = class {
838
- constructor(config, opts) {
839
- this.pathCache = {};
840
- this.serialized = config;
841
- if (opts?.removeFlaggedPaths) {
842
- for (const app of Object.values(config.applications)) {
843
- if (app.routing) {
844
- app.routing = app.routing.filter((match) => !match.flag);
845
- }
846
- }
847
- }
848
- this.applications = config.applications;
849
- }
850
- /**
851
- * Create a new `MicrofrontendConfigClient` from a JSON string.
852
- * Config must be passed in to remain framework agnostic
853
- */
854
- static fromEnv(config, opts) {
855
- if (!config) {
856
- throw new Error("No microfrontends configuration found");
857
- }
858
- return new MicrofrontendConfigClient(
859
- JSON.parse(config),
860
- opts
861
- );
862
- }
863
- isEqual(other) {
864
- return JSON.stringify(this.applications) === JSON.stringify(other.applications);
865
- }
866
- getApplicationNameForPath(path7) {
867
- if (!path7.startsWith("/")) {
868
- throw new Error(`Path must start with a /`);
869
- }
870
- if (this.pathCache[path7]) {
871
- return this.pathCache[path7];
872
- }
873
- const pathname = new URL(path7, "https://example.com").pathname;
874
- for (const [name, application] of Object.entries(this.applications)) {
875
- if (application.routing) {
876
- for (const group of application.routing) {
877
- for (const childPath of group.paths) {
878
- const regexp = (0, import_path_to_regexp2.pathToRegexp)(childPath);
879
- if (regexp.test(pathname)) {
880
- this.pathCache[path7] = name;
881
- return name;
882
- }
883
- }
884
- }
885
- }
886
- }
887
- const defaultApplication = Object.entries(this.applications).find(
888
- ([, application]) => application.default
889
- );
890
- if (!defaultApplication) {
891
- return null;
892
- }
893
- this.pathCache[path7] = defaultApplication[0];
894
- return defaultApplication[0];
895
- }
896
- serialize() {
897
- return this.serialized;
898
- }
899
- };
900
-
901
- // src/config/overrides/constants.ts
902
- var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
903
- var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
904
-
905
- // src/config/overrides/is-override-cookie.ts
906
- function isOverrideCookie(cookie) {
907
- return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
908
- }
909
-
910
- // src/config/overrides/get-override-from-cookie.ts
911
- function getOverrideFromCookie(cookie) {
912
- if (!isOverrideCookie(cookie) || !cookie.value)
913
- return;
914
- return {
915
- application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ""),
916
- host: cookie.value
917
- };
918
- }
919
-
920
- // src/config/overrides/parse-overrides.ts
921
- function parseOverrides(cookies) {
922
- const overridesConfig = { applications: {} };
923
- cookies.forEach((cookie) => {
924
- const override = getOverrideFromCookie(cookie);
925
- if (!override)
926
- return;
927
- overridesConfig.applications[override.application] = {
928
- environment: { host: override.host }
929
- };
930
- });
931
- return overridesConfig;
932
- }
933
-
934
929
  // src/config/microfrontends-config/isomorphic/constants.ts
935
930
  var DEFAULT_LOCAL_PROXY_PORT = 3024;
936
931
 
@@ -939,42 +934,28 @@ var MicrofrontendConfigIsomorphic = class {
939
934
  constructor({
940
935
  config,
941
936
  overrides,
942
- meta,
943
937
  opts
944
938
  }) {
945
939
  this.childApplications = {};
946
940
  MicrofrontendConfigIsomorphic.validate(config, opts);
947
941
  const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
948
942
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
949
- this.isMainConfig = isMainConfig(config);
950
- if (isMainConfig(config)) {
951
- for (const [appId, appConfig] of Object.entries(config.applications)) {
952
- const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
953
- if (isDefaultApp(appConfig)) {
954
- this.defaultApplication = new DefaultApplication(appId, {
955
- app: appConfig,
956
- overrides: appOverrides
957
- });
958
- } else {
959
- this.childApplications[appId] = new ChildApplication(appId, {
960
- app: appConfig,
961
- overrides: appOverrides
962
- });
963
- }
964
- }
965
- } else {
966
- this.partOf = config.partOf;
967
- const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
968
- this.childApplications[meta.fromApp] = new ChildApplication(
969
- meta.fromApp,
970
- {
971
- // we don't know routing because we're not in the main config
972
- app: { routing: [] },
943
+ let defaultApplication;
944
+ for (const [appId, appConfig] of Object.entries(config.applications)) {
945
+ const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
946
+ if (isDefaultApp(appConfig)) {
947
+ defaultApplication = new DefaultApplication(appId, {
948
+ app: appConfig,
973
949
  overrides: appOverrides
974
- }
975
- );
950
+ });
951
+ } else {
952
+ this.childApplications[appId] = new ChildApplication(appId, {
953
+ app: appConfig,
954
+ overrides: appOverrides
955
+ });
956
+ }
976
957
  }
977
- if (isMainConfig(config) && !this.defaultApplication) {
958
+ if (!defaultApplication) {
978
959
  throw new MicrofrontendError(
979
960
  "Could not find default application in microfrontends configuration",
980
961
  {
@@ -983,34 +964,30 @@ var MicrofrontendConfigIsomorphic = class {
983
964
  }
984
965
  );
985
966
  }
967
+ this.defaultApplication = defaultApplication;
986
968
  this.config = config;
987
969
  this.options = config.options;
988
970
  this.serialized = {
989
971
  config,
990
- overrides,
991
- meta
972
+ overrides
992
973
  };
993
974
  }
994
975
  static validate(config, opts) {
995
976
  const skipValidation = opts?.skipValidation ?? [];
996
977
  const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
997
- if (isMainConfig(c)) {
998
- validateConfigPaths(c.applications);
999
- validateConfigDefaultApplication(c.applications);
1000
- if (!skipValidation.includes("deprecatedFields")) {
1001
- validateDeprecatedFields(c);
1002
- }
978
+ validateConfigPaths(c.applications);
979
+ validateConfigDefaultApplication(c.applications);
980
+ if (!skipValidation.includes("deprecatedFields")) {
981
+ validateDeprecatedFields(c);
1003
982
  }
1004
983
  return c;
1005
984
  }
1006
985
  static fromEnv({
1007
- meta,
1008
986
  cookies
1009
987
  }) {
1010
988
  return new MicrofrontendConfigIsomorphic({
1011
989
  config: (0, import_jsonc_parser.parse)(getConfigStringFromEnv()),
1012
- overrides: parseOverrides(cookies ?? []),
1013
- meta
990
+ overrides: parseOverrides(cookies ?? [])
1014
991
  });
1015
992
  }
1016
993
  isOverridesDisabled() {
@@ -1035,7 +1012,7 @@ var MicrofrontendConfigIsomorphic = class {
1035
1012
  ].filter(Boolean);
1036
1013
  }
1037
1014
  getApplication(name) {
1038
- if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
1015
+ if (this.defaultApplication.name === name || this.defaultApplication.packageName === name) {
1039
1016
  return this.defaultApplication;
1040
1017
  }
1041
1018
  const app = this.childApplications[name] || Object.values(this.childApplications).find(
@@ -1053,7 +1030,7 @@ var MicrofrontendConfigIsomorphic = class {
1053
1030
  return app;
1054
1031
  }
1055
1032
  getApplicationByProjectId(projectId) {
1056
- if (this.defaultApplication?.projectId === projectId) {
1033
+ if (this.defaultApplication.projectId === projectId) {
1057
1034
  return this.defaultApplication;
1058
1035
  }
1059
1036
  return Object.values(this.childApplications).find(
@@ -1061,19 +1038,9 @@ var MicrofrontendConfigIsomorphic = class {
1061
1038
  );
1062
1039
  }
1063
1040
  /**
1064
- * Returns the default application. This can throw if the default application
1065
- * is undefined ( )
1041
+ * Returns the default application.
1066
1042
  */
1067
1043
  getDefaultApplication() {
1068
- if (!this.defaultApplication) {
1069
- throw new MicrofrontendError(
1070
- "Could not find default application in microfrontends configuration",
1071
- {
1072
- type: "application",
1073
- subtype: "not_found"
1074
- }
1075
- );
1076
- }
1077
1044
  return this.defaultApplication;
1078
1045
  }
1079
1046
  /**
@@ -1100,11 +1067,9 @@ var MicrofrontendConfigIsomorphic = class {
1100
1067
  }
1101
1068
  ])
1102
1069
  );
1103
- if (this.defaultApplication) {
1104
- applications[this.defaultApplication.name] = {
1105
- default: true
1106
- };
1107
- }
1070
+ applications[this.defaultApplication.name] = {
1071
+ default: true
1072
+ };
1108
1073
  return new MicrofrontendConfigClient({
1109
1074
  applications
1110
1075
  });
@@ -1114,106 +1079,28 @@ var MicrofrontendConfigIsomorphic = class {
1114
1079
  }
1115
1080
  };
1116
1081
 
1117
- // src/config/microfrontends-config/isomorphic/main.ts
1118
- var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1119
- constructor({
1120
- config,
1121
- overrides,
1122
- meta
1123
- }) {
1124
- super({ config, overrides, meta });
1125
- this.isMainConfig = true;
1126
- const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
1127
- let defaultApplication;
1128
- for (const [appId, appConfig] of Object.entries(config.applications)) {
1129
- const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
1130
- if (isDefaultApp(appConfig)) {
1131
- defaultApplication = new DefaultApplication(appId, {
1132
- app: appConfig,
1133
- overrides: appOverrides
1134
- });
1135
- } else {
1136
- this.childApplications[appId] = new ChildApplication(appId, {
1137
- app: appConfig,
1138
- overrides: appOverrides
1139
- });
1140
- }
1141
- }
1142
- if (!defaultApplication) {
1143
- throw new MicrofrontendError(
1144
- "Could not find default application in microfrontends configuration",
1145
- {
1146
- type: "application",
1147
- subtype: "not_found"
1148
- }
1149
- );
1150
- }
1151
- this.defaultApplication = defaultApplication;
1152
- }
1153
- };
1154
-
1155
- // src/config/microfrontends/utils/is-main-config.ts
1156
- function isMainConfig2(c) {
1157
- return !("partOf" in c);
1158
- }
1159
-
1160
1082
  // src/config/microfrontends/server/index.ts
1161
- var import_node_fs8 = __toESM(require("fs"), 1);
1162
- var import_node_path9 = require("path");
1163
-
1164
- // src/config/microfrontends-config/isomorphic/child.ts
1165
- var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
1166
- constructor({
1167
- config,
1168
- overrides,
1169
- meta
1170
- }) {
1171
- super({ config, overrides, meta });
1172
- this.isMainConfig = false;
1173
- this.partOf = config.partOf;
1174
- }
1175
- };
1176
-
1177
- // src/config/microfrontends/isomorphic/index.ts
1178
- var Microfrontends = class {
1179
- constructor({
1180
- config,
1181
- overrides,
1182
- meta
1183
- }) {
1184
- if (isMainConfig(config)) {
1185
- this.config = new MicrofrontendMainConfig({ config, overrides, meta });
1186
- } else {
1187
- this.config = new MicrofrontendChildConfig({ config, overrides, meta });
1188
- }
1189
- }
1190
- isChildConfig() {
1191
- return this.config instanceof MicrofrontendChildConfig;
1192
- }
1193
- static fromEnv({
1194
- cookies,
1195
- meta
1196
- }) {
1197
- const config = MicrofrontendConfigIsomorphic.fromEnv({
1198
- cookies,
1199
- meta
1200
- });
1201
- return new Microfrontends(config.serialize());
1202
- }
1203
- };
1083
+ var import_node_fs7 = __toESM(require("fs"), 1);
1084
+ var import_node_path8 = require("path");
1204
1085
 
1205
1086
  // src/config/microfrontends/utils/find-repository-root.ts
1206
1087
  var import_node_fs = __toESM(require("fs"), 1);
1207
1088
  var import_node_path = __toESM(require("path"), 1);
1208
1089
  var GIT_DIRECTORY = ".git";
1090
+ function hasGitDirectory(dir) {
1091
+ const gitPath = import_node_path.default.join(dir, GIT_DIRECTORY);
1092
+ return import_node_fs.default.existsSync(gitPath) && import_node_fs.default.statSync(gitPath).isDirectory();
1093
+ }
1094
+ function hasPnpmWorkspaces(dir) {
1095
+ return import_node_fs.default.existsSync(import_node_path.default.join(dir, "pnpm-workspace.yaml"));
1096
+ }
1209
1097
  function findRepositoryRoot(startDir) {
1210
1098
  if (process.env.NX_WORKSPACE_ROOT) {
1211
1099
  return process.env.NX_WORKSPACE_ROOT;
1212
1100
  }
1213
1101
  let currentDir = startDir || process.cwd();
1214
1102
  while (currentDir !== import_node_path.default.parse(currentDir).root) {
1215
- const gitPath = import_node_path.default.join(currentDir, GIT_DIRECTORY);
1216
- if (import_node_fs.default.existsSync(gitPath) && import_node_fs.default.statSync(gitPath).isDirectory()) {
1103
+ if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
1217
1104
  return currentDir;
1218
1105
  }
1219
1106
  currentDir = import_node_path.default.dirname(currentDir);
@@ -1223,67 +1110,11 @@ function findRepositoryRoot(startDir) {
1223
1110
  );
1224
1111
  }
1225
1112
 
1226
- // src/config/microfrontends/utils/find-package-path.ts
1113
+ // src/config/microfrontends/utils/find-default-package.ts
1227
1114
  var import_node_path2 = require("path");
1228
1115
  var import_node_fs2 = require("fs");
1229
- var import_fast_glob = __toESM(require("fast-glob"), 1);
1230
- var configCache = {};
1231
- function findPackagePathWithGlob({
1232
- repositoryRoot,
1233
- name
1234
- }) {
1235
- try {
1236
- const packageJsonPaths = import_fast_glob.default.globSync("**/package.json", {
1237
- cwd: repositoryRoot,
1238
- absolute: true,
1239
- onlyFiles: true,
1240
- followSymbolicLinks: false,
1241
- ignore: ["**/node_modules/**", "**/.git/**"]
1242
- });
1243
- const matchingPaths = [];
1244
- for (const packageJsonPath2 of packageJsonPaths) {
1245
- const packageJsonContent = (0, import_node_fs2.readFileSync)(packageJsonPath2, "utf-8");
1246
- const packageJson = JSON.parse(packageJsonContent);
1247
- if (packageJson.name === name) {
1248
- matchingPaths.push(packageJsonPath2);
1249
- }
1250
- }
1251
- if (matchingPaths.length > 1) {
1252
- throw new Error(
1253
- `Found multiple packages with the name "${name}" in the repository: ${matchingPaths.join(", ")}`
1254
- );
1255
- }
1256
- if (matchingPaths.length === 0) {
1257
- throw new Error(
1258
- `Could not find package with the name "${name}" in the repository`
1259
- );
1260
- }
1261
- const [packageJsonPath] = matchingPaths;
1262
- return (0, import_node_path2.dirname)(packageJsonPath);
1263
- } catch (error) {
1264
- return null;
1265
- }
1266
- }
1267
- function findPackagePath(opts) {
1268
- const cacheKey = `${opts.repositoryRoot}-${opts.name}`;
1269
- if (configCache[cacheKey]) {
1270
- return configCache[cacheKey];
1271
- }
1272
- const result = findPackagePathWithGlob(opts);
1273
- if (!result) {
1274
- throw new Error(
1275
- `Could not find package with the name "${opts.name}" in the repository`
1276
- );
1277
- }
1278
- configCache[cacheKey] = result;
1279
- return result;
1280
- }
1281
-
1282
- // src/config/microfrontends/utils/find-default-package.ts
1283
- var import_node_path3 = require("path");
1284
- var import_node_fs3 = require("fs");
1285
1116
  var import_jsonc_parser2 = require("jsonc-parser");
1286
- var import_fast_glob2 = __toESM(require("fast-glob"), 1);
1117
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
1287
1118
 
1288
1119
  // src/config/constants.ts
1289
1120
  var CONFIGURATION_FILENAMES = [
@@ -1292,13 +1123,13 @@ var CONFIGURATION_FILENAMES = [
1292
1123
  ];
1293
1124
 
1294
1125
  // src/config/microfrontends/utils/find-default-package.ts
1295
- var configCache2 = {};
1126
+ var configCache = {};
1296
1127
  function findDefaultMicrofrontendsPackages({
1297
1128
  repositoryRoot,
1298
1129
  applicationName
1299
1130
  }) {
1300
1131
  try {
1301
- const microfrontendsJsonPaths = import_fast_glob2.default.globSync(
1132
+ const microfrontendsJsonPaths = import_fast_glob.default.globSync(
1302
1133
  `**/{${CONFIGURATION_FILENAMES.join(",")}}`,
1303
1134
  {
1304
1135
  cwd: repositoryRoot,
@@ -1311,12 +1142,12 @@ function findDefaultMicrofrontendsPackages({
1311
1142
  const matchingPaths = [];
1312
1143
  for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
1313
1144
  try {
1314
- const microfrontendsJsonContent = (0, import_node_fs3.readFileSync)(
1145
+ const microfrontendsJsonContent = (0, import_node_fs2.readFileSync)(
1315
1146
  microfrontendsJsonPath,
1316
1147
  "utf-8"
1317
1148
  );
1318
1149
  const microfrontendsJson = (0, import_jsonc_parser2.parse)(microfrontendsJsonContent);
1319
- if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
1150
+ if (microfrontendsJson.applications[applicationName]) {
1320
1151
  matchingPaths.push(microfrontendsJsonPath);
1321
1152
  }
1322
1153
  } catch (error) {
@@ -1324,7 +1155,7 @@ function findDefaultMicrofrontendsPackages({
1324
1155
  }
1325
1156
  if (matchingPaths.length > 1) {
1326
1157
  throw new Error(
1327
- `Found multiple default applications referencing "${applicationName}" in the repository, this is not yet supported.
1158
+ `Found multiple default applications referencing "${applicationName}" in the repository, but only one is allowed.
1328
1159
  ${matchingPaths.join("\n \u2022 ")}`
1329
1160
  );
1330
1161
  }
@@ -1334,15 +1165,15 @@ ${matchingPaths.join("\n \u2022 ")}`
1334
1165
  );
1335
1166
  }
1336
1167
  const [packageJsonPath] = matchingPaths;
1337
- return (0, import_node_path3.dirname)(packageJsonPath);
1168
+ return (0, import_node_path2.dirname)(packageJsonPath);
1338
1169
  } catch (error) {
1339
1170
  return null;
1340
1171
  }
1341
1172
  }
1342
1173
  function findDefaultMicrofrontendsPackage(opts) {
1343
1174
  const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
1344
- if (configCache2[cacheKey]) {
1345
- return configCache2[cacheKey];
1175
+ if (configCache[cacheKey]) {
1176
+ return configCache[cacheKey];
1346
1177
  }
1347
1178
  const result = findDefaultMicrofrontendsPackages(opts);
1348
1179
  if (!result) {
@@ -1350,32 +1181,32 @@ function findDefaultMicrofrontendsPackage(opts) {
1350
1181
  "Error trying to resolve the main microfrontends configuration"
1351
1182
  );
1352
1183
  }
1353
- configCache2[cacheKey] = result;
1184
+ configCache[cacheKey] = result;
1354
1185
  return result;
1355
1186
  }
1356
1187
 
1357
1188
  // src/config/microfrontends/utils/is-monorepo.ts
1358
- var import_node_fs4 = __toESM(require("fs"), 1);
1359
- var import_node_path4 = __toESM(require("path"), 1);
1189
+ var import_node_fs3 = __toESM(require("fs"), 1);
1190
+ var import_node_path3 = __toESM(require("path"), 1);
1360
1191
  function isMonorepo({
1361
1192
  repositoryRoot
1362
1193
  }) {
1363
1194
  try {
1364
- if (import_node_fs4.default.existsSync(import_node_path4.default.join(repositoryRoot, "pnpm-workspace.yaml"))) {
1195
+ if (import_node_fs3.default.existsSync(import_node_path3.default.join(repositoryRoot, "pnpm-workspace.yaml"))) {
1365
1196
  return true;
1366
1197
  }
1367
- if (import_node_fs4.default.existsSync(import_node_path4.default.join(repositoryRoot, "vlt-workspaces.json"))) {
1198
+ if (import_node_fs3.default.existsSync(import_node_path3.default.join(repositoryRoot, "vlt-workspaces.json"))) {
1368
1199
  return true;
1369
1200
  }
1370
- if (process.env.NX_WORKSPACE_ROOT === import_node_path4.default.resolve(repositoryRoot)) {
1201
+ if (process.env.NX_WORKSPACE_ROOT === import_node_path3.default.resolve(repositoryRoot)) {
1371
1202
  return true;
1372
1203
  }
1373
- const packageJsonPath = import_node_path4.default.join(repositoryRoot, "package.json");
1374
- if (!import_node_fs4.default.existsSync(packageJsonPath)) {
1204
+ const packageJsonPath = import_node_path3.default.join(repositoryRoot, "package.json");
1205
+ if (!import_node_fs3.default.existsSync(packageJsonPath)) {
1375
1206
  return false;
1376
1207
  }
1377
1208
  const packageJson = JSON.parse(
1378
- import_node_fs4.default.readFileSync(packageJsonPath, "utf-8")
1209
+ import_node_fs3.default.readFileSync(packageJsonPath, "utf-8")
1379
1210
  );
1380
1211
  return packageJson.workspaces !== void 0;
1381
1212
  } catch (error) {
@@ -1385,17 +1216,17 @@ function isMonorepo({
1385
1216
  }
1386
1217
 
1387
1218
  // src/config/microfrontends/utils/find-package-root.ts
1388
- var import_node_fs5 = __toESM(require("fs"), 1);
1389
- var import_node_path5 = __toESM(require("path"), 1);
1219
+ var import_node_fs4 = __toESM(require("fs"), 1);
1220
+ var import_node_path4 = __toESM(require("path"), 1);
1390
1221
  var PACKAGE_JSON = "package.json";
1391
1222
  function findPackageRoot(startDir) {
1392
1223
  let currentDir = startDir || process.cwd();
1393
- while (currentDir !== import_node_path5.default.parse(currentDir).root) {
1394
- const pkgJsonPath = import_node_path5.default.join(currentDir, PACKAGE_JSON);
1395
- if (import_node_fs5.default.existsSync(pkgJsonPath)) {
1224
+ while (currentDir !== import_node_path4.default.parse(currentDir).root) {
1225
+ const pkgJsonPath = import_node_path4.default.join(currentDir, PACKAGE_JSON);
1226
+ if (import_node_fs4.default.existsSync(pkgJsonPath)) {
1396
1227
  return currentDir;
1397
1228
  }
1398
- currentDir = import_node_path5.default.dirname(currentDir);
1229
+ currentDir = import_node_path4.default.dirname(currentDir);
1399
1230
  }
1400
1231
  throw new Error(
1401
1232
  "Package root not found. Specify the root of the package with the `package.root` option."
@@ -1403,12 +1234,12 @@ function findPackageRoot(startDir) {
1403
1234
  }
1404
1235
 
1405
1236
  // src/config/microfrontends/utils/find-config.ts
1406
- var import_node_fs6 = __toESM(require("fs"), 1);
1407
- var import_node_path6 = require("path");
1237
+ var import_node_fs5 = __toESM(require("fs"), 1);
1238
+ var import_node_path5 = require("path");
1408
1239
  function findConfig({ dir }) {
1409
1240
  for (const filename of CONFIGURATION_FILENAMES) {
1410
- const maybeConfig = (0, import_node_path6.join)(dir, filename);
1411
- if (import_node_fs6.default.existsSync(maybeConfig)) {
1241
+ const maybeConfig = (0, import_node_path5.join)(dir, filename);
1242
+ if (import_node_fs5.default.existsSync(maybeConfig)) {
1412
1243
  return maybeConfig;
1413
1244
  }
1414
1245
  }
@@ -1416,8 +1247,8 @@ function findConfig({ dir }) {
1416
1247
  }
1417
1248
 
1418
1249
  // src/config/microfrontends/utils/get-application-context.ts
1419
- var import_node_fs7 = __toESM(require("fs"), 1);
1420
- var import_node_path7 = __toESM(require("path"), 1);
1250
+ var import_node_fs6 = __toESM(require("fs"), 1);
1251
+ var import_node_path6 = __toESM(require("path"), 1);
1421
1252
  function getApplicationContext(opts) {
1422
1253
  if (opts?.appName) {
1423
1254
  return { name: opts.appName };
@@ -1426,8 +1257,8 @@ function getApplicationContext(opts) {
1426
1257
  return { name: process.env.NX_TASK_TARGET_PROJECT };
1427
1258
  }
1428
1259
  try {
1429
- const packageJsonString = import_node_fs7.default.readFileSync(
1430
- import_node_path7.default.join(opts?.packageRoot || ".", "package.json"),
1260
+ const packageJsonString = import_node_fs6.default.readFileSync(
1261
+ import_node_path6.default.join(opts?.packageRoot || ".", "package.json"),
1431
1262
  "utf-8"
1432
1263
  );
1433
1264
  const packageJson = JSON.parse(packageJsonString);
@@ -1450,7 +1281,7 @@ function getApplicationContext(opts) {
1450
1281
  }
1451
1282
 
1452
1283
  // src/config/microfrontends/server/utils/get-output-file-path.ts
1453
- var import_node_path8 = __toESM(require("path"), 1);
1284
+ var import_node_path7 = __toESM(require("path"), 1);
1454
1285
 
1455
1286
  // src/config/microfrontends/server/constants.ts
1456
1287
  var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
@@ -1458,7 +1289,7 @@ var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
1458
1289
 
1459
1290
  // src/config/microfrontends/server/utils/get-output-file-path.ts
1460
1291
  function getOutputFilePath() {
1461
- return import_node_path8.default.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1292
+ return import_node_path7.default.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1462
1293
  }
1463
1294
 
1464
1295
  // src/config/microfrontends/server/validation.ts
@@ -1471,16 +1302,6 @@ var schema_default = {
1471
1302
  $ref: "#/definitions/Config",
1472
1303
  definitions: {
1473
1304
  Config: {
1474
- anyOf: [
1475
- {
1476
- $ref: "#/definitions/MainConfig"
1477
- },
1478
- {
1479
- $ref: "#/definitions/ChildConfig"
1480
- }
1481
- ]
1482
- },
1483
- MainConfig: {
1484
1305
  type: "object",
1485
1306
  properties: {
1486
1307
  $schema: {
@@ -1737,27 +1558,6 @@ var schema_default = {
1737
1558
  },
1738
1559
  required: ["paths"],
1739
1560
  additionalProperties: false
1740
- },
1741
- ChildConfig: {
1742
- type: "object",
1743
- properties: {
1744
- $schema: {
1745
- type: "string"
1746
- },
1747
- version: {
1748
- type: "string",
1749
- const: "1"
1750
- },
1751
- options: {
1752
- $ref: "#/definitions/Options"
1753
- },
1754
- partOf: {
1755
- type: "string",
1756
- description: "Applications that only serve a subset of the microfrontend routes only need to reference the name of the primary application that owns the full microfrontends configuration."
1757
- }
1758
- },
1759
- required: ["partOf"],
1760
- additionalProperties: false
1761
1561
  }
1762
1562
  }
1763
1563
  };
@@ -1766,13 +1566,54 @@ var schema_default = {
1766
1566
  var SCHEMA = schema_default;
1767
1567
 
1768
1568
  // src/config/microfrontends/server/validation.ts
1769
- function filterAjvErrors(errors) {
1569
+ var LIST_FORMATTER2 = new Intl.ListFormat("en", {
1570
+ style: "long",
1571
+ type: "disjunction"
1572
+ });
1573
+ function formatAjvErrors(errors) {
1770
1574
  if (!errors) {
1771
1575
  return [];
1772
1576
  }
1773
- return errors.filter((error) => {
1774
- return error.keyword === "additionalProperties" || error.keyword === "required";
1775
- });
1577
+ const errorMessages = [];
1578
+ for (const error of errors) {
1579
+ if (error.instancePath === "" && (error.keyword === "anyOf" || error.keyword === "required" && error.params.missingProperty === "partOf")) {
1580
+ continue;
1581
+ }
1582
+ const instancePath = error.instancePath.slice(1);
1583
+ const formattedInstancePath = instancePath === "" ? "at the root" : `in field ${instancePath}`;
1584
+ if (error.keyword === "required" && error.params.missingProperty === "routing" && instancePath.split("/").length === 2) {
1585
+ errorMessages.push(
1586
+ `Unable to infer if ${instancePath} is the default app or a child app. This usually means that there is another error in the configuration.`
1587
+ );
1588
+ } else if (error.keyword === "anyOf" && instancePath.split("/").length > 2) {
1589
+ const anyOfErrors = errors.filter(
1590
+ (e) => e.instancePath === error.instancePath && e.keyword !== "anyOf"
1591
+ );
1592
+ if (anyOfErrors.every((e) => e.keyword === "type")) {
1593
+ const allowedTypes = LIST_FORMATTER2.format(
1594
+ anyOfErrors.map((e) => {
1595
+ return e.keyword === "type" ? String(e.params.type) : "unknown";
1596
+ })
1597
+ );
1598
+ errorMessages.push(
1599
+ `Incorrect type for ${instancePath}. Must be one of ${allowedTypes}`
1600
+ );
1601
+ } else {
1602
+ errorMessages.push(
1603
+ `Invalid field for ${instancePath}. Possible error messages are ${LIST_FORMATTER2.format(anyOfErrors.map((e) => e.message ?? ""))}`
1604
+ );
1605
+ }
1606
+ } else if (error.keyword === "additionalProperties" && !(error.params.additionalProperty === "routing" && instancePath.split("/").length === 2)) {
1607
+ errorMessages.push(
1608
+ `Property '${error.params.additionalProperty}' is not allowed ${formattedInstancePath}`
1609
+ );
1610
+ } else if (error.keyword === "required") {
1611
+ errorMessages.push(
1612
+ `Property '${error.params.missingProperty}' is required ${formattedInstancePath}`
1613
+ );
1614
+ }
1615
+ }
1616
+ return errorMessages;
1776
1617
  }
1777
1618
  function validateSchema(configString) {
1778
1619
  const parsedConfig = (0, import_jsonc_parser3.parse)(configString);
@@ -1781,8 +1622,10 @@ function validateSchema(configString) {
1781
1622
  const isValid = validate(parsedConfig);
1782
1623
  if (!isValid) {
1783
1624
  throw new MicrofrontendError(
1784
- `Invalid microfrontends config:
1785
- - ${ajv.errorsText(filterAjvErrors(validate.errors), { separator: "\n - " })}
1625
+ `Invalid microfrontends config:${formatAjvErrors(validate.errors).map((error) => `
1626
+ - ${error}`).join(
1627
+ ""
1628
+ )}
1786
1629
 
1787
1630
  See https://openapi.vercel.sh/microfrontends.json for the schema.`,
1788
1631
  { type: "config", subtype: "does_not_match_schema" }
@@ -1792,7 +1635,13 @@ See https://openapi.vercel.sh/microfrontends.json for the schema.`,
1792
1635
  }
1793
1636
 
1794
1637
  // src/config/microfrontends/server/index.ts
1795
- var MicrofrontendsServer = class extends Microfrontends {
1638
+ var MicrofrontendsServer = class {
1639
+ constructor({
1640
+ config,
1641
+ overrides
1642
+ }) {
1643
+ this.config = new MicrofrontendConfigIsomorphic({ config, overrides });
1644
+ }
1796
1645
  /**
1797
1646
  * Writes the configuration to a file.
1798
1647
  */
@@ -1800,8 +1649,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1800
1649
  pretty: true
1801
1650
  }) {
1802
1651
  const outputPath = getOutputFilePath();
1803
- import_node_fs8.default.mkdirSync((0, import_node_path9.dirname)(outputPath), { recursive: true });
1804
- import_node_fs8.default.writeFileSync(
1652
+ import_node_fs7.default.mkdirSync((0, import_node_path8.dirname)(outputPath), { recursive: true });
1653
+ import_node_fs7.default.writeFileSync(
1805
1654
  outputPath,
1806
1655
  JSON.stringify(
1807
1656
  this.config.toSchemaJson(),
@@ -1816,22 +1665,19 @@ var MicrofrontendsServer = class extends Microfrontends {
1816
1665
  */
1817
1666
  static fromUnknown({
1818
1667
  config,
1819
- cookies,
1820
- meta
1668
+ cookies
1821
1669
  }) {
1822
1670
  const overrides = cookies ? parseOverrides(cookies) : void 0;
1823
1671
  if (typeof config === "string") {
1824
1672
  return new MicrofrontendsServer({
1825
1673
  config: MicrofrontendsServer.validate(config),
1826
- overrides,
1827
- meta
1674
+ overrides
1828
1675
  });
1829
1676
  }
1830
1677
  if (typeof config === "object") {
1831
1678
  return new MicrofrontendsServer({
1832
1679
  config,
1833
- overrides,
1834
- meta
1680
+ overrides
1835
1681
  });
1836
1682
  }
1837
1683
  throw new MicrofrontendError(
@@ -1844,13 +1690,11 @@ var MicrofrontendsServer = class extends Microfrontends {
1844
1690
  * Uses additional validation that is only available when in a node runtime
1845
1691
  */
1846
1692
  static fromEnv({
1847
- cookies,
1848
- meta
1693
+ cookies
1849
1694
  }) {
1850
1695
  return new MicrofrontendsServer({
1851
1696
  config: MicrofrontendsServer.validate(getConfigStringFromEnv()),
1852
- overrides: parseOverrides(cookies),
1853
- meta
1697
+ overrides: parseOverrides(cookies)
1854
1698
  });
1855
1699
  }
1856
1700
  /**
@@ -1873,29 +1717,22 @@ var MicrofrontendsServer = class extends Microfrontends {
1873
1717
  static infer({
1874
1718
  directory,
1875
1719
  filePath,
1876
- meta,
1877
- cookies,
1878
- options
1720
+ cookies
1879
1721
  } = {}) {
1880
- if (filePath && meta) {
1722
+ if (filePath) {
1881
1723
  return MicrofrontendsServer.fromFile({
1882
1724
  filePath,
1883
- cookies,
1884
- meta,
1885
- options
1725
+ cookies
1886
1726
  });
1887
1727
  }
1888
1728
  try {
1889
1729
  const packageRoot = findPackageRoot(directory);
1890
1730
  const { name: appName } = getApplicationContext({ packageRoot });
1891
- const configMeta = meta ?? { fromApp: appName };
1892
1731
  const maybeConfig = findConfig({ dir: packageRoot });
1893
1732
  if (maybeConfig) {
1894
1733
  return MicrofrontendsServer.fromFile({
1895
1734
  filePath: maybeConfig,
1896
- cookies,
1897
- meta: configMeta,
1898
- options
1735
+ cookies
1899
1736
  });
1900
1737
  }
1901
1738
  const repositoryRoot = findRepositoryRoot();
@@ -1909,14 +1746,15 @@ var MicrofrontendsServer = class extends Microfrontends {
1909
1746
  if (maybeConfigFromDefault) {
1910
1747
  return MicrofrontendsServer.fromFile({
1911
1748
  filePath: maybeConfigFromDefault,
1912
- cookies,
1913
- meta: configMeta,
1914
- options
1749
+ cookies
1915
1750
  });
1916
1751
  }
1917
1752
  }
1918
1753
  throw new Error("Unable to infer");
1919
1754
  } catch (e) {
1755
+ if (e instanceof MicrofrontendError) {
1756
+ throw e;
1757
+ }
1920
1758
  throw new MicrofrontendError(
1921
1759
  "Unable to locate and parse microfrontends configuration",
1922
1760
  { cause: e, type: "config", subtype: "inference_failed" }
@@ -1928,44 +1766,14 @@ var MicrofrontendsServer = class extends Microfrontends {
1928
1766
  */
1929
1767
  static fromFile({
1930
1768
  filePath,
1931
- cookies,
1932
- meta,
1933
- options
1769
+ cookies
1934
1770
  }) {
1935
1771
  try {
1936
- const configJson = import_node_fs8.default.readFileSync(filePath, "utf-8");
1772
+ const configJson = import_node_fs7.default.readFileSync(filePath, "utf-8");
1937
1773
  const config = MicrofrontendsServer.validate(configJson);
1938
- if (!isMainConfig(config) && options?.resolveMainConfig) {
1939
- const repositoryRoot = findRepositoryRoot();
1940
- const isMonorepo2 = isMonorepo({ repositoryRoot });
1941
- if (isMonorepo2) {
1942
- const packagePath = findPackagePath({
1943
- repositoryRoot,
1944
- name: config.partOf
1945
- });
1946
- if (!packagePath) {
1947
- throw new MicrofrontendError(
1948
- `Could not find default application "${config.partOf}" in the repository`,
1949
- { type: "config", subtype: "not_found" }
1950
- );
1951
- }
1952
- const maybeConfig = findConfig({ dir: packagePath });
1953
- if (!maybeConfig) {
1954
- throw new MicrofrontendError(
1955
- `Could not find microfrontends configuration in ${packagePath}`,
1956
- { type: "config", subtype: "not_found" }
1957
- );
1958
- }
1959
- return MicrofrontendsServer.fromMainConfigFile({
1960
- filePath: maybeConfig,
1961
- overrides: cookies ? parseOverrides(cookies) : void 0
1962
- });
1963
- }
1964
- }
1965
1774
  return new MicrofrontendsServer({
1966
1775
  config,
1967
- overrides: cookies ? parseOverrides(cookies) : void 0,
1968
- meta
1776
+ overrides: cookies ? parseOverrides(cookies) : void 0
1969
1777
  });
1970
1778
  } catch (e) {
1971
1779
  throw MicrofrontendError.handle(e, {
@@ -1974,24 +1782,15 @@ var MicrofrontendsServer = class extends Microfrontends {
1974
1782
  }
1975
1783
  }
1976
1784
  /*
1977
- * Generates a MicrofrontendMainConfig instance from a file.
1785
+ * Generates a MicrofrontendsServer instance from a file.
1978
1786
  */
1979
1787
  static fromMainConfigFile({
1980
1788
  filePath,
1981
1789
  overrides
1982
1790
  }) {
1983
1791
  try {
1984
- const config = import_node_fs8.default.readFileSync(filePath, "utf-8");
1792
+ const config = import_node_fs7.default.readFileSync(filePath, "utf-8");
1985
1793
  const validatedConfig = MicrofrontendsServer.validate(config);
1986
- if (!isMainConfig(validatedConfig)) {
1987
- throw new MicrofrontendError(
1988
- `${filePath} is not a main microfrontend config`,
1989
- {
1990
- type: "config",
1991
- subtype: "invalid_main_path"
1992
- }
1993
- );
1994
- }
1995
1794
  const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
1996
1795
  if (!defaultApplication) {
1997
1796
  throw new MicrofrontendError(
@@ -2001,8 +1800,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2001
1800
  }
2002
1801
  return new MicrofrontendsServer({
2003
1802
  config: validatedConfig,
2004
- overrides,
2005
- meta: { fromApp: defaultApplication }
1803
+ overrides
2006
1804
  });
2007
1805
  } catch (e) {
2008
1806
  throw MicrofrontendError.handle(e, {
@@ -2095,14 +1893,9 @@ var ProxyRequestRouter = class {
2095
1893
  Object.entries(cookies).map(([name, value]) => ({ name, value }))
2096
1894
  );
2097
1895
  const hasOverrides = Object.keys(cookieOverrides.applications).length > 0;
2098
- const fromApp = this.config.getDefaultApplication().name;
2099
1896
  const serialized = this.config.serialize().config;
2100
- if (!isMainConfig(serialized)) {
2101
- throw new Error("unreachable");
2102
- }
2103
- return hasOverrides ? new MicrofrontendMainConfig({
1897
+ return hasOverrides ? new MicrofrontendConfigIsomorphic({
2104
1898
  config: serialized,
2105
- meta: { fromApp },
2106
1899
  overrides: cookieOverrides
2107
1900
  }) : this.config;
2108
1901
  }
@@ -2283,15 +2076,15 @@ var LocalProxy = class {
2283
2076
  localApps,
2284
2077
  proxyPort
2285
2078
  }) {
2286
- const microfrontends = MicrofrontendsServer.infer({
2287
- directory: filePath
2288
- });
2289
- if (isMainConfig2(microfrontends.config)) {
2290
- return new LocalProxy(microfrontends.config, { localApps, proxyPort });
2079
+ let microfrontends;
2080
+ if (filePath) {
2081
+ microfrontends = MicrofrontendsServer.fromFile({
2082
+ filePath
2083
+ });
2084
+ } else {
2085
+ microfrontends = MicrofrontendsServer.infer();
2291
2086
  }
2292
- throw new Error(
2293
- `Unable to find main config from child application (${filePath})`
2294
- );
2087
+ return new LocalProxy(microfrontends.config, { localApps, proxyPort });
2295
2088
  }
2296
2089
  startServer() {
2297
2090
  const httpServer = http.createServer(
@@ -2426,8 +2219,8 @@ function removeMfeFlagQuery(req) {
2426
2219
  var import_node_process = require("process");
2427
2220
 
2428
2221
  // src/utils/mfe-port.ts
2429
- var import_node_path10 = __toESM(require("path"), 1);
2430
- var import_node_fs9 = __toESM(require("fs"), 1);
2222
+ var import_node_path9 = __toESM(require("path"), 1);
2223
+ var import_node_fs8 = __toESM(require("fs"), 1);
2431
2224
  function mfePort(packageDir) {
2432
2225
  const { name: appName, version } = getPackageJson(packageDir);
2433
2226
  const result = loadConfig({ packageDir, appName });
@@ -2445,8 +2238,8 @@ function mfePort(packageDir) {
2445
2238
  };
2446
2239
  }
2447
2240
  function getPackageJson(packageDir) {
2448
- const filePath = import_node_path10.default.join(packageDir, "package.json");
2449
- return JSON.parse(import_node_fs9.default.readFileSync(filePath, "utf-8"));
2241
+ const filePath = import_node_path9.default.join(packageDir, "package.json");
2242
+ return JSON.parse(import_node_fs8.default.readFileSync(filePath, "utf-8"));
2450
2243
  }
2451
2244
  function loadConfig({
2452
2245
  packageDir,
@@ -2455,9 +2248,7 @@ function loadConfig({
2455
2248
  let config;
2456
2249
  try {
2457
2250
  config = MicrofrontendsServer.infer({
2458
- directory: packageDir,
2459
- meta: { fromApp: appName },
2460
- options: { resolveMainConfig: true }
2251
+ directory: packageDir
2461
2252
  });
2462
2253
  } catch (e) {
2463
2254
  return void 0;
@@ -2484,7 +2275,7 @@ function header({ name, version, port }) {
2484
2275
  function main() {
2485
2276
  const program = new import_commander.Command();
2486
2277
  program.name(package_default.name).description("Tools for working with micro-frontend applications").version(package_default.version, "-v, --version", "output the current version");
2487
- program.command("proxy").argument("<filePath>", "Path to the micro-frontend configuration file").option("--names <names...>", "List of locally running applications", []).option("--port <port>", "Port proxy will use", (value) => {
2278
+ program.command("proxy").argument("[filePath]", "Path to the micro-frontend configuration file").option("--names <names...>", "List of locally running applications", []).option("--port <port>", "Port proxy will use", (value) => {
2488
2279
  const parsedValue = Number.parseInt(value, 10);
2489
2280
  if (isNaN(parsedValue) || parsedValue <= 0) {
2490
2281
  throw new Error("Port must be a positive number");