@vercel/microfrontends 1.1.1-canary.3 → 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 (60) hide show
  1. package/dist/bin/cli.cjs +225 -493
  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 +28 -64
  31. package/dist/next/testing.cjs.map +1 -1
  32. package/dist/next/testing.d.ts +4 -4
  33. package/dist/next/testing.js +28 -64
  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
@@ -9,7 +9,7 @@ function displayLocalProxyInfo(port) {
9
9
 
10
10
  // src/config/microfrontends/server/index.ts
11
11
  import fs6 from "node:fs";
12
- import { dirname as dirname3 } from "node:path";
12
+ import { dirname as dirname2 } from "node:path";
13
13
 
14
14
  // src/config/overrides/constants.ts
15
15
  var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
@@ -148,19 +148,177 @@ function getConfigStringFromEnv() {
148
148
  return config;
149
149
  }
150
150
 
151
- // src/config/microfrontends-config/isomorphic/index.ts
151
+ // src/config/schema/utils/is-default-app.ts
152
+ function isDefaultApp(a) {
153
+ return !("routing" in a);
154
+ }
155
+
156
+ // src/config/microfrontends/utils/find-repository-root.ts
157
+ import fs from "node:fs";
158
+ import path from "node:path";
159
+ var GIT_DIRECTORY = ".git";
160
+ function hasGitDirectory(dir) {
161
+ const gitPath = path.join(dir, GIT_DIRECTORY);
162
+ return fs.existsSync(gitPath) && fs.statSync(gitPath).isDirectory();
163
+ }
164
+ function hasPnpmWorkspaces(dir) {
165
+ return fs.existsSync(path.join(dir, "pnpm-workspace.yaml"));
166
+ }
167
+ function findRepositoryRoot(startDir) {
168
+ if (process.env.NX_WORKSPACE_ROOT) {
169
+ return process.env.NX_WORKSPACE_ROOT;
170
+ }
171
+ let currentDir = startDir || process.cwd();
172
+ while (currentDir !== path.parse(currentDir).root) {
173
+ if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
174
+ return currentDir;
175
+ }
176
+ currentDir = path.dirname(currentDir);
177
+ }
178
+ throw new Error(
179
+ "Repository root not found. Specify the root of the repository with the `repository.root` option."
180
+ );
181
+ }
182
+
183
+ // src/config/microfrontends/utils/find-default-package.ts
184
+ import { dirname } from "node:path";
185
+ import { readFileSync } from "node:fs";
152
186
  import { parse } from "jsonc-parser";
187
+ import fg from "fast-glob";
188
+
189
+ // src/config/constants.ts
190
+ var CONFIGURATION_FILENAMES = [
191
+ "microfrontends.jsonc",
192
+ "microfrontends.json"
193
+ ];
153
194
 
154
- // src/config/schema/utils/is-main-config.ts
155
- function isMainConfig(c) {
156
- return !("partOf" in c);
195
+ // src/config/microfrontends/utils/find-default-package.ts
196
+ var configCache = {};
197
+ function findDefaultMicrofrontendsPackages({
198
+ repositoryRoot,
199
+ applicationName
200
+ }) {
201
+ try {
202
+ const microfrontendsJsonPaths = fg.globSync(
203
+ `**/{${CONFIGURATION_FILENAMES.join(",")}}`,
204
+ {
205
+ cwd: repositoryRoot,
206
+ absolute: true,
207
+ onlyFiles: true,
208
+ followSymbolicLinks: false,
209
+ ignore: ["**/node_modules/**", "**/.git/**"]
210
+ }
211
+ );
212
+ const matchingPaths = [];
213
+ for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
214
+ try {
215
+ const microfrontendsJsonContent = readFileSync(
216
+ microfrontendsJsonPath,
217
+ "utf-8"
218
+ );
219
+ const microfrontendsJson = parse(microfrontendsJsonContent);
220
+ if (microfrontendsJson.applications[applicationName]) {
221
+ matchingPaths.push(microfrontendsJsonPath);
222
+ }
223
+ } catch (error) {
224
+ }
225
+ }
226
+ if (matchingPaths.length > 1) {
227
+ throw new Error(
228
+ `Found multiple default applications referencing "${applicationName}" in the repository, but only one is allowed.
229
+ ${matchingPaths.join("\n \u2022 ")}`
230
+ );
231
+ }
232
+ if (matchingPaths.length === 0) {
233
+ throw new Error(
234
+ `Could not find default application with "applications.${applicationName}"`
235
+ );
236
+ }
237
+ const [packageJsonPath] = matchingPaths;
238
+ return dirname(packageJsonPath);
239
+ } catch (error) {
240
+ return null;
241
+ }
242
+ }
243
+ function findDefaultMicrofrontendsPackage(opts) {
244
+ const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
245
+ if (configCache[cacheKey]) {
246
+ return configCache[cacheKey];
247
+ }
248
+ const result = findDefaultMicrofrontendsPackages(opts);
249
+ if (!result) {
250
+ throw new Error(
251
+ "Error trying to resolve the main microfrontends configuration"
252
+ );
253
+ }
254
+ configCache[cacheKey] = result;
255
+ return result;
157
256
  }
158
257
 
159
- // src/config/schema/utils/is-default-app.ts
160
- function isDefaultApp(a) {
161
- return !("routing" in a);
258
+ // src/config/microfrontends/utils/is-monorepo.ts
259
+ import fs2 from "node:fs";
260
+ import path2 from "node:path";
261
+ function isMonorepo({
262
+ repositoryRoot
263
+ }) {
264
+ try {
265
+ if (fs2.existsSync(path2.join(repositoryRoot, "pnpm-workspace.yaml"))) {
266
+ return true;
267
+ }
268
+ if (fs2.existsSync(path2.join(repositoryRoot, "vlt-workspaces.json"))) {
269
+ return true;
270
+ }
271
+ if (process.env.NX_WORKSPACE_ROOT === path2.resolve(repositoryRoot)) {
272
+ return true;
273
+ }
274
+ const packageJsonPath = path2.join(repositoryRoot, "package.json");
275
+ if (!fs2.existsSync(packageJsonPath)) {
276
+ return false;
277
+ }
278
+ const packageJson = JSON.parse(
279
+ fs2.readFileSync(packageJsonPath, "utf-8")
280
+ );
281
+ return packageJson.workspaces !== void 0;
282
+ } catch (error) {
283
+ console.error("Error determining if repository is a monorepo", error);
284
+ return false;
285
+ }
286
+ }
287
+
288
+ // src/config/microfrontends/utils/find-package-root.ts
289
+ import fs3 from "node:fs";
290
+ import path3 from "node:path";
291
+ var PACKAGE_JSON = "package.json";
292
+ function findPackageRoot(startDir) {
293
+ let currentDir = startDir || process.cwd();
294
+ while (currentDir !== path3.parse(currentDir).root) {
295
+ const pkgJsonPath = path3.join(currentDir, PACKAGE_JSON);
296
+ if (fs3.existsSync(pkgJsonPath)) {
297
+ return currentDir;
298
+ }
299
+ currentDir = path3.dirname(currentDir);
300
+ }
301
+ throw new Error(
302
+ "Package root not found. Specify the root of the package with the `package.root` option."
303
+ );
304
+ }
305
+
306
+ // src/config/microfrontends/utils/find-config.ts
307
+ import fs4 from "node:fs";
308
+ import { join } from "node:path";
309
+ function findConfig({ dir }) {
310
+ for (const filename of CONFIGURATION_FILENAMES) {
311
+ const maybeConfig = join(dir, filename);
312
+ if (fs4.existsSync(maybeConfig)) {
313
+ return maybeConfig;
314
+ }
315
+ }
316
+ return null;
162
317
  }
163
318
 
319
+ // src/config/microfrontends-config/isomorphic/index.ts
320
+ import { parse as parse2 } from "jsonc-parser";
321
+
164
322
  // src/config/microfrontends-config/client/index.ts
165
323
  import { pathToRegexp } from "path-to-regexp";
166
324
  var MicrofrontendConfigClient = class {
@@ -696,42 +854,28 @@ var MicrofrontendConfigIsomorphic = class {
696
854
  constructor({
697
855
  config,
698
856
  overrides,
699
- meta,
700
857
  opts
701
858
  }) {
702
859
  this.childApplications = {};
703
860
  MicrofrontendConfigIsomorphic.validate(config, opts);
704
861
  const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
705
862
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
706
- this.isMainConfig = isMainConfig(config);
707
- if (isMainConfig(config)) {
708
- for (const [appId, appConfig] of Object.entries(config.applications)) {
709
- const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
710
- if (isDefaultApp(appConfig)) {
711
- this.defaultApplication = new DefaultApplication(appId, {
712
- app: appConfig,
713
- overrides: appOverrides
714
- });
715
- } else {
716
- this.childApplications[appId] = new ChildApplication(appId, {
717
- app: appConfig,
718
- overrides: appOverrides
719
- });
720
- }
721
- }
722
- } else {
723
- this.partOf = config.partOf;
724
- const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
725
- this.childApplications[meta.fromApp] = new ChildApplication(
726
- meta.fromApp,
727
- {
728
- // we don't know routing because we're not in the main config
729
- app: { routing: [] },
863
+ let defaultApplication;
864
+ for (const [appId, appConfig] of Object.entries(config.applications)) {
865
+ const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
866
+ if (isDefaultApp(appConfig)) {
867
+ defaultApplication = new DefaultApplication(appId, {
868
+ app: appConfig,
730
869
  overrides: appOverrides
731
- }
732
- );
870
+ });
871
+ } else {
872
+ this.childApplications[appId] = new ChildApplication(appId, {
873
+ app: appConfig,
874
+ overrides: appOverrides
875
+ });
876
+ }
733
877
  }
734
- if (isMainConfig(config) && !this.defaultApplication) {
878
+ if (!defaultApplication) {
735
879
  throw new MicrofrontendError(
736
880
  "Could not find default application in microfrontends configuration",
737
881
  {
@@ -740,34 +884,30 @@ var MicrofrontendConfigIsomorphic = class {
740
884
  }
741
885
  );
742
886
  }
887
+ this.defaultApplication = defaultApplication;
743
888
  this.config = config;
744
889
  this.options = config.options;
745
890
  this.serialized = {
746
891
  config,
747
- overrides,
748
- meta
892
+ overrides
749
893
  };
750
894
  }
751
895
  static validate(config, opts) {
752
896
  const skipValidation = opts?.skipValidation ?? [];
753
- const c = typeof config === "string" ? parse(config) : config;
754
- if (isMainConfig(c)) {
755
- validateConfigPaths(c.applications);
756
- validateConfigDefaultApplication(c.applications);
757
- if (!skipValidation.includes("deprecatedFields")) {
758
- validateDeprecatedFields(c);
759
- }
897
+ const c = typeof config === "string" ? parse2(config) : config;
898
+ validateConfigPaths(c.applications);
899
+ validateConfigDefaultApplication(c.applications);
900
+ if (!skipValidation.includes("deprecatedFields")) {
901
+ validateDeprecatedFields(c);
760
902
  }
761
903
  return c;
762
904
  }
763
905
  static fromEnv({
764
- meta,
765
906
  cookies
766
907
  }) {
767
908
  return new MicrofrontendConfigIsomorphic({
768
- config: parse(getConfigStringFromEnv()),
769
- overrides: parseOverrides(cookies ?? []),
770
- meta
909
+ config: parse2(getConfigStringFromEnv()),
910
+ overrides: parseOverrides(cookies ?? [])
771
911
  });
772
912
  }
773
913
  isOverridesDisabled() {
@@ -792,7 +932,7 @@ var MicrofrontendConfigIsomorphic = class {
792
932
  ].filter(Boolean);
793
933
  }
794
934
  getApplication(name) {
795
- if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
935
+ if (this.defaultApplication.name === name || this.defaultApplication.packageName === name) {
796
936
  return this.defaultApplication;
797
937
  }
798
938
  const app = this.childApplications[name] || Object.values(this.childApplications).find(
@@ -810,7 +950,7 @@ var MicrofrontendConfigIsomorphic = class {
810
950
  return app;
811
951
  }
812
952
  getApplicationByProjectId(projectId) {
813
- if (this.defaultApplication?.projectId === projectId) {
953
+ if (this.defaultApplication.projectId === projectId) {
814
954
  return this.defaultApplication;
815
955
  }
816
956
  return Object.values(this.childApplications).find(
@@ -818,19 +958,9 @@ var MicrofrontendConfigIsomorphic = class {
818
958
  );
819
959
  }
820
960
  /**
821
- * Returns the default application. This can throw if the default application
822
- * is undefined ( )
961
+ * Returns the default application.
823
962
  */
824
963
  getDefaultApplication() {
825
- if (!this.defaultApplication) {
826
- throw new MicrofrontendError(
827
- "Could not find default application in microfrontends configuration",
828
- {
829
- type: "application",
830
- subtype: "not_found"
831
- }
832
- );
833
- }
834
964
  return this.defaultApplication;
835
965
  }
836
966
  /**
@@ -857,11 +987,9 @@ var MicrofrontendConfigIsomorphic = class {
857
987
  }
858
988
  ])
859
989
  );
860
- if (this.defaultApplication) {
861
- applications[this.defaultApplication.name] = {
862
- default: true
863
- };
864
- }
990
+ applications[this.defaultApplication.name] = {
991
+ default: true
992
+ };
865
993
  return new MicrofrontendConfigClient({
866
994
  applications
867
995
  });
@@ -871,304 +999,6 @@ var MicrofrontendConfigIsomorphic = class {
871
999
  }
872
1000
  };
873
1001
 
874
- // src/config/microfrontends-config/isomorphic/child.ts
875
- var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
876
- constructor({
877
- config,
878
- overrides,
879
- meta
880
- }) {
881
- super({ config, overrides, meta });
882
- this.isMainConfig = false;
883
- this.partOf = config.partOf;
884
- }
885
- };
886
-
887
- // src/config/microfrontends-config/isomorphic/main.ts
888
- var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
889
- constructor({
890
- config,
891
- overrides,
892
- meta
893
- }) {
894
- super({ config, overrides, meta });
895
- this.isMainConfig = true;
896
- const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
897
- let defaultApplication;
898
- for (const [appId, appConfig] of Object.entries(config.applications)) {
899
- const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
900
- if (isDefaultApp(appConfig)) {
901
- defaultApplication = new DefaultApplication(appId, {
902
- app: appConfig,
903
- overrides: appOverrides
904
- });
905
- } else {
906
- this.childApplications[appId] = new ChildApplication(appId, {
907
- app: appConfig,
908
- overrides: appOverrides
909
- });
910
- }
911
- }
912
- if (!defaultApplication) {
913
- throw new MicrofrontendError(
914
- "Could not find default application in microfrontends configuration",
915
- {
916
- type: "application",
917
- subtype: "not_found"
918
- }
919
- );
920
- }
921
- this.defaultApplication = defaultApplication;
922
- }
923
- };
924
-
925
- // src/config/microfrontends/isomorphic/index.ts
926
- var Microfrontends = class {
927
- constructor({
928
- config,
929
- overrides,
930
- meta
931
- }) {
932
- if (isMainConfig(config)) {
933
- this.config = new MicrofrontendMainConfig({ config, overrides, meta });
934
- } else {
935
- this.config = new MicrofrontendChildConfig({ config, overrides, meta });
936
- }
937
- }
938
- isChildConfig() {
939
- return this.config instanceof MicrofrontendChildConfig;
940
- }
941
- static fromEnv({
942
- cookies,
943
- meta
944
- }) {
945
- const config = MicrofrontendConfigIsomorphic.fromEnv({
946
- cookies,
947
- meta
948
- });
949
- return new Microfrontends(config.serialize());
950
- }
951
- };
952
-
953
- // src/config/microfrontends/utils/find-repository-root.ts
954
- import fs from "node:fs";
955
- import path from "node:path";
956
- var GIT_DIRECTORY = ".git";
957
- function hasGitDirectory(dir) {
958
- const gitPath = path.join(dir, GIT_DIRECTORY);
959
- return fs.existsSync(gitPath) && fs.statSync(gitPath).isDirectory();
960
- }
961
- function hasPnpmWorkspaces(dir) {
962
- return fs.existsSync(path.join(dir, "pnpm-workspace.yaml"));
963
- }
964
- function findRepositoryRoot(startDir) {
965
- if (process.env.NX_WORKSPACE_ROOT) {
966
- return process.env.NX_WORKSPACE_ROOT;
967
- }
968
- let currentDir = startDir || process.cwd();
969
- while (currentDir !== path.parse(currentDir).root) {
970
- if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
971
- return currentDir;
972
- }
973
- currentDir = path.dirname(currentDir);
974
- }
975
- throw new Error(
976
- "Repository root not found. Specify the root of the repository with the `repository.root` option."
977
- );
978
- }
979
-
980
- // src/config/microfrontends/utils/find-package-path.ts
981
- import { dirname } from "node:path";
982
- import { readFileSync } from "node:fs";
983
- import fg from "fast-glob";
984
- var configCache = {};
985
- function findPackagePathWithGlob({
986
- repositoryRoot,
987
- name
988
- }) {
989
- try {
990
- const packageJsonPaths = fg.globSync("**/package.json", {
991
- cwd: repositoryRoot,
992
- absolute: true,
993
- onlyFiles: true,
994
- followSymbolicLinks: false,
995
- ignore: ["**/node_modules/**", "**/.git/**"]
996
- });
997
- const matchingPaths = [];
998
- for (const packageJsonPath2 of packageJsonPaths) {
999
- const packageJsonContent = readFileSync(packageJsonPath2, "utf-8");
1000
- const packageJson = JSON.parse(packageJsonContent);
1001
- if (packageJson.name === name) {
1002
- matchingPaths.push(packageJsonPath2);
1003
- }
1004
- }
1005
- if (matchingPaths.length > 1) {
1006
- throw new Error(
1007
- `Found multiple packages with the name "${name}" in the repository: ${matchingPaths.join(", ")}`
1008
- );
1009
- }
1010
- if (matchingPaths.length === 0) {
1011
- throw new Error(
1012
- `Could not find package with the name "${name}" in the repository`
1013
- );
1014
- }
1015
- const [packageJsonPath] = matchingPaths;
1016
- return dirname(packageJsonPath);
1017
- } catch (error) {
1018
- return null;
1019
- }
1020
- }
1021
- function findPackagePath(opts) {
1022
- const cacheKey = `${opts.repositoryRoot}-${opts.name}`;
1023
- if (configCache[cacheKey]) {
1024
- return configCache[cacheKey];
1025
- }
1026
- const result = findPackagePathWithGlob(opts);
1027
- if (!result) {
1028
- throw new Error(
1029
- `Could not find package with the name "${opts.name}" in the repository`
1030
- );
1031
- }
1032
- configCache[cacheKey] = result;
1033
- return result;
1034
- }
1035
-
1036
- // src/config/microfrontends/utils/find-default-package.ts
1037
- import { dirname as dirname2 } from "node:path";
1038
- import { readFileSync as readFileSync2 } from "node:fs";
1039
- import { parse as parse2 } from "jsonc-parser";
1040
- import fg2 from "fast-glob";
1041
-
1042
- // src/config/constants.ts
1043
- var CONFIGURATION_FILENAMES = [
1044
- "microfrontends.jsonc",
1045
- "microfrontends.json"
1046
- ];
1047
-
1048
- // src/config/microfrontends/utils/find-default-package.ts
1049
- var configCache2 = {};
1050
- function findDefaultMicrofrontendsPackages({
1051
- repositoryRoot,
1052
- applicationName
1053
- }) {
1054
- try {
1055
- const microfrontendsJsonPaths = fg2.globSync(
1056
- `**/{${CONFIGURATION_FILENAMES.join(",")}}`,
1057
- {
1058
- cwd: repositoryRoot,
1059
- absolute: true,
1060
- onlyFiles: true,
1061
- followSymbolicLinks: false,
1062
- ignore: ["**/node_modules/**", "**/.git/**"]
1063
- }
1064
- );
1065
- const matchingPaths = [];
1066
- for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
1067
- try {
1068
- const microfrontendsJsonContent = readFileSync2(
1069
- microfrontendsJsonPath,
1070
- "utf-8"
1071
- );
1072
- const microfrontendsJson = parse2(microfrontendsJsonContent);
1073
- if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
1074
- matchingPaths.push(microfrontendsJsonPath);
1075
- }
1076
- } catch (error) {
1077
- }
1078
- }
1079
- if (matchingPaths.length > 1) {
1080
- throw new Error(
1081
- `Found multiple default applications referencing "${applicationName}" in the repository, but only one is allowed.
1082
- ${matchingPaths.join("\n \u2022 ")}`
1083
- );
1084
- }
1085
- if (matchingPaths.length === 0) {
1086
- throw new Error(
1087
- `Could not find default application with "applications.${applicationName}"`
1088
- );
1089
- }
1090
- const [packageJsonPath] = matchingPaths;
1091
- return dirname2(packageJsonPath);
1092
- } catch (error) {
1093
- return null;
1094
- }
1095
- }
1096
- function findDefaultMicrofrontendsPackage(opts) {
1097
- const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
1098
- if (configCache2[cacheKey]) {
1099
- return configCache2[cacheKey];
1100
- }
1101
- const result = findDefaultMicrofrontendsPackages(opts);
1102
- if (!result) {
1103
- throw new Error(
1104
- "Error trying to resolve the main microfrontends configuration"
1105
- );
1106
- }
1107
- configCache2[cacheKey] = result;
1108
- return result;
1109
- }
1110
-
1111
- // src/config/microfrontends/utils/is-monorepo.ts
1112
- import fs2 from "node:fs";
1113
- import path2 from "node:path";
1114
- function isMonorepo({
1115
- repositoryRoot
1116
- }) {
1117
- try {
1118
- if (fs2.existsSync(path2.join(repositoryRoot, "pnpm-workspace.yaml"))) {
1119
- return true;
1120
- }
1121
- if (fs2.existsSync(path2.join(repositoryRoot, "vlt-workspaces.json"))) {
1122
- return true;
1123
- }
1124
- if (process.env.NX_WORKSPACE_ROOT === path2.resolve(repositoryRoot)) {
1125
- return true;
1126
- }
1127
- const packageJsonPath = path2.join(repositoryRoot, "package.json");
1128
- if (!fs2.existsSync(packageJsonPath)) {
1129
- return false;
1130
- }
1131
- const packageJson = JSON.parse(
1132
- fs2.readFileSync(packageJsonPath, "utf-8")
1133
- );
1134
- return packageJson.workspaces !== void 0;
1135
- } catch (error) {
1136
- console.error("Error determining if repository is a monorepo", error);
1137
- return false;
1138
- }
1139
- }
1140
-
1141
- // src/config/microfrontends/utils/find-package-root.ts
1142
- import fs3 from "node:fs";
1143
- import path3 from "node:path";
1144
- var PACKAGE_JSON = "package.json";
1145
- function findPackageRoot(startDir) {
1146
- let currentDir = startDir || process.cwd();
1147
- while (currentDir !== path3.parse(currentDir).root) {
1148
- const pkgJsonPath = path3.join(currentDir, PACKAGE_JSON);
1149
- if (fs3.existsSync(pkgJsonPath)) {
1150
- return currentDir;
1151
- }
1152
- currentDir = path3.dirname(currentDir);
1153
- }
1154
- throw new Error(
1155
- "Package root not found. Specify the root of the package with the `package.root` option."
1156
- );
1157
- }
1158
-
1159
- // src/config/microfrontends/utils/find-config.ts
1160
- import fs4 from "node:fs";
1161
- import { join } from "node:path";
1162
- function findConfig({ dir }) {
1163
- for (const filename of CONFIGURATION_FILENAMES) {
1164
- const maybeConfig = join(dir, filename);
1165
- if (fs4.existsSync(maybeConfig)) {
1166
- return maybeConfig;
1167
- }
1168
- }
1169
- return null;
1170
- }
1171
-
1172
1002
  // src/config/microfrontends/utils/get-application-context.ts
1173
1003
  import fs5 from "node:fs";
1174
1004
  import path4 from "node:path";
@@ -1225,16 +1055,6 @@ var schema_default = {
1225
1055
  $ref: "#/definitions/Config",
1226
1056
  definitions: {
1227
1057
  Config: {
1228
- anyOf: [
1229
- {
1230
- $ref: "#/definitions/MainConfig"
1231
- },
1232
- {
1233
- $ref: "#/definitions/ChildConfig"
1234
- }
1235
- ]
1236
- },
1237
- MainConfig: {
1238
1058
  type: "object",
1239
1059
  properties: {
1240
1060
  $schema: {
@@ -1491,27 +1311,6 @@ var schema_default = {
1491
1311
  },
1492
1312
  required: ["paths"],
1493
1313
  additionalProperties: false
1494
- },
1495
- ChildConfig: {
1496
- type: "object",
1497
- properties: {
1498
- $schema: {
1499
- type: "string"
1500
- },
1501
- version: {
1502
- type: "string",
1503
- const: "1"
1504
- },
1505
- options: {
1506
- $ref: "#/definitions/Options"
1507
- },
1508
- partOf: {
1509
- type: "string",
1510
- 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."
1511
- }
1512
- },
1513
- required: ["partOf"],
1514
- additionalProperties: false
1515
1314
  }
1516
1315
  }
1517
1316
  };
@@ -1589,7 +1388,13 @@ See https://openapi.vercel.sh/microfrontends.json for the schema.`,
1589
1388
  }
1590
1389
 
1591
1390
  // src/config/microfrontends/server/index.ts
1592
- var MicrofrontendsServer = class extends Microfrontends {
1391
+ var MicrofrontendsServer = class {
1392
+ constructor({
1393
+ config,
1394
+ overrides
1395
+ }) {
1396
+ this.config = new MicrofrontendConfigIsomorphic({ config, overrides });
1397
+ }
1593
1398
  /**
1594
1399
  * Writes the configuration to a file.
1595
1400
  */
@@ -1597,7 +1402,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1597
1402
  pretty: true
1598
1403
  }) {
1599
1404
  const outputPath = getOutputFilePath();
1600
- fs6.mkdirSync(dirname3(outputPath), { recursive: true });
1405
+ fs6.mkdirSync(dirname2(outputPath), { recursive: true });
1601
1406
  fs6.writeFileSync(
1602
1407
  outputPath,
1603
1408
  JSON.stringify(
@@ -1613,22 +1418,19 @@ var MicrofrontendsServer = class extends Microfrontends {
1613
1418
  */
1614
1419
  static fromUnknown({
1615
1420
  config,
1616
- cookies,
1617
- meta
1421
+ cookies
1618
1422
  }) {
1619
1423
  const overrides = cookies ? parseOverrides(cookies) : void 0;
1620
1424
  if (typeof config === "string") {
1621
1425
  return new MicrofrontendsServer({
1622
1426
  config: MicrofrontendsServer.validate(config),
1623
- overrides,
1624
- meta
1427
+ overrides
1625
1428
  });
1626
1429
  }
1627
1430
  if (typeof config === "object") {
1628
1431
  return new MicrofrontendsServer({
1629
1432
  config,
1630
- overrides,
1631
- meta
1433
+ overrides
1632
1434
  });
1633
1435
  }
1634
1436
  throw new MicrofrontendError(
@@ -1641,13 +1443,11 @@ var MicrofrontendsServer = class extends Microfrontends {
1641
1443
  * Uses additional validation that is only available when in a node runtime
1642
1444
  */
1643
1445
  static fromEnv({
1644
- cookies,
1645
- meta
1446
+ cookies
1646
1447
  }) {
1647
1448
  return new MicrofrontendsServer({
1648
1449
  config: MicrofrontendsServer.validate(getConfigStringFromEnv()),
1649
- overrides: parseOverrides(cookies),
1650
- meta
1450
+ overrides: parseOverrides(cookies)
1651
1451
  });
1652
1452
  }
1653
1453
  /**
@@ -1670,29 +1470,22 @@ var MicrofrontendsServer = class extends Microfrontends {
1670
1470
  static infer({
1671
1471
  directory,
1672
1472
  filePath,
1673
- meta,
1674
- cookies,
1675
- options
1473
+ cookies
1676
1474
  } = {}) {
1677
- if (filePath && meta) {
1475
+ if (filePath) {
1678
1476
  return MicrofrontendsServer.fromFile({
1679
1477
  filePath,
1680
- cookies,
1681
- meta,
1682
- options
1478
+ cookies
1683
1479
  });
1684
1480
  }
1685
1481
  try {
1686
1482
  const packageRoot = findPackageRoot(directory);
1687
1483
  const { name: appName } = getApplicationContext({ packageRoot });
1688
- const configMeta = meta ?? { fromApp: appName };
1689
1484
  const maybeConfig = findConfig({ dir: packageRoot });
1690
1485
  if (maybeConfig) {
1691
1486
  return MicrofrontendsServer.fromFile({
1692
1487
  filePath: maybeConfig,
1693
- cookies,
1694
- meta: configMeta,
1695
- options
1488
+ cookies
1696
1489
  });
1697
1490
  }
1698
1491
  const repositoryRoot = findRepositoryRoot();
@@ -1706,9 +1499,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1706
1499
  if (maybeConfigFromDefault) {
1707
1500
  return MicrofrontendsServer.fromFile({
1708
1501
  filePath: maybeConfigFromDefault,
1709
- cookies,
1710
- meta: configMeta,
1711
- options
1502
+ cookies
1712
1503
  });
1713
1504
  }
1714
1505
  }
@@ -1728,44 +1519,14 @@ var MicrofrontendsServer = class extends Microfrontends {
1728
1519
  */
1729
1520
  static fromFile({
1730
1521
  filePath,
1731
- cookies,
1732
- meta,
1733
- options
1522
+ cookies
1734
1523
  }) {
1735
1524
  try {
1736
1525
  const configJson = fs6.readFileSync(filePath, "utf-8");
1737
1526
  const config = MicrofrontendsServer.validate(configJson);
1738
- if (!isMainConfig(config) && options?.resolveMainConfig) {
1739
- const repositoryRoot = findRepositoryRoot();
1740
- const isMonorepo2 = isMonorepo({ repositoryRoot });
1741
- if (isMonorepo2) {
1742
- const packagePath = findPackagePath({
1743
- repositoryRoot,
1744
- name: config.partOf
1745
- });
1746
- if (!packagePath) {
1747
- throw new MicrofrontendError(
1748
- `Could not find default application "${config.partOf}" in the repository`,
1749
- { type: "config", subtype: "not_found" }
1750
- );
1751
- }
1752
- const maybeConfig = findConfig({ dir: packagePath });
1753
- if (!maybeConfig) {
1754
- throw new MicrofrontendError(
1755
- `Could not find microfrontends configuration in ${packagePath}`,
1756
- { type: "config", subtype: "not_found" }
1757
- );
1758
- }
1759
- return MicrofrontendsServer.fromMainConfigFile({
1760
- filePath: maybeConfig,
1761
- overrides: cookies ? parseOverrides(cookies) : void 0
1762
- });
1763
- }
1764
- }
1765
1527
  return new MicrofrontendsServer({
1766
1528
  config,
1767
- overrides: cookies ? parseOverrides(cookies) : void 0,
1768
- meta
1529
+ overrides: cookies ? parseOverrides(cookies) : void 0
1769
1530
  });
1770
1531
  } catch (e) {
1771
1532
  throw MicrofrontendError.handle(e, {
@@ -1774,7 +1535,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1774
1535
  }
1775
1536
  }
1776
1537
  /*
1777
- * Generates a MicrofrontendMainConfig instance from a file.
1538
+ * Generates a MicrofrontendsServer instance from a file.
1778
1539
  */
1779
1540
  static fromMainConfigFile({
1780
1541
  filePath,
@@ -1783,15 +1544,6 @@ var MicrofrontendsServer = class extends Microfrontends {
1783
1544
  try {
1784
1545
  const config = fs6.readFileSync(filePath, "utf-8");
1785
1546
  const validatedConfig = MicrofrontendsServer.validate(config);
1786
- if (!isMainConfig(validatedConfig)) {
1787
- throw new MicrofrontendError(
1788
- `${filePath} is not a main microfrontend config`,
1789
- {
1790
- type: "config",
1791
- subtype: "invalid_main_path"
1792
- }
1793
- );
1794
- }
1795
1547
  const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
1796
1548
  if (!defaultApplication) {
1797
1549
  throw new MicrofrontendError(
@@ -1801,8 +1553,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1801
1553
  }
1802
1554
  return new MicrofrontendsServer({
1803
1555
  config: validatedConfig,
1804
- overrides,
1805
- meta: { fromApp: defaultApplication }
1556
+ overrides
1806
1557
  });
1807
1558
  } catch (e) {
1808
1559
  throw MicrofrontendError.handle(e, {
@@ -1816,10 +1567,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1816
1567
  function withMicrofrontends(config, opts) {
1817
1568
  const { name: fromApp } = getApplicationContext(opts);
1818
1569
  const microfrontends = MicrofrontendsServer.infer({
1819
- filePath: opts?.configPath,
1820
- meta: {
1821
- fromApp
1822
- }
1570
+ filePath: opts?.configPath
1823
1571
  });
1824
1572
  const app = microfrontends.config.getApplication(fromApp);
1825
1573
  if (!app.isDefault()) {