@vercel/microfrontends 1.1.1-canary.3 → 1.1.1-canary.5

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 (60) hide show
  1. package/dist/bin/cli.cjs +244 -494
  2. package/dist/config.cjs +27 -62
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +153 -4
  5. package/dist/config.js +27 -62
  6. package/dist/config.js.map +1 -1
  7. package/dist/experimental/sveltekit.cjs +228 -480
  8. package/dist/experimental/sveltekit.cjs.map +1 -1
  9. package/dist/experimental/sveltekit.js +218 -470
  10. package/dist/experimental/sveltekit.js.map +1 -1
  11. package/dist/experimental/vite.cjs +258 -502
  12. package/dist/experimental/vite.cjs.map +1 -1
  13. package/dist/experimental/vite.js +244 -488
  14. package/dist/experimental/vite.js.map +1 -1
  15. package/dist/microfrontends/server.cjs +227 -476
  16. package/dist/microfrontends/server.cjs.map +1 -1
  17. package/dist/microfrontends/server.d.ts +14 -20
  18. package/dist/microfrontends/server.js +217 -466
  19. package/dist/microfrontends/server.js.map +1 -1
  20. package/dist/next/config.cjs +229 -489
  21. package/dist/next/config.cjs.map +1 -1
  22. package/dist/next/config.js +219 -479
  23. package/dist/next/config.js.map +1 -1
  24. package/dist/next/endpoints.d.ts +2 -2
  25. package/dist/next/middleware.cjs +42 -162
  26. package/dist/next/middleware.cjs.map +1 -1
  27. package/dist/next/middleware.d.ts +2 -4
  28. package/dist/next/middleware.js +42 -162
  29. package/dist/next/middleware.js.map +1 -1
  30. package/dist/next/testing.cjs +30 -66
  31. package/dist/next/testing.cjs.map +1 -1
  32. package/dist/next/testing.d.ts +5 -5
  33. package/dist/next/testing.js +30 -66
  34. package/dist/next/testing.js.map +1 -1
  35. package/dist/overrides.d.ts +3 -3
  36. package/dist/schema.cjs +2 -9
  37. package/dist/schema.cjs.map +1 -1
  38. package/dist/schema.d.ts +3 -4
  39. package/dist/schema.js +1 -7
  40. package/dist/schema.js.map +1 -1
  41. package/dist/{types-6ee19ccc.d.ts → types-54064641.d.ts} +2 -13
  42. package/dist/{types-73527280.d.ts → types-a4add5ab.d.ts} +1 -1
  43. package/dist/{types-74e3336c.d.ts → types-f1260e44.d.ts} +1 -1
  44. package/dist/utils/mfe-port.cjs +232 -483
  45. package/dist/utils/mfe-port.cjs.map +1 -1
  46. package/dist/utils/mfe-port.js +218 -469
  47. package/dist/utils/mfe-port.js.map +1 -1
  48. package/dist/validation.cjs +0 -31
  49. package/dist/validation.cjs.map +1 -1
  50. package/dist/validation.d.ts +1 -1
  51. package/dist/validation.js +0 -31
  52. package/dist/validation.js.map +1 -1
  53. package/package.json +1 -8
  54. package/schema/schema.json +0 -33
  55. package/dist/index-7e69650e.d.ts +0 -165
  56. package/dist/microfrontends.cjs +0 -969
  57. package/dist/microfrontends.cjs.map +0 -1
  58. package/dist/microfrontends.d.ts +0 -45
  59. package/dist/microfrontends.js +0 -942
  60. 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.3",
32
+ version: "1.1.1-canary.5",
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
  ],
@@ -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,124 @@ 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");
363
470
  var LIST_FORMATTER = new Intl.ListFormat("en", {
364
471
  style: "long",
365
472
  type: "conjunction"
@@ -387,7 +494,7 @@ var validateConfigPaths = (applicationConfigsById) => {
387
494
  } else {
388
495
  pathsByApplicationId.set(path7, {
389
496
  applications: [id],
390
- matcher: (0, import_path_to_regexp.pathToRegexp)(path7),
497
+ matcher: (0, import_path_to_regexp2.pathToRegexp)(path7),
391
498
  applicationId: id
392
499
  });
393
500
  }
@@ -434,7 +541,7 @@ var validateConfigPaths = (applicationConfigsById) => {
434
541
  var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
435
542
  function validatePathExpression(path7) {
436
543
  try {
437
- const tokens = (0, import_path_to_regexp.parse)(path7);
544
+ const tokens = (0, import_path_to_regexp2.parse)(path7);
438
545
  if (/(?<!\\)\{/.test(path7)) {
439
546
  return `Optional paths are not supported: ${path7}`;
440
547
  }
@@ -819,125 +926,6 @@ var ChildApplication = class extends Application {
819
926
  }
820
927
  };
821
928
 
822
- // src/config/microfrontends-config/isomorphic/index.ts
823
- var import_jsonc_parser = require("jsonc-parser");
824
-
825
- // src/config/microfrontends-config/utils/get-config-from-env.ts
826
- function getConfigStringFromEnv() {
827
- const config = process.env.MFE_CONFIG;
828
- if (!config) {
829
- throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
830
- type: "config",
831
- subtype: "not_found_in_env"
832
- });
833
- }
834
- return config;
835
- }
836
-
837
- // src/config/schema/utils/is-main-config.ts
838
- function isMainConfig(c) {
839
- return !("partOf" in c);
840
- }
841
-
842
- // src/config/microfrontends-config/client/index.ts
843
- var import_path_to_regexp2 = require("path-to-regexp");
844
- var MicrofrontendConfigClient = class {
845
- constructor(config, opts) {
846
- this.pathCache = {};
847
- this.serialized = config;
848
- if (opts?.removeFlaggedPaths) {
849
- for (const app of Object.values(config.applications)) {
850
- if (app.routing) {
851
- app.routing = app.routing.filter((match) => !match.flag);
852
- }
853
- }
854
- }
855
- this.applications = config.applications;
856
- }
857
- /**
858
- * Create a new `MicrofrontendConfigClient` from a JSON string.
859
- * Config must be passed in to remain framework agnostic
860
- */
861
- static fromEnv(config, opts) {
862
- if (!config) {
863
- throw new Error("No microfrontends configuration found");
864
- }
865
- return new MicrofrontendConfigClient(
866
- JSON.parse(config),
867
- opts
868
- );
869
- }
870
- isEqual(other) {
871
- return JSON.stringify(this.applications) === JSON.stringify(other.applications);
872
- }
873
- getApplicationNameForPath(path7) {
874
- if (!path7.startsWith("/")) {
875
- throw new Error(`Path must start with a /`);
876
- }
877
- if (this.pathCache[path7]) {
878
- return this.pathCache[path7];
879
- }
880
- const pathname = new URL(path7, "https://example.com").pathname;
881
- for (const [name, application] of Object.entries(this.applications)) {
882
- if (application.routing) {
883
- for (const group of application.routing) {
884
- for (const childPath of group.paths) {
885
- const regexp = (0, import_path_to_regexp2.pathToRegexp)(childPath);
886
- if (regexp.test(pathname)) {
887
- this.pathCache[path7] = name;
888
- return name;
889
- }
890
- }
891
- }
892
- }
893
- }
894
- const defaultApplication = Object.entries(this.applications).find(
895
- ([, application]) => application.default
896
- );
897
- if (!defaultApplication) {
898
- return null;
899
- }
900
- this.pathCache[path7] = defaultApplication[0];
901
- return defaultApplication[0];
902
- }
903
- serialize() {
904
- return this.serialized;
905
- }
906
- };
907
-
908
- // src/config/overrides/constants.ts
909
- var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
910
- var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
911
-
912
- // src/config/overrides/is-override-cookie.ts
913
- function isOverrideCookie(cookie) {
914
- return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
915
- }
916
-
917
- // src/config/overrides/get-override-from-cookie.ts
918
- function getOverrideFromCookie(cookie) {
919
- if (!isOverrideCookie(cookie) || !cookie.value)
920
- return;
921
- return {
922
- application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ""),
923
- host: cookie.value
924
- };
925
- }
926
-
927
- // src/config/overrides/parse-overrides.ts
928
- function parseOverrides(cookies) {
929
- const overridesConfig = { applications: {} };
930
- cookies.forEach((cookie) => {
931
- const override = getOverrideFromCookie(cookie);
932
- if (!override)
933
- return;
934
- overridesConfig.applications[override.application] = {
935
- environment: { host: override.host }
936
- };
937
- });
938
- return overridesConfig;
939
- }
940
-
941
929
  // src/config/microfrontends-config/isomorphic/constants.ts
942
930
  var DEFAULT_LOCAL_PROXY_PORT = 3024;
943
931
 
@@ -946,42 +934,28 @@ var MicrofrontendConfigIsomorphic = class {
946
934
  constructor({
947
935
  config,
948
936
  overrides,
949
- meta,
950
937
  opts
951
938
  }) {
952
939
  this.childApplications = {};
953
940
  MicrofrontendConfigIsomorphic.validate(config, opts);
954
941
  const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
955
942
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
956
- this.isMainConfig = isMainConfig(config);
957
- if (isMainConfig(config)) {
958
- for (const [appId, appConfig] of Object.entries(config.applications)) {
959
- const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
960
- if (isDefaultApp(appConfig)) {
961
- this.defaultApplication = new DefaultApplication(appId, {
962
- app: appConfig,
963
- overrides: appOverrides
964
- });
965
- } else {
966
- this.childApplications[appId] = new ChildApplication(appId, {
967
- app: appConfig,
968
- overrides: appOverrides
969
- });
970
- }
971
- }
972
- } else {
973
- this.partOf = config.partOf;
974
- const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
975
- this.childApplications[meta.fromApp] = new ChildApplication(
976
- meta.fromApp,
977
- {
978
- // we don't know routing because we're not in the main config
979
- 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,
980
949
  overrides: appOverrides
981
- }
982
- );
950
+ });
951
+ } else {
952
+ this.childApplications[appId] = new ChildApplication(appId, {
953
+ app: appConfig,
954
+ overrides: appOverrides
955
+ });
956
+ }
983
957
  }
984
- if (isMainConfig(config) && !this.defaultApplication) {
958
+ if (!defaultApplication) {
985
959
  throw new MicrofrontendError(
986
960
  "Could not find default application in microfrontends configuration",
987
961
  {
@@ -990,34 +964,30 @@ var MicrofrontendConfigIsomorphic = class {
990
964
  }
991
965
  );
992
966
  }
967
+ this.defaultApplication = defaultApplication;
993
968
  this.config = config;
994
969
  this.options = config.options;
995
970
  this.serialized = {
996
971
  config,
997
- overrides,
998
- meta
972
+ overrides
999
973
  };
1000
974
  }
1001
975
  static validate(config, opts) {
1002
976
  const skipValidation = opts?.skipValidation ?? [];
1003
977
  const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
1004
- if (isMainConfig(c)) {
1005
- validateConfigPaths(c.applications);
1006
- validateConfigDefaultApplication(c.applications);
1007
- if (!skipValidation.includes("deprecatedFields")) {
1008
- validateDeprecatedFields(c);
1009
- }
978
+ validateConfigPaths(c.applications);
979
+ validateConfigDefaultApplication(c.applications);
980
+ if (!skipValidation.includes("deprecatedFields")) {
981
+ validateDeprecatedFields(c);
1010
982
  }
1011
983
  return c;
1012
984
  }
1013
985
  static fromEnv({
1014
- meta,
1015
986
  cookies
1016
987
  }) {
1017
988
  return new MicrofrontendConfigIsomorphic({
1018
989
  config: (0, import_jsonc_parser.parse)(getConfigStringFromEnv()),
1019
- overrides: parseOverrides(cookies ?? []),
1020
- meta
990
+ overrides: parseOverrides(cookies ?? [])
1021
991
  });
1022
992
  }
1023
993
  isOverridesDisabled() {
@@ -1042,7 +1012,7 @@ var MicrofrontendConfigIsomorphic = class {
1042
1012
  ].filter(Boolean);
1043
1013
  }
1044
1014
  getApplication(name) {
1045
- if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
1015
+ if (this.defaultApplication.name === name || this.defaultApplication.packageName === name) {
1046
1016
  return this.defaultApplication;
1047
1017
  }
1048
1018
  const app = this.childApplications[name] || Object.values(this.childApplications).find(
@@ -1060,7 +1030,7 @@ var MicrofrontendConfigIsomorphic = class {
1060
1030
  return app;
1061
1031
  }
1062
1032
  getApplicationByProjectId(projectId) {
1063
- if (this.defaultApplication?.projectId === projectId) {
1033
+ if (this.defaultApplication.projectId === projectId) {
1064
1034
  return this.defaultApplication;
1065
1035
  }
1066
1036
  return Object.values(this.childApplications).find(
@@ -1068,19 +1038,9 @@ var MicrofrontendConfigIsomorphic = class {
1068
1038
  );
1069
1039
  }
1070
1040
  /**
1071
- * Returns the default application. This can throw if the default application
1072
- * is undefined ( )
1041
+ * Returns the default application.
1073
1042
  */
1074
1043
  getDefaultApplication() {
1075
- if (!this.defaultApplication) {
1076
- throw new MicrofrontendError(
1077
- "Could not find default application in microfrontends configuration",
1078
- {
1079
- type: "application",
1080
- subtype: "not_found"
1081
- }
1082
- );
1083
- }
1084
1044
  return this.defaultApplication;
1085
1045
  }
1086
1046
  /**
@@ -1107,11 +1067,9 @@ var MicrofrontendConfigIsomorphic = class {
1107
1067
  }
1108
1068
  ])
1109
1069
  );
1110
- if (this.defaultApplication) {
1111
- applications[this.defaultApplication.name] = {
1112
- default: true
1113
- };
1114
- }
1070
+ applications[this.defaultApplication.name] = {
1071
+ default: true
1072
+ };
1115
1073
  return new MicrofrontendConfigClient({
1116
1074
  applications
1117
1075
  });
@@ -1121,93 +1079,9 @@ var MicrofrontendConfigIsomorphic = class {
1121
1079
  }
1122
1080
  };
1123
1081
 
1124
- // src/config/microfrontends-config/isomorphic/main.ts
1125
- var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1126
- constructor({
1127
- config,
1128
- overrides,
1129
- meta
1130
- }) {
1131
- super({ config, overrides, meta });
1132
- this.isMainConfig = true;
1133
- const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
1134
- let defaultApplication;
1135
- for (const [appId, appConfig] of Object.entries(config.applications)) {
1136
- const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
1137
- if (isDefaultApp(appConfig)) {
1138
- defaultApplication = new DefaultApplication(appId, {
1139
- app: appConfig,
1140
- overrides: appOverrides
1141
- });
1142
- } else {
1143
- this.childApplications[appId] = new ChildApplication(appId, {
1144
- app: appConfig,
1145
- overrides: appOverrides
1146
- });
1147
- }
1148
- }
1149
- if (!defaultApplication) {
1150
- throw new MicrofrontendError(
1151
- "Could not find default application in microfrontends configuration",
1152
- {
1153
- type: "application",
1154
- subtype: "not_found"
1155
- }
1156
- );
1157
- }
1158
- this.defaultApplication = defaultApplication;
1159
- }
1160
- };
1161
-
1162
- // src/config/microfrontends/utils/is-main-config.ts
1163
- function isMainConfig2(c) {
1164
- return !("partOf" in c);
1165
- }
1166
-
1167
1082
  // src/config/microfrontends/server/index.ts
1168
- var import_node_fs8 = __toESM(require("fs"), 1);
1169
- var import_node_path9 = require("path");
1170
-
1171
- // src/config/microfrontends-config/isomorphic/child.ts
1172
- var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
1173
- constructor({
1174
- config,
1175
- overrides,
1176
- meta
1177
- }) {
1178
- super({ config, overrides, meta });
1179
- this.isMainConfig = false;
1180
- this.partOf = config.partOf;
1181
- }
1182
- };
1183
-
1184
- // src/config/microfrontends/isomorphic/index.ts
1185
- var Microfrontends = class {
1186
- constructor({
1187
- config,
1188
- overrides,
1189
- meta
1190
- }) {
1191
- if (isMainConfig(config)) {
1192
- this.config = new MicrofrontendMainConfig({ config, overrides, meta });
1193
- } else {
1194
- this.config = new MicrofrontendChildConfig({ config, overrides, meta });
1195
- }
1196
- }
1197
- isChildConfig() {
1198
- return this.config instanceof MicrofrontendChildConfig;
1199
- }
1200
- static fromEnv({
1201
- cookies,
1202
- meta
1203
- }) {
1204
- const config = MicrofrontendConfigIsomorphic.fromEnv({
1205
- cookies,
1206
- meta
1207
- });
1208
- return new Microfrontends(config.serialize());
1209
- }
1210
- };
1083
+ var import_node_fs7 = __toESM(require("fs"), 1);
1084
+ var import_node_path8 = require("path");
1211
1085
 
1212
1086
  // src/config/microfrontends/utils/find-repository-root.ts
1213
1087
  var import_node_fs = __toESM(require("fs"), 1);
@@ -1236,67 +1110,11 @@ function findRepositoryRoot(startDir) {
1236
1110
  );
1237
1111
  }
1238
1112
 
1239
- // src/config/microfrontends/utils/find-package-path.ts
1113
+ // src/config/microfrontends/utils/find-default-package.ts
1240
1114
  var import_node_path2 = require("path");
1241
1115
  var import_node_fs2 = require("fs");
1242
- var import_fast_glob = __toESM(require("fast-glob"), 1);
1243
- var configCache = {};
1244
- function findPackagePathWithGlob({
1245
- repositoryRoot,
1246
- name
1247
- }) {
1248
- try {
1249
- const packageJsonPaths = import_fast_glob.default.globSync("**/package.json", {
1250
- cwd: repositoryRoot,
1251
- absolute: true,
1252
- onlyFiles: true,
1253
- followSymbolicLinks: false,
1254
- ignore: ["**/node_modules/**", "**/.git/**"]
1255
- });
1256
- const matchingPaths = [];
1257
- for (const packageJsonPath2 of packageJsonPaths) {
1258
- const packageJsonContent = (0, import_node_fs2.readFileSync)(packageJsonPath2, "utf-8");
1259
- const packageJson = JSON.parse(packageJsonContent);
1260
- if (packageJson.name === name) {
1261
- matchingPaths.push(packageJsonPath2);
1262
- }
1263
- }
1264
- if (matchingPaths.length > 1) {
1265
- throw new Error(
1266
- `Found multiple packages with the name "${name}" in the repository: ${matchingPaths.join(", ")}`
1267
- );
1268
- }
1269
- if (matchingPaths.length === 0) {
1270
- throw new Error(
1271
- `Could not find package with the name "${name}" in the repository`
1272
- );
1273
- }
1274
- const [packageJsonPath] = matchingPaths;
1275
- return (0, import_node_path2.dirname)(packageJsonPath);
1276
- } catch (error) {
1277
- return null;
1278
- }
1279
- }
1280
- function findPackagePath(opts) {
1281
- const cacheKey = `${opts.repositoryRoot}-${opts.name}`;
1282
- if (configCache[cacheKey]) {
1283
- return configCache[cacheKey];
1284
- }
1285
- const result = findPackagePathWithGlob(opts);
1286
- if (!result) {
1287
- throw new Error(
1288
- `Could not find package with the name "${opts.name}" in the repository`
1289
- );
1290
- }
1291
- configCache[cacheKey] = result;
1292
- return result;
1293
- }
1294
-
1295
- // src/config/microfrontends/utils/find-default-package.ts
1296
- var import_node_path3 = require("path");
1297
- var import_node_fs3 = require("fs");
1298
1116
  var import_jsonc_parser2 = require("jsonc-parser");
1299
- var import_fast_glob2 = __toESM(require("fast-glob"), 1);
1117
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
1300
1118
 
1301
1119
  // src/config/constants.ts
1302
1120
  var CONFIGURATION_FILENAMES = [
@@ -1305,13 +1123,13 @@ var CONFIGURATION_FILENAMES = [
1305
1123
  ];
1306
1124
 
1307
1125
  // src/config/microfrontends/utils/find-default-package.ts
1308
- var configCache2 = {};
1126
+ var configCache = {};
1309
1127
  function findDefaultMicrofrontendsPackages({
1310
1128
  repositoryRoot,
1311
1129
  applicationName
1312
1130
  }) {
1313
1131
  try {
1314
- const microfrontendsJsonPaths = import_fast_glob2.default.globSync(
1132
+ const microfrontendsJsonPaths = import_fast_glob.default.globSync(
1315
1133
  `**/{${CONFIGURATION_FILENAMES.join(",")}}`,
1316
1134
  {
1317
1135
  cwd: repositoryRoot,
@@ -1324,12 +1142,12 @@ function findDefaultMicrofrontendsPackages({
1324
1142
  const matchingPaths = [];
1325
1143
  for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
1326
1144
  try {
1327
- const microfrontendsJsonContent = (0, import_node_fs3.readFileSync)(
1145
+ const microfrontendsJsonContent = (0, import_node_fs2.readFileSync)(
1328
1146
  microfrontendsJsonPath,
1329
1147
  "utf-8"
1330
1148
  );
1331
1149
  const microfrontendsJson = (0, import_jsonc_parser2.parse)(microfrontendsJsonContent);
1332
- if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
1150
+ if (microfrontendsJson.applications[applicationName]) {
1333
1151
  matchingPaths.push(microfrontendsJsonPath);
1334
1152
  }
1335
1153
  } catch (error) {
@@ -1347,15 +1165,15 @@ ${matchingPaths.join("\n \u2022 ")}`
1347
1165
  );
1348
1166
  }
1349
1167
  const [packageJsonPath] = matchingPaths;
1350
- return (0, import_node_path3.dirname)(packageJsonPath);
1168
+ return (0, import_node_path2.dirname)(packageJsonPath);
1351
1169
  } catch (error) {
1352
1170
  return null;
1353
1171
  }
1354
1172
  }
1355
1173
  function findDefaultMicrofrontendsPackage(opts) {
1356
1174
  const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
1357
- if (configCache2[cacheKey]) {
1358
- return configCache2[cacheKey];
1175
+ if (configCache[cacheKey]) {
1176
+ return configCache[cacheKey];
1359
1177
  }
1360
1178
  const result = findDefaultMicrofrontendsPackages(opts);
1361
1179
  if (!result) {
@@ -1363,32 +1181,32 @@ function findDefaultMicrofrontendsPackage(opts) {
1363
1181
  "Error trying to resolve the main microfrontends configuration"
1364
1182
  );
1365
1183
  }
1366
- configCache2[cacheKey] = result;
1184
+ configCache[cacheKey] = result;
1367
1185
  return result;
1368
1186
  }
1369
1187
 
1370
1188
  // src/config/microfrontends/utils/is-monorepo.ts
1371
- var import_node_fs4 = __toESM(require("fs"), 1);
1372
- 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);
1373
1191
  function isMonorepo({
1374
1192
  repositoryRoot
1375
1193
  }) {
1376
1194
  try {
1377
- 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"))) {
1378
1196
  return true;
1379
1197
  }
1380
- 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"))) {
1381
1199
  return true;
1382
1200
  }
1383
- 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)) {
1384
1202
  return true;
1385
1203
  }
1386
- const packageJsonPath = import_node_path4.default.join(repositoryRoot, "package.json");
1387
- 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)) {
1388
1206
  return false;
1389
1207
  }
1390
1208
  const packageJson = JSON.parse(
1391
- import_node_fs4.default.readFileSync(packageJsonPath, "utf-8")
1209
+ import_node_fs3.default.readFileSync(packageJsonPath, "utf-8")
1392
1210
  );
1393
1211
  return packageJson.workspaces !== void 0;
1394
1212
  } catch (error) {
@@ -1398,17 +1216,17 @@ function isMonorepo({
1398
1216
  }
1399
1217
 
1400
1218
  // src/config/microfrontends/utils/find-package-root.ts
1401
- var import_node_fs5 = __toESM(require("fs"), 1);
1402
- 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);
1403
1221
  var PACKAGE_JSON = "package.json";
1404
1222
  function findPackageRoot(startDir) {
1405
1223
  let currentDir = startDir || process.cwd();
1406
- while (currentDir !== import_node_path5.default.parse(currentDir).root) {
1407
- const pkgJsonPath = import_node_path5.default.join(currentDir, PACKAGE_JSON);
1408
- 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)) {
1409
1227
  return currentDir;
1410
1228
  }
1411
- currentDir = import_node_path5.default.dirname(currentDir);
1229
+ currentDir = import_node_path4.default.dirname(currentDir);
1412
1230
  }
1413
1231
  throw new Error(
1414
1232
  "Package root not found. Specify the root of the package with the `package.root` option."
@@ -1416,12 +1234,12 @@ function findPackageRoot(startDir) {
1416
1234
  }
1417
1235
 
1418
1236
  // src/config/microfrontends/utils/find-config.ts
1419
- var import_node_fs6 = __toESM(require("fs"), 1);
1420
- var import_node_path6 = require("path");
1237
+ var import_node_fs5 = __toESM(require("fs"), 1);
1238
+ var import_node_path5 = require("path");
1421
1239
  function findConfig({ dir }) {
1422
1240
  for (const filename of CONFIGURATION_FILENAMES) {
1423
- const maybeConfig = (0, import_node_path6.join)(dir, filename);
1424
- 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)) {
1425
1243
  return maybeConfig;
1426
1244
  }
1427
1245
  }
@@ -1429,8 +1247,8 @@ function findConfig({ dir }) {
1429
1247
  }
1430
1248
 
1431
1249
  // src/config/microfrontends/utils/get-application-context.ts
1432
- var import_node_fs7 = __toESM(require("fs"), 1);
1433
- 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);
1434
1252
  function getApplicationContext(opts) {
1435
1253
  if (opts?.appName) {
1436
1254
  return { name: opts.appName };
@@ -1439,8 +1257,8 @@ function getApplicationContext(opts) {
1439
1257
  return { name: process.env.NX_TASK_TARGET_PROJECT };
1440
1258
  }
1441
1259
  try {
1442
- const packageJsonString = import_node_fs7.default.readFileSync(
1443
- 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"),
1444
1262
  "utf-8"
1445
1263
  );
1446
1264
  const packageJson = JSON.parse(packageJsonString);
@@ -1463,7 +1281,7 @@ function getApplicationContext(opts) {
1463
1281
  }
1464
1282
 
1465
1283
  // src/config/microfrontends/server/utils/get-output-file-path.ts
1466
- var import_node_path8 = __toESM(require("path"), 1);
1284
+ var import_node_path7 = __toESM(require("path"), 1);
1467
1285
 
1468
1286
  // src/config/microfrontends/server/constants.ts
1469
1287
  var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
@@ -1471,7 +1289,7 @@ var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
1471
1289
 
1472
1290
  // src/config/microfrontends/server/utils/get-output-file-path.ts
1473
1291
  function getOutputFilePath() {
1474
- 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);
1475
1293
  }
1476
1294
 
1477
1295
  // src/config/microfrontends/server/validation.ts
@@ -1484,16 +1302,6 @@ var schema_default = {
1484
1302
  $ref: "#/definitions/Config",
1485
1303
  definitions: {
1486
1304
  Config: {
1487
- anyOf: [
1488
- {
1489
- $ref: "#/definitions/MainConfig"
1490
- },
1491
- {
1492
- $ref: "#/definitions/ChildConfig"
1493
- }
1494
- ]
1495
- },
1496
- MainConfig: {
1497
1305
  type: "object",
1498
1306
  properties: {
1499
1307
  $schema: {
@@ -1750,27 +1558,6 @@ var schema_default = {
1750
1558
  },
1751
1559
  required: ["paths"],
1752
1560
  additionalProperties: false
1753
- },
1754
- ChildConfig: {
1755
- type: "object",
1756
- properties: {
1757
- $schema: {
1758
- type: "string"
1759
- },
1760
- version: {
1761
- type: "string",
1762
- const: "1"
1763
- },
1764
- options: {
1765
- $ref: "#/definitions/Options"
1766
- },
1767
- partOf: {
1768
- type: "string",
1769
- 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."
1770
- }
1771
- },
1772
- required: ["partOf"],
1773
- additionalProperties: false
1774
1561
  }
1775
1562
  }
1776
1563
  };
@@ -1848,7 +1635,13 @@ See https://openapi.vercel.sh/microfrontends.json for the schema.`,
1848
1635
  }
1849
1636
 
1850
1637
  // src/config/microfrontends/server/index.ts
1851
- var MicrofrontendsServer = class extends Microfrontends {
1638
+ var MicrofrontendsServer = class {
1639
+ constructor({
1640
+ config,
1641
+ overrides
1642
+ }) {
1643
+ this.config = new MicrofrontendConfigIsomorphic({ config, overrides });
1644
+ }
1852
1645
  /**
1853
1646
  * Writes the configuration to a file.
1854
1647
  */
@@ -1856,8 +1649,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1856
1649
  pretty: true
1857
1650
  }) {
1858
1651
  const outputPath = getOutputFilePath();
1859
- import_node_fs8.default.mkdirSync((0, import_node_path9.dirname)(outputPath), { recursive: true });
1860
- 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(
1861
1654
  outputPath,
1862
1655
  JSON.stringify(
1863
1656
  this.config.toSchemaJson(),
@@ -1872,22 +1665,19 @@ var MicrofrontendsServer = class extends Microfrontends {
1872
1665
  */
1873
1666
  static fromUnknown({
1874
1667
  config,
1875
- cookies,
1876
- meta
1668
+ cookies
1877
1669
  }) {
1878
1670
  const overrides = cookies ? parseOverrides(cookies) : void 0;
1879
1671
  if (typeof config === "string") {
1880
1672
  return new MicrofrontendsServer({
1881
1673
  config: MicrofrontendsServer.validate(config),
1882
- overrides,
1883
- meta
1674
+ overrides
1884
1675
  });
1885
1676
  }
1886
1677
  if (typeof config === "object") {
1887
1678
  return new MicrofrontendsServer({
1888
1679
  config,
1889
- overrides,
1890
- meta
1680
+ overrides
1891
1681
  });
1892
1682
  }
1893
1683
  throw new MicrofrontendError(
@@ -1900,13 +1690,11 @@ var MicrofrontendsServer = class extends Microfrontends {
1900
1690
  * Uses additional validation that is only available when in a node runtime
1901
1691
  */
1902
1692
  static fromEnv({
1903
- cookies,
1904
- meta
1693
+ cookies
1905
1694
  }) {
1906
1695
  return new MicrofrontendsServer({
1907
1696
  config: MicrofrontendsServer.validate(getConfigStringFromEnv()),
1908
- overrides: parseOverrides(cookies),
1909
- meta
1697
+ overrides: parseOverrides(cookies)
1910
1698
  });
1911
1699
  }
1912
1700
  /**
@@ -1929,29 +1717,22 @@ var MicrofrontendsServer = class extends Microfrontends {
1929
1717
  static infer({
1930
1718
  directory,
1931
1719
  filePath,
1932
- meta,
1933
- cookies,
1934
- options
1720
+ cookies
1935
1721
  } = {}) {
1936
- if (filePath && meta) {
1722
+ if (filePath) {
1937
1723
  return MicrofrontendsServer.fromFile({
1938
1724
  filePath,
1939
- cookies,
1940
- meta,
1941
- options
1725
+ cookies
1942
1726
  });
1943
1727
  }
1944
1728
  try {
1945
1729
  const packageRoot = findPackageRoot(directory);
1946
1730
  const { name: appName } = getApplicationContext({ packageRoot });
1947
- const configMeta = meta ?? { fromApp: appName };
1948
1731
  const maybeConfig = findConfig({ dir: packageRoot });
1949
1732
  if (maybeConfig) {
1950
1733
  return MicrofrontendsServer.fromFile({
1951
1734
  filePath: maybeConfig,
1952
- cookies,
1953
- meta: configMeta,
1954
- options
1735
+ cookies
1955
1736
  });
1956
1737
  }
1957
1738
  const repositoryRoot = findRepositoryRoot();
@@ -1965,9 +1746,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1965
1746
  if (maybeConfigFromDefault) {
1966
1747
  return MicrofrontendsServer.fromFile({
1967
1748
  filePath: maybeConfigFromDefault,
1968
- cookies,
1969
- meta: configMeta,
1970
- options
1749
+ cookies
1971
1750
  });
1972
1751
  }
1973
1752
  }
@@ -1987,44 +1766,14 @@ var MicrofrontendsServer = class extends Microfrontends {
1987
1766
  */
1988
1767
  static fromFile({
1989
1768
  filePath,
1990
- cookies,
1991
- meta,
1992
- options
1769
+ cookies
1993
1770
  }) {
1994
1771
  try {
1995
- const configJson = import_node_fs8.default.readFileSync(filePath, "utf-8");
1772
+ const configJson = import_node_fs7.default.readFileSync(filePath, "utf-8");
1996
1773
  const config = MicrofrontendsServer.validate(configJson);
1997
- if (!isMainConfig(config) && options?.resolveMainConfig) {
1998
- const repositoryRoot = findRepositoryRoot();
1999
- const isMonorepo2 = isMonorepo({ repositoryRoot });
2000
- if (isMonorepo2) {
2001
- const packagePath = findPackagePath({
2002
- repositoryRoot,
2003
- name: config.partOf
2004
- });
2005
- if (!packagePath) {
2006
- throw new MicrofrontendError(
2007
- `Could not find default application "${config.partOf}" in the repository`,
2008
- { type: "config", subtype: "not_found" }
2009
- );
2010
- }
2011
- const maybeConfig = findConfig({ dir: packagePath });
2012
- if (!maybeConfig) {
2013
- throw new MicrofrontendError(
2014
- `Could not find microfrontends configuration in ${packagePath}`,
2015
- { type: "config", subtype: "not_found" }
2016
- );
2017
- }
2018
- return MicrofrontendsServer.fromMainConfigFile({
2019
- filePath: maybeConfig,
2020
- overrides: cookies ? parseOverrides(cookies) : void 0
2021
- });
2022
- }
2023
- }
2024
1774
  return new MicrofrontendsServer({
2025
1775
  config,
2026
- overrides: cookies ? parseOverrides(cookies) : void 0,
2027
- meta
1776
+ overrides: cookies ? parseOverrides(cookies) : void 0
2028
1777
  });
2029
1778
  } catch (e) {
2030
1779
  throw MicrofrontendError.handle(e, {
@@ -2033,24 +1782,15 @@ var MicrofrontendsServer = class extends Microfrontends {
2033
1782
  }
2034
1783
  }
2035
1784
  /*
2036
- * Generates a MicrofrontendMainConfig instance from a file.
1785
+ * Generates a MicrofrontendsServer instance from a file.
2037
1786
  */
2038
1787
  static fromMainConfigFile({
2039
1788
  filePath,
2040
1789
  overrides
2041
1790
  }) {
2042
1791
  try {
2043
- const config = import_node_fs8.default.readFileSync(filePath, "utf-8");
1792
+ const config = import_node_fs7.default.readFileSync(filePath, "utf-8");
2044
1793
  const validatedConfig = MicrofrontendsServer.validate(config);
2045
- if (!isMainConfig(validatedConfig)) {
2046
- throw new MicrofrontendError(
2047
- `${filePath} is not a main microfrontend config`,
2048
- {
2049
- type: "config",
2050
- subtype: "invalid_main_path"
2051
- }
2052
- );
2053
- }
2054
1794
  const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
2055
1795
  if (!defaultApplication) {
2056
1796
  throw new MicrofrontendError(
@@ -2060,8 +1800,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2060
1800
  }
2061
1801
  return new MicrofrontendsServer({
2062
1802
  config: validatedConfig,
2063
- overrides,
2064
- meta: { fromApp: defaultApplication }
1803
+ overrides
2065
1804
  });
2066
1805
  } catch (e) {
2067
1806
  throw MicrofrontendError.handle(e, {
@@ -2154,14 +1893,9 @@ var ProxyRequestRouter = class {
2154
1893
  Object.entries(cookies).map(([name, value]) => ({ name, value }))
2155
1894
  );
2156
1895
  const hasOverrides = Object.keys(cookieOverrides.applications).length > 0;
2157
- const fromApp = this.config.getDefaultApplication().name;
2158
1896
  const serialized = this.config.serialize().config;
2159
- if (!isMainConfig(serialized)) {
2160
- throw new Error("unreachable");
2161
- }
2162
- return hasOverrides ? new MicrofrontendMainConfig({
1897
+ return hasOverrides ? new MicrofrontendConfigIsomorphic({
2163
1898
  config: serialized,
2164
- meta: { fromApp },
2165
1899
  overrides: cookieOverrides
2166
1900
  }) : this.config;
2167
1901
  }
@@ -2342,15 +2076,33 @@ var LocalProxy = class {
2342
2076
  localApps,
2343
2077
  proxyPort
2344
2078
  }) {
2345
- const microfrontends = MicrofrontendsServer.infer({
2346
- directory: filePath
2347
- });
2348
- if (isMainConfig2(microfrontends.config)) {
2349
- 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();
2086
+ }
2087
+ LocalProxy.validateLocalApps(localApps, microfrontends.config);
2088
+ return new LocalProxy(microfrontends.config, { localApps, proxyPort });
2089
+ }
2090
+ static validateLocalApps(localApps, config) {
2091
+ const unknownApps = [];
2092
+ const allApps = /* @__PURE__ */ new Set();
2093
+ for (const app of config.getAllApplications()) {
2094
+ allApps.add(app.name);
2095
+ }
2096
+ for (const app of localApps) {
2097
+ if (!allApps.has(app)) {
2098
+ unknownApps.push(app);
2099
+ }
2100
+ }
2101
+ if (unknownApps.length) {
2102
+ throw new Error(
2103
+ `The following apps passed via --local-apps are not in the microfrontends config: ${unknownApps.join(", ")} (microfrontends config contains: ${Array.from(allApps).join(", ")})`
2104
+ );
2350
2105
  }
2351
- throw new Error(
2352
- `Unable to find main config from child application (${filePath})`
2353
- );
2354
2106
  }
2355
2107
  startServer() {
2356
2108
  const httpServer = http.createServer(
@@ -2485,8 +2237,8 @@ function removeMfeFlagQuery(req) {
2485
2237
  var import_node_process = require("process");
2486
2238
 
2487
2239
  // src/utils/mfe-port.ts
2488
- var import_node_path10 = __toESM(require("path"), 1);
2489
- var import_node_fs9 = __toESM(require("fs"), 1);
2240
+ var import_node_path9 = __toESM(require("path"), 1);
2241
+ var import_node_fs8 = __toESM(require("fs"), 1);
2490
2242
  function mfePort(packageDir) {
2491
2243
  const { name: appName, version } = getPackageJson(packageDir);
2492
2244
  const result = loadConfig({ packageDir, appName });
@@ -2504,8 +2256,8 @@ function mfePort(packageDir) {
2504
2256
  };
2505
2257
  }
2506
2258
  function getPackageJson(packageDir) {
2507
- const filePath = import_node_path10.default.join(packageDir, "package.json");
2508
- return JSON.parse(import_node_fs9.default.readFileSync(filePath, "utf-8"));
2259
+ const filePath = import_node_path9.default.join(packageDir, "package.json");
2260
+ return JSON.parse(import_node_fs8.default.readFileSync(filePath, "utf-8"));
2509
2261
  }
2510
2262
  function loadConfig({
2511
2263
  packageDir,
@@ -2514,9 +2266,7 @@ function loadConfig({
2514
2266
  let config;
2515
2267
  try {
2516
2268
  config = MicrofrontendsServer.infer({
2517
- directory: packageDir,
2518
- meta: { fromApp: appName },
2519
- options: { resolveMainConfig: true }
2269
+ directory: packageDir
2520
2270
  });
2521
2271
  } catch (e) {
2522
2272
  return void 0;
@@ -2543,7 +2293,7 @@ function header({ name, version, port }) {
2543
2293
  function main() {
2544
2294
  const program = new import_commander.Command();
2545
2295
  program.name(package_default.name).description("Tools for working with micro-frontend applications").version(package_default.version, "-v, --version", "output the current version");
2546
- 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) => {
2296
+ program.command("proxy").argument("[filePath]", "Path to the micro-frontend configuration file").option("--names, --local-apps <names...>", "List of locally running applications", []).option("--port <port>", "Port proxy will use", (value) => {
2547
2297
  const parsedValue = Number.parseInt(value, 10);
2548
2298
  if (isNaN(parsedValue) || parsedValue <= 0) {
2549
2299
  throw new Error("Port must be a positive number");
@@ -2551,7 +2301,7 @@ function main() {
2551
2301
  return parsedValue;
2552
2302
  }).action((filePath, options) => {
2553
2303
  const localProxy = LocalProxy.fromFile(filePath, {
2554
- localApps: options.names,
2304
+ localApps: options.localApps,
2555
2305
  proxyPort: options.port
2556
2306
  });
2557
2307
  localProxy.startServer();