@vercel/microfrontends 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +3 -3
  2. package/dist/bin/cli.cjs +403 -1627
  3. package/dist/config.cjs +460 -1004
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +4 -25
  6. package/dist/config.js +456 -983
  7. package/dist/config.js.map +1 -1
  8. package/dist/{index-83133f2d.d.ts → index-bf67a461.d.ts} +3 -10
  9. package/dist/{v2/microfrontends → microfrontends}/server.cjs +128 -194
  10. package/dist/microfrontends/server.cjs.map +1 -0
  11. package/dist/{v2/microfrontends → microfrontends}/server.d.ts +6 -5
  12. package/dist/{v2/microfrontends → microfrontends}/server.js +125 -191
  13. package/dist/microfrontends/server.js.map +1 -0
  14. package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +21 -35
  15. package/dist/microfrontends.cjs.map +1 -0
  16. package/dist/{v2/microfrontends.d.ts → microfrontends.d.ts} +4 -3
  17. package/dist/{v2/microfrontends.js → microfrontends.js} +20 -34
  18. package/dist/microfrontends.js.map +1 -0
  19. package/dist/next/client.cjs +1 -1
  20. package/dist/next/client.cjs.map +1 -1
  21. package/dist/next/client.js +1 -1
  22. package/dist/next/client.js.map +1 -1
  23. package/dist/next/config.cjs +1323 -1024
  24. package/dist/next/config.cjs.map +1 -1
  25. package/dist/next/config.d.ts +1 -1
  26. package/dist/next/config.js +1327 -1028
  27. package/dist/next/config.js.map +1 -1
  28. package/dist/next/endpoints.cjs +77 -18
  29. package/dist/next/endpoints.cjs.map +1 -1
  30. package/dist/next/endpoints.d.ts +14 -3
  31. package/dist/next/endpoints.js +77 -18
  32. package/dist/next/endpoints.js.map +1 -1
  33. package/dist/next/middleware.cjs +745 -425
  34. package/dist/next/middleware.cjs.map +1 -1
  35. package/dist/next/middleware.d.ts +10 -5
  36. package/dist/next/middleware.js +745 -425
  37. package/dist/next/middleware.js.map +1 -1
  38. package/dist/next/testing.cjs +595 -1032
  39. package/dist/next/testing.cjs.map +1 -1
  40. package/dist/next/testing.d.ts +14 -12
  41. package/dist/next/testing.js +589 -1016
  42. package/dist/next/testing.js.map +1 -1
  43. package/dist/overrides.cjs +40 -108
  44. package/dist/overrides.cjs.map +1 -1
  45. package/dist/overrides.d.ts +24 -2
  46. package/dist/overrides.js +36 -106
  47. package/dist/overrides.js.map +1 -1
  48. package/dist/routing.cjs +19 -0
  49. package/dist/routing.cjs.map +1 -0
  50. package/dist/routing.d.ts +26 -0
  51. package/dist/routing.js +1 -0
  52. package/dist/{v2/schema.cjs → schema.cjs} +1 -1
  53. package/dist/schema.cjs.map +1 -0
  54. package/dist/schema.d.ts +1 -0
  55. package/dist/schema.js.map +1 -0
  56. package/dist/{types-a995174e.d.ts → types-a29d224a.d.ts} +1 -7
  57. package/dist/{types-15b7f215.d.ts → types-cfe3308b.d.ts} +1 -1
  58. package/dist/types-fc30696d.d.ts +11 -0
  59. package/dist/utils/mfe-port.cjs +254 -1362
  60. package/dist/utils/mfe-port.cjs.map +1 -1
  61. package/dist/utils/mfe-port.js +250 -1358
  62. package/dist/utils/mfe-port.js.map +1 -1
  63. package/dist/validation.cjs +31 -365
  64. package/dist/validation.cjs.map +1 -1
  65. package/dist/validation.d.ts +3 -152
  66. package/dist/validation.js +30 -363
  67. package/dist/validation.js.map +1 -1
  68. package/package.json +32 -80
  69. package/schema/schema.json +174 -244
  70. package/dist/config/client.cjs +0 -54
  71. package/dist/config/client.cjs.map +0 -1
  72. package/dist/config/client.d.ts +0 -23
  73. package/dist/config/client.js +0 -28
  74. package/dist/config/client.js.map +0 -1
  75. package/dist/config/edge.cjs +0 -508
  76. package/dist/config/edge.cjs.map +0 -1
  77. package/dist/config/edge.d.ts +0 -20
  78. package/dist/config/edge.js +0 -481
  79. package/dist/config/edge.js.map +0 -1
  80. package/dist/microfrontend-config-983a5139.d.ts +0 -154
  81. package/dist/schema-2922d49e.d.ts +0 -182
  82. package/dist/v2/config.cjs +0 -723
  83. package/dist/v2/config.cjs.map +0 -1
  84. package/dist/v2/config.d.ts +0 -3
  85. package/dist/v2/config.js +0 -698
  86. package/dist/v2/config.js.map +0 -1
  87. package/dist/v2/microfrontends/server.cjs.map +0 -1
  88. package/dist/v2/microfrontends/server.js.map +0 -1
  89. package/dist/v2/microfrontends.cjs.map +0 -1
  90. package/dist/v2/microfrontends.js.map +0 -1
  91. package/dist/v2/next/client.cjs +0 -3
  92. package/dist/v2/next/client.cjs.map +0 -1
  93. package/dist/v2/next/client.d.ts +0 -45
  94. package/dist/v2/next/client.js +0 -3
  95. package/dist/v2/next/client.js.map +0 -1
  96. package/dist/v2/next/config.cjs +0 -2132
  97. package/dist/v2/next/config.cjs.map +0 -1
  98. package/dist/v2/next/config.d.ts +0 -22
  99. package/dist/v2/next/config.js +0 -2097
  100. package/dist/v2/next/config.js.map +0 -1
  101. package/dist/v2/next/endpoints.cjs +0 -141
  102. package/dist/v2/next/endpoints.cjs.map +0 -1
  103. package/dist/v2/next/endpoints.d.ts +0 -15
  104. package/dist/v2/next/endpoints.js +0 -116
  105. package/dist/v2/next/endpoints.js.map +0 -1
  106. package/dist/v2/next/middleware.cjs +0 -1143
  107. package/dist/v2/next/middleware.cjs.map +0 -1
  108. package/dist/v2/next/middleware.d.ts +0 -29
  109. package/dist/v2/next/middleware.js +0 -1115
  110. package/dist/v2/next/middleware.js.map +0 -1
  111. package/dist/v2/overrides.cjs +0 -75
  112. package/dist/v2/overrides.cjs.map +0 -1
  113. package/dist/v2/overrides.d.ts +0 -24
  114. package/dist/v2/overrides.js +0 -45
  115. package/dist/v2/overrides.js.map +0 -1
  116. package/dist/v2/schema.cjs.map +0 -1
  117. package/dist/v2/schema.d.ts +0 -1
  118. package/schema/schema-v2.json +0 -270
  119. /package/dist/{v2/schema.js.map → routing.js.map} +0 -0
  120. /package/dist/{v2/schema.js → schema.js} +0 -0
@@ -27,26 +27,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/config-v2/microfrontends/server/index.ts
30
+ // src/config/microfrontends/server/index.ts
31
31
  var server_exports = {};
32
32
  __export(server_exports, {
33
33
  MicrofrontendsServer: () => MicrofrontendsServer
34
34
  });
35
35
  module.exports = __toCommonJS(server_exports);
36
- var import_node_fs6 = __toESM(require("fs"), 1);
37
- var import_node_path7 = require("path");
36
+ var import_node_fs7 = __toESM(require("fs"), 1);
37
+ var import_node_path8 = require("path");
38
38
 
39
- // src/config-v2/overrides/constants.ts
39
+ // src/config/overrides/constants.ts
40
40
  var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
41
41
  var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
42
42
 
43
- // src/config-v2/overrides/is-override-cookie.ts
43
+ // src/config/overrides/is-override-cookie.ts
44
44
  function isOverrideCookie(cookie) {
45
45
  var _a;
46
46
  return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
47
47
  }
48
48
 
49
- // src/config-v2/overrides/get-override-from-cookie.ts
49
+ // src/config/overrides/get-override-from-cookie.ts
50
50
  function getOverrideFromCookie(cookie) {
51
51
  if (!isOverrideCookie(cookie) || !cookie.value)
52
52
  return;
@@ -56,7 +56,7 @@ function getOverrideFromCookie(cookie) {
56
56
  };
57
57
  }
58
58
 
59
- // src/config-v2/overrides/parse-overrides.ts
59
+ // src/config/overrides/parse-overrides.ts
60
60
  function parseOverrides(cookies) {
61
61
  const overridesConfig = { applications: {} };
62
62
  cookies.forEach((cookie) => {
@@ -70,7 +70,7 @@ function parseOverrides(cookies) {
70
70
  return overridesConfig;
71
71
  }
72
72
 
73
- // src/config-v2/errors.ts
73
+ // src/config/errors.ts
74
74
  var MicrofrontendError = class extends Error {
75
75
  constructor(message, opts) {
76
76
  super(message);
@@ -162,7 +162,7 @@ var MicrofrontendError = class extends Error {
162
162
  }
163
163
  };
164
164
 
165
- // src/config-v2/microfrontends-config/utils/get-config-from-env.ts
165
+ // src/config/microfrontends-config/utils/get-config-from-env.ts
166
166
  function getConfigStringFromEnv() {
167
167
  const config = process.env.MFE_CONFIG;
168
168
  if (!config) {
@@ -174,20 +174,20 @@ function getConfigStringFromEnv() {
174
174
  return config;
175
175
  }
176
176
 
177
- // src/config-v2/microfrontends-config/isomorphic/index.ts
177
+ // src/config/microfrontends-config/isomorphic/index.ts
178
178
  var import_jsonc_parser = require("jsonc-parser");
179
179
 
180
- // src/config-v2/schema/utils/is-main-config.ts
180
+ // src/config/schema/utils/is-main-config.ts
181
181
  function isMainConfig(c) {
182
182
  return !("partOf" in c);
183
183
  }
184
184
 
185
- // src/config-v2/schema/utils/is-default-app.ts
185
+ // src/config/schema/utils/is-default-app.ts
186
186
  function isDefaultApp(a) {
187
187
  return !("routing" in a);
188
188
  }
189
189
 
190
- // src/config-v2/microfrontends-config/client/index.ts
190
+ // src/config/microfrontends-config/client/index.ts
191
191
  var import_path_to_regexp = require("path-to-regexp");
192
192
  var MicrofrontendConfigClient = class {
193
193
  constructor(config, opts) {
@@ -253,7 +253,7 @@ var MicrofrontendConfigClient = class {
253
253
  }
254
254
  };
255
255
 
256
- // src/config-v2/microfrontends-config/isomorphic/validation.ts
256
+ // src/config/microfrontends-config/isomorphic/validation.ts
257
257
  var import_path_to_regexp2 = require("path-to-regexp");
258
258
  var SUPPORTED_VERSIONS = ["2"];
259
259
  var validateConfigVersion = (version) => {
@@ -381,21 +381,8 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
381
381
  );
382
382
  }
383
383
  };
384
- var validateConfigOptions = (options) => {
385
- var _a;
386
- if ((_a = options == null ? void 0 : options.vercel) == null ? void 0 : _a.previewDeploymentSuffix) {
387
- if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
388
- options.vercel.previewDeploymentSuffix
389
- )) {
390
- throw new MicrofrontendError(
391
- `Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
392
- { type: "config", subtype: "invalid_preview_deployment_suffix" }
393
- );
394
- }
395
- }
396
- };
397
384
 
398
- // src/config-v2/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
385
+ // src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
399
386
  var PREFIX = "vc-ap";
400
387
  function generateAssetPrefixFromName({
401
388
  name
@@ -406,7 +393,7 @@ function generateAssetPrefixFromName({
406
393
  return `${PREFIX}-${name}`;
407
394
  }
408
395
 
409
- // src/config-v2/microfrontends-config/isomorphic/utils/generate-port.ts
396
+ // src/config/microfrontends-config/isomorphic/utils/generate-port.ts
410
397
  function generatePortFromName({
411
398
  name,
412
399
  minPort = 3e3,
@@ -426,7 +413,7 @@ function generatePortFromName({
426
413
  return port;
427
414
  }
428
415
 
429
- // src/config-v2/microfrontends-config/isomorphic/host.ts
416
+ // src/config/microfrontends-config/isomorphic/host.ts
430
417
  var Host = class {
431
418
  constructor(hostConfig, options) {
432
419
  const { protocol = "https", host, port } = hostConfig;
@@ -475,7 +462,7 @@ var LocalHost = class extends Host {
475
462
  }
476
463
  };
477
464
 
478
- // src/config-v2/microfrontends-config/isomorphic/application.ts
465
+ // src/config/microfrontends-config/isomorphic/application.ts
479
466
  var Application = class {
480
467
  constructor(name, {
481
468
  app,
@@ -545,10 +532,10 @@ var ChildApplication = class extends Application {
545
532
  }
546
533
  };
547
534
 
548
- // src/config-v2/microfrontends-config/isomorphic/constants.ts
535
+ // src/config/microfrontends-config/isomorphic/constants.ts
549
536
  var DEFAULT_LOCAL_PROXY_PORT = 3024;
550
537
 
551
- // src/config-v2/microfrontends-config/isomorphic/index.ts
538
+ // src/config/microfrontends-config/isomorphic/index.ts
552
539
  var MicrofrontendConfigIsomorphic = class {
553
540
  constructor({
554
541
  config,
@@ -612,7 +599,6 @@ var MicrofrontendConfigIsomorphic = class {
612
599
  validateConfigPaths(c.applications);
613
600
  validateConfigDefaultApplication(c.applications);
614
601
  }
615
- validateConfigOptions(c.options);
616
602
  return c;
617
603
  }
618
604
  static fromEnv({
@@ -731,7 +717,7 @@ var MicrofrontendConfigIsomorphic = class {
731
717
  }
732
718
  };
733
719
 
734
- // src/config-v2/microfrontends-config/isomorphic/child.ts
720
+ // src/config/microfrontends-config/isomorphic/child.ts
735
721
  var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
736
722
  constructor({
737
723
  config,
@@ -744,7 +730,7 @@ var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
744
730
  }
745
731
  };
746
732
 
747
- // src/config-v2/microfrontends-config/isomorphic/main.ts
733
+ // src/config/microfrontends-config/isomorphic/main.ts
748
734
  var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
749
735
  constructor({
750
736
  config,
@@ -783,7 +769,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
783
769
  }
784
770
  };
785
771
 
786
- // src/config-v2/microfrontends/isomorphic/index.ts
772
+ // src/config/microfrontends/isomorphic/index.ts
787
773
  var Microfrontends = class {
788
774
  constructor({
789
775
  config,
@@ -811,7 +797,7 @@ var Microfrontends = class {
811
797
  }
812
798
  };
813
799
 
814
- // src/config-v2/microfrontends/utils/find-repository-root.ts
800
+ // src/config/microfrontends/utils/find-repository-root.ts
815
801
  var import_node_fs = __toESM(require("fs"), 1);
816
802
  var import_node_path = __toESM(require("path"), 1);
817
803
  var GIT_DIRECTORY = ".git";
@@ -829,7 +815,7 @@ function findRepositoryRoot(startDir) {
829
815
  );
830
816
  }
831
817
 
832
- // src/config-v2/microfrontends/utils/find-package-path.ts
818
+ // src/config/microfrontends/utils/find-package-path.ts
833
819
  var import_node_path2 = require("path");
834
820
  var import_node_fs2 = require("fs");
835
821
  var import_fast_glob = __toESM(require("fast-glob"), 1);
@@ -885,32 +871,42 @@ function findPackagePath(opts) {
885
871
  return result;
886
872
  }
887
873
 
888
- // src/config-v2/microfrontends/utils/find-default-package.ts
874
+ // src/config/microfrontends/utils/find-default-package.ts
889
875
  var import_node_path3 = require("path");
890
876
  var import_node_fs3 = require("fs");
877
+ var import_jsonc_parser2 = require("jsonc-parser");
891
878
  var import_fast_glob2 = __toESM(require("fast-glob"), 1);
879
+
880
+ // src/config/constants.ts
881
+ var CONFIGURATION_FILENAMES = [
882
+ "microfrontends.jsonc",
883
+ "microfrontends.json"
884
+ ];
885
+
886
+ // src/config/microfrontends/utils/find-default-package.ts
892
887
  var configCache2 = {};
893
888
  function findDefaultMicrofrontendsPackages({
894
889
  repositoryRoot,
895
890
  applicationName
896
891
  }) {
897
892
  try {
898
- const microfrontendsJsonPaths = import_fast_glob2.default.globSync("**/microfrontends.json", {
899
- cwd: repositoryRoot,
900
- absolute: true,
901
- onlyFiles: true,
902
- followSymbolicLinks: false,
903
- ignore: ["**/node_modules/**", "**/.git/**"]
904
- });
893
+ const microfrontendsJsonPaths = import_fast_glob2.default.globSync(
894
+ `**/{${CONFIGURATION_FILENAMES.join(",")}}`,
895
+ {
896
+ cwd: repositoryRoot,
897
+ absolute: true,
898
+ onlyFiles: true,
899
+ followSymbolicLinks: false,
900
+ ignore: ["**/node_modules/**", "**/.git/**"]
901
+ }
902
+ );
905
903
  const matchingPaths = [];
906
904
  for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
907
905
  const microfrontendsJsonContent = (0, import_node_fs3.readFileSync)(
908
906
  microfrontendsJsonPath,
909
907
  "utf-8"
910
908
  );
911
- const microfrontendsJson = JSON.parse(
912
- microfrontendsJsonContent
913
- );
909
+ const microfrontendsJson = (0, import_jsonc_parser2.parse)(microfrontendsJsonContent);
914
910
  if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
915
911
  matchingPaths.push(microfrontendsJsonPath);
916
912
  }
@@ -940,14 +936,14 @@ function findDefaultMicrofrontendsPackage(opts) {
940
936
  const result = findDefaultMicrofrontendsPackages(opts);
941
937
  if (!result) {
942
938
  throw new Error(
943
- `Error trying to resolve the main microfrontends.json configuration`
939
+ `Error trying to resolve the main microfrontends configuration`
944
940
  );
945
941
  }
946
942
  configCache2[cacheKey] = result;
947
943
  return result;
948
944
  }
949
945
 
950
- // src/config-v2/microfrontends/utils/is-monorepo.ts
946
+ // src/config/microfrontends/utils/is-monorepo.ts
951
947
  var import_node_fs4 = __toESM(require("fs"), 1);
952
948
  var import_node_path4 = __toESM(require("path"), 1);
953
949
  function isMonorepo({
@@ -974,7 +970,7 @@ function isMonorepo({
974
970
  }
975
971
  }
976
972
 
977
- // src/config-v2/microfrontends/utils/find-package-root.ts
973
+ // src/config/microfrontends/utils/find-package-root.ts
978
974
  var import_node_fs5 = __toESM(require("fs"), 1);
979
975
  var import_node_path5 = __toESM(require("path"), 1);
980
976
  var PACKAGE_JSON = "package.json";
@@ -992,10 +988,23 @@ function findPackageRoot(startDir) {
992
988
  );
993
989
  }
994
990
 
995
- // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
996
- var import_node_path6 = __toESM(require("path"), 1);
991
+ // src/config/microfrontends/utils/find-config.ts
992
+ var import_node_fs6 = __toESM(require("fs"), 1);
993
+ var import_node_path6 = require("path");
994
+ function findConfig({ dir }) {
995
+ for (const filename of CONFIGURATION_FILENAMES) {
996
+ const maybeConfig = (0, import_node_path6.join)(dir, filename);
997
+ if (import_node_fs6.default.existsSync(maybeConfig)) {
998
+ return maybeConfig;
999
+ }
1000
+ }
1001
+ return null;
1002
+ }
1003
+
1004
+ // src/config/microfrontends/server/utils/get-output-file-path.ts
1005
+ var import_node_path7 = __toESM(require("path"), 1);
997
1006
 
998
- // src/config-v2/microfrontends/server/constants.ts
1007
+ // src/config/microfrontends/server/constants.ts
999
1008
  var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
1000
1009
  var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
1001
1010
 
@@ -1004,116 +1013,24 @@ function isVercel() {
1004
1013
  return process.env.VERCEL === "1";
1005
1014
  }
1006
1015
 
1007
- // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
1016
+ // src/config/microfrontends/server/utils/get-output-file-path.ts
1008
1017
  function getOutputFilePath() {
1009
1018
  if (isVercel()) {
1010
- return import_node_path6.default.join(
1019
+ return import_node_path7.default.join(
1011
1020
  ".vercel",
1012
1021
  MFE_CONFIG_DEFAULT_FILE_PATH,
1013
1022
  MFE_CONFIG_DEFAULT_FILE_NAME
1014
1023
  );
1015
1024
  }
1016
- return import_node_path6.default.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1025
+ return import_node_path7.default.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1017
1026
  }
1018
1027
 
1019
- // src/config-v2/microfrontends/server/validation.ts
1020
- var import_jsonc_parser2 = require("jsonc-parser");
1028
+ // src/config/microfrontends/server/validation.ts
1029
+ var import_jsonc_parser3 = require("jsonc-parser");
1021
1030
  var import_ajv = require("ajv");
1022
1031
 
1023
- // src/config/errors.ts
1024
- var MicrofrontendError2 = class extends Error {
1025
- constructor(message, opts) {
1026
- super(message);
1027
- this.name = "MicrofrontendsError";
1028
- this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
1029
- this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
1030
- this.subtype = opts == null ? void 0 : opts.subtype;
1031
- Error.captureStackTrace(this, MicrofrontendError2);
1032
- }
1033
- isKnown() {
1034
- return this.type !== "unknown";
1035
- }
1036
- isUnknown() {
1037
- return !this.isKnown();
1038
- }
1039
- /**
1040
- * Converts an error to a MicrofrontendsError.
1041
- * @param original - The original error to convert.
1042
- * @returns The converted MicrofrontendsError.
1043
- */
1044
- static convert(original, opts) {
1045
- if (opts == null ? void 0 : opts.fileName) {
1046
- const err = MicrofrontendError2.convertFSError(original, opts.fileName);
1047
- if (err) {
1048
- return err;
1049
- }
1050
- }
1051
- if (original.message.includes(
1052
- "Code generation from strings disallowed for this context"
1053
- )) {
1054
- return new MicrofrontendError2(original.message, {
1055
- type: "config",
1056
- subtype: "unsupported_validation_env",
1057
- source: "ajv"
1058
- });
1059
- }
1060
- return new MicrofrontendError2(original.message);
1061
- }
1062
- static convertFSError(original, fileName) {
1063
- if (original instanceof Error && "code" in original) {
1064
- if (original.code === "ENOENT") {
1065
- return new MicrofrontendError2(`Could not find "${fileName}"`, {
1066
- type: "config",
1067
- subtype: "unable_to_read_file",
1068
- source: "fs"
1069
- });
1070
- }
1071
- if (original.code === "EACCES") {
1072
- return new MicrofrontendError2(
1073
- `Permission denied while accessing "${fileName}"`,
1074
- {
1075
- type: "config",
1076
- subtype: "invalid_permissions",
1077
- source: "fs"
1078
- }
1079
- );
1080
- }
1081
- }
1082
- if (original instanceof SyntaxError) {
1083
- return new MicrofrontendError2(
1084
- `Failed to parse "${fileName}": Invalid JSON format.`,
1085
- {
1086
- type: "config",
1087
- subtype: "invalid_syntax",
1088
- source: "fs"
1089
- }
1090
- );
1091
- }
1092
- return null;
1093
- }
1094
- /**
1095
- * Handles an unknown error and returns a MicrofrontendsError instance.
1096
- * @param err - The error to handle.
1097
- * @returns A MicrofrontendsError instance.
1098
- */
1099
- static handle(err, opts) {
1100
- if (err instanceof MicrofrontendError2) {
1101
- return err;
1102
- }
1103
- if (err instanceof Error) {
1104
- return MicrofrontendError2.convert(err, opts);
1105
- }
1106
- if (typeof err === "object" && err !== null) {
1107
- if ("message" in err && typeof err.message === "string") {
1108
- return MicrofrontendError2.convert(new Error(err.message), opts);
1109
- }
1110
- }
1111
- return new MicrofrontendError2("An unknown error occurred");
1112
- }
1113
- };
1114
-
1115
- // schema/schema-v2.json
1116
- var schema_v2_default = {
1032
+ // schema/schema.json
1033
+ var schema_default = {
1117
1034
  $schema: "http://json-schema.org/draft-07/schema#",
1118
1035
  $ref: "#/definitions/Config",
1119
1036
  definitions: {
@@ -1152,7 +1069,8 @@ var schema_v2_default = {
1152
1069
  description: "Mapping of application names to the routes that they host. Only needs to be defined in the application that owns the primary microfrontend domain"
1153
1070
  }
1154
1071
  },
1155
- required: ["applications", "version"]
1072
+ required: ["applications", "version"],
1073
+ additionalProperties: false
1156
1074
  },
1157
1075
  Options: {
1158
1076
  type: "object",
@@ -1165,15 +1083,12 @@ var schema_v2_default = {
1165
1083
  $ref: "#/definitions/LocalProxyOptions",
1166
1084
  description: "Options for local proxy."
1167
1085
  }
1168
- }
1086
+ },
1087
+ additionalProperties: false
1169
1088
  },
1170
1089
  VercelOptions: {
1171
1090
  type: "object",
1172
1091
  properties: {
1173
- previewDeploymentSuffix: {
1174
- type: "string",
1175
- description: "If your team uses a custom Preview Deployment Suffix, please specify it here. See https://vercel.com/docs/deployments/preview-deployment-suffix. The default is `vercel.app`."
1176
- },
1177
1092
  teamSlug: {
1178
1093
  type: "string",
1179
1094
  description: "Team slug for the Vercel team"
@@ -1182,7 +1097,8 @@ var schema_v2_default = {
1182
1097
  type: "boolean",
1183
1098
  description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
1184
1099
  }
1185
- }
1100
+ },
1101
+ additionalProperties: false
1186
1102
  },
1187
1103
  LocalProxyOptions: {
1188
1104
  type: "object",
@@ -1191,7 +1107,8 @@ var schema_v2_default = {
1191
1107
  type: "number",
1192
1108
  description: "The port number used by the local proxy server.\n\nThe default is `3024`."
1193
1109
  }
1194
- }
1110
+ },
1111
+ additionalProperties: false
1195
1112
  },
1196
1113
  Application: {
1197
1114
  anyOf: [
@@ -1216,7 +1133,8 @@ var schema_v2_default = {
1216
1133
  $ref: "#/definitions/HostConfig"
1217
1134
  }
1218
1135
  },
1219
- required: ["production"]
1136
+ required: ["production"],
1137
+ additionalProperties: false
1220
1138
  },
1221
1139
  Vercel: {
1222
1140
  type: "object",
@@ -1226,7 +1144,8 @@ var schema_v2_default = {
1226
1144
  description: "Vercel project ID"
1227
1145
  }
1228
1146
  },
1229
- required: ["projectId"]
1147
+ required: ["projectId"],
1148
+ additionalProperties: false
1230
1149
  },
1231
1150
  Development: {
1232
1151
  type: "object",
@@ -1242,10 +1161,12 @@ var schema_v2_default = {
1242
1161
  type: "string",
1243
1162
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1244
1163
  }
1245
- }
1164
+ },
1165
+ additionalProperties: false
1246
1166
  },
1247
1167
  LocalHostConfig: {
1248
1168
  type: "object",
1169
+ additionalProperties: false,
1249
1170
  properties: {
1250
1171
  host: {
1251
1172
  type: "string",
@@ -1279,7 +1200,8 @@ var schema_v2_default = {
1279
1200
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
1280
1201
  }
1281
1202
  },
1282
- required: ["host"]
1203
+ required: ["host"],
1204
+ additionalProperties: false
1283
1205
  },
1284
1206
  ChildApplication: {
1285
1207
  type: "object",
@@ -1298,7 +1220,8 @@ var schema_v2_default = {
1298
1220
  $ref: "#/definitions/HostConfig"
1299
1221
  }
1300
1222
  },
1301
- required: ["routing"]
1223
+ required: ["routing"],
1224
+ additionalProperties: false
1302
1225
  },
1303
1226
  Routing: {
1304
1227
  type: "array",
@@ -1324,7 +1247,8 @@ var schema_v2_default = {
1324
1247
  }
1325
1248
  }
1326
1249
  },
1327
- required: ["paths"]
1250
+ required: ["paths"],
1251
+ additionalProperties: false
1328
1252
  },
1329
1253
  ApplicationRouting: {
1330
1254
  type: "object",
@@ -1357,22 +1281,23 @@ var schema_v2_default = {
1357
1281
  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."
1358
1282
  }
1359
1283
  },
1360
- required: ["partOf", "version"]
1284
+ required: ["partOf", "version"],
1285
+ additionalProperties: false
1361
1286
  }
1362
1287
  }
1363
1288
  };
1364
1289
 
1365
- // src/config-v2/schema/utils/load.ts
1366
- var SCHEMA = schema_v2_default;
1290
+ // src/config/schema/utils/load.ts
1291
+ var SCHEMA = schema_default;
1367
1292
 
1368
- // src/config-v2/microfrontends/server/validation.ts
1293
+ // src/config/microfrontends/server/validation.ts
1369
1294
  function validateSchema(configString) {
1370
- const parsedConfig = (0, import_jsonc_parser2.parse)(configString);
1295
+ const parsedConfig = (0, import_jsonc_parser3.parse)(configString);
1371
1296
  const ajv = new import_ajv.Ajv();
1372
1297
  const validate = ajv.compile(SCHEMA);
1373
1298
  const isValid = validate(parsedConfig);
1374
1299
  if (!isValid) {
1375
- throw new MicrofrontendError2(
1300
+ throw new MicrofrontendError(
1376
1301
  `Invalid config: ${ajv.errorsText(validate.errors)}`,
1377
1302
  { type: "config", subtype: "does_not_match_schema" }
1378
1303
  );
@@ -1380,7 +1305,7 @@ function validateSchema(configString) {
1380
1305
  return parsedConfig;
1381
1306
  }
1382
1307
 
1383
- // src/config-v2/microfrontends/server/index.ts
1308
+ // src/config/microfrontends/server/index.ts
1384
1309
  var MicrofrontendsServer = class extends Microfrontends {
1385
1310
  /**
1386
1311
  * Writes the configuration to a file.
@@ -1389,8 +1314,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1389
1314
  pretty: true
1390
1315
  }) {
1391
1316
  const outputPath = getOutputFilePath();
1392
- import_node_fs6.default.mkdirSync((0, import_node_path7.dirname)(outputPath), { recursive: true });
1393
- import_node_fs6.default.writeFileSync(
1317
+ import_node_fs7.default.mkdirSync((0, import_node_path8.dirname)(outputPath), { recursive: true });
1318
+ import_node_fs7.default.writeFileSync(
1394
1319
  outputPath,
1395
1320
  JSON.stringify(
1396
1321
  this.config.toSchemaJson(),
@@ -1453,8 +1378,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1453
1378
  return config;
1454
1379
  }
1455
1380
  /**
1456
- * Looks up the configuration by inferring the package root and looking for a microfrontends.json file. If a file is not found,
1457
- * it will look for a package in the repository with a microfrontends.json file that contains the current application
1381
+ * Looks up the configuration by inferring the package root and looking for a microfrontends config file. If a file is not found,
1382
+ * it will look for a package in the repository with a microfrontends file that contains the current application
1458
1383
  * and use that configuration.
1459
1384
  *
1460
1385
  * This can return either a Child or Main configuration.
@@ -1476,16 +1401,16 @@ var MicrofrontendsServer = class extends Microfrontends {
1476
1401
  }
1477
1402
  try {
1478
1403
  const packageRoot = findPackageRoot(directory);
1479
- const packageJsonPath = (0, import_node_path7.join)(packageRoot, "package.json");
1404
+ const packageJsonPath = (0, import_node_path8.join)(packageRoot, "package.json");
1480
1405
  const packageJson = JSON.parse(
1481
- import_node_fs6.default.readFileSync(packageJsonPath, "utf-8")
1406
+ import_node_fs7.default.readFileSync(packageJsonPath, "utf-8")
1482
1407
  );
1483
1408
  if (!packageJson.name) {
1484
1409
  throw new Error(`No name found in package.json at ${packageJsonPath}`);
1485
1410
  }
1486
1411
  const configMeta = meta ?? { fromApp: packageJson.name };
1487
- const maybeConfig = (0, import_node_path7.join)(packageRoot, "microfrontends.json");
1488
- if (import_node_fs6.default.existsSync(maybeConfig)) {
1412
+ const maybeConfig = findConfig({ dir: packageRoot });
1413
+ if (maybeConfig) {
1489
1414
  return MicrofrontendsServer.fromFile({
1490
1415
  filePath: maybeConfig,
1491
1416
  cookies,
@@ -1500,12 +1425,15 @@ var MicrofrontendsServer = class extends Microfrontends {
1500
1425
  repositoryRoot,
1501
1426
  applicationName: packageJson.name
1502
1427
  });
1503
- return MicrofrontendsServer.fromFile({
1504
- filePath: (0, import_node_path7.join)(defaultPackage, "microfrontends.json"),
1505
- cookies,
1506
- meta: configMeta,
1507
- options
1508
- });
1428
+ const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
1429
+ if (maybeConfigFromDefault) {
1430
+ return MicrofrontendsServer.fromFile({
1431
+ filePath: maybeConfigFromDefault,
1432
+ cookies,
1433
+ meta: configMeta,
1434
+ options
1435
+ });
1436
+ }
1509
1437
  }
1510
1438
  throw new Error("Unable to infer");
1511
1439
  } catch (e) {
@@ -1525,7 +1453,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1525
1453
  options
1526
1454
  }) {
1527
1455
  try {
1528
- const configJson = import_node_fs6.default.readFileSync(filePath, "utf-8");
1456
+ const configJson = import_node_fs7.default.readFileSync(filePath, "utf-8");
1529
1457
  const config = MicrofrontendsServer.validate(configJson);
1530
1458
  if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
1531
1459
  const repositoryRoot = findRepositoryRoot();
@@ -1541,9 +1469,15 @@ var MicrofrontendsServer = class extends Microfrontends {
1541
1469
  { type: "config", subtype: "not_found" }
1542
1470
  );
1543
1471
  }
1544
- const mainConfigPath = (0, import_node_path7.join)(packagePath, "microfrontends.json");
1472
+ const maybeConfig = findConfig({ dir: packagePath });
1473
+ if (!maybeConfig) {
1474
+ throw new MicrofrontendError(
1475
+ `Could not find microfrontends configuration in ${packagePath}`,
1476
+ { type: "config", subtype: "not_found" }
1477
+ );
1478
+ }
1545
1479
  return MicrofrontendsServer.fromMainConfigFile({
1546
- filePath: mainConfigPath,
1480
+ filePath: maybeConfig,
1547
1481
  overrides: cookies ? parseOverrides(cookies) : void 0
1548
1482
  });
1549
1483
  }
@@ -1567,7 +1501,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1567
1501
  overrides
1568
1502
  }) {
1569
1503
  try {
1570
- const config = import_node_fs6.default.readFileSync(filePath, "utf-8");
1504
+ const config = import_node_fs7.default.readFileSync(filePath, "utf-8");
1571
1505
  const validatedConfig = MicrofrontendsServer.validate(config);
1572
1506
  if (!isMainConfig(validatedConfig)) {
1573
1507
  throw new MicrofrontendError(