@vercel/microfrontends 2.3.0 → 2.3.2

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 (50) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/bin/cli.cjs +275 -268
  3. package/dist/config.cjs +22 -21
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +3 -2
  6. package/dist/config.js +22 -21
  7. package/dist/config.js.map +1 -1
  8. package/dist/experimental/sveltekit.cjs +259 -258
  9. package/dist/experimental/sveltekit.cjs.map +1 -1
  10. package/dist/experimental/sveltekit.js +239 -238
  11. package/dist/experimental/sveltekit.js.map +1 -1
  12. package/dist/experimental/vite.cjs +259 -258
  13. package/dist/experimental/vite.cjs.map +1 -1
  14. package/dist/experimental/vite.js +239 -238
  15. package/dist/experimental/vite.js.map +1 -1
  16. package/dist/microfrontends/server.cjs +259 -258
  17. package/dist/microfrontends/server.cjs.map +1 -1
  18. package/dist/microfrontends/server.d.ts +2 -2
  19. package/dist/microfrontends/server.js +239 -238
  20. package/dist/microfrontends/server.js.map +1 -1
  21. package/dist/microfrontends/utils.cjs +22 -0
  22. package/dist/microfrontends/utils.cjs.map +1 -1
  23. package/dist/microfrontends/utils.d.ts +5 -1
  24. package/dist/microfrontends/utils.js +21 -0
  25. package/dist/microfrontends/utils.js.map +1 -1
  26. package/dist/next/client.cjs.map +1 -1
  27. package/dist/next/client.js.map +1 -1
  28. package/dist/next/config.cjs +259 -258
  29. package/dist/next/config.cjs.map +1 -1
  30. package/dist/next/config.js +239 -238
  31. package/dist/next/config.js.map +1 -1
  32. package/dist/next/middleware.cjs +22 -21
  33. package/dist/next/middleware.cjs.map +1 -1
  34. package/dist/next/middleware.js +22 -21
  35. package/dist/next/middleware.js.map +1 -1
  36. package/dist/next/testing.cjs +22 -21
  37. package/dist/next/testing.cjs.map +1 -1
  38. package/dist/next/testing.d.ts +2 -2
  39. package/dist/next/testing.js +22 -21
  40. package/dist/next/testing.js.map +1 -1
  41. package/dist/overrides.d.ts +3 -3
  42. package/dist/schema.d.ts +2 -2
  43. package/dist/{types-b9ea41b2.d.ts → types-279c294f.d.ts} +1 -1
  44. package/dist/{types-dcd8b17a.d.ts → types-f331c2a8.d.ts} +0 -4
  45. package/dist/utils/mfe-port.cjs +259 -258
  46. package/dist/utils/mfe-port.cjs.map +1 -1
  47. package/dist/utils/mfe-port.js +239 -238
  48. package/dist/utils/mfe-port.js.map +1 -1
  49. package/dist/validation.d.ts +1 -1
  50. package/package.json +1 -1
@@ -121,7 +121,16 @@ var MicrofrontendError = class extends Error {
121
121
  };
122
122
 
123
123
  // src/config/microfrontends-config/isomorphic/index.ts
124
- import { parse } from "jsonc-parser";
124
+ import { parse as parse2 } from "jsonc-parser";
125
+
126
+ // src/config/microfrontends/utils/hash-application-name.ts
127
+ import md5 from "md5";
128
+ function hashApplicationName(name) {
129
+ if (!name) {
130
+ throw new Error("Application name is required to generate hash");
131
+ }
132
+ return md5(name).substring(0, 6).padStart(6, "0");
133
+ }
125
134
 
126
135
  // src/config/overrides/constants.ts
127
136
  var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
@@ -271,6 +280,231 @@ function getConfigStringFromEnv() {
271
280
  return config;
272
281
  }
273
282
 
283
+ // src/config/microfrontends/utils/find-config.ts
284
+ import fs from "node:fs";
285
+ import { join } from "node:path";
286
+
287
+ // src/config/microfrontends/utils/get-config-file-name.ts
288
+ var DEFAULT_CONFIGURATION_FILENAMES = [
289
+ "microfrontends.json",
290
+ "microfrontends.jsonc"
291
+ ];
292
+ function getPossibleConfigurationFilenames({
293
+ customConfigFilename
294
+ }) {
295
+ if (customConfigFilename) {
296
+ if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
297
+ throw new Error(
298
+ `Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}. The file name must end with '.json' or '.jsonc'. It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`
299
+ );
300
+ }
301
+ return Array.from(
302
+ /* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
303
+ );
304
+ }
305
+ return DEFAULT_CONFIGURATION_FILENAMES;
306
+ }
307
+
308
+ // src/config/microfrontends/utils/find-config.ts
309
+ function findConfig({
310
+ dir,
311
+ customConfigFilename
312
+ }) {
313
+ for (const filename of getPossibleConfigurationFilenames({
314
+ customConfigFilename
315
+ })) {
316
+ const maybeConfig = join(dir, filename);
317
+ if (fs.existsSync(maybeConfig)) {
318
+ return maybeConfig;
319
+ }
320
+ }
321
+ return null;
322
+ }
323
+
324
+ // src/config/microfrontends/utils/generate-default-asset-prefix.ts
325
+ var PREFIX = "vc-ap";
326
+ function generateDefaultAssetPrefixFromName({
327
+ name
328
+ }) {
329
+ if (!name) {
330
+ throw new Error("Name is required to generate an asset prefix");
331
+ }
332
+ return `${PREFIX}-${hashApplicationName(name)}`;
333
+ }
334
+
335
+ // src/config/microfrontends/utils/infer-microfrontends-location.ts
336
+ import { readFileSync, statSync } from "node:fs";
337
+ import { dirname, join as join2 } from "node:path";
338
+ import fg from "fast-glob";
339
+ import { parse } from "jsonc-parser";
340
+ var configCache = {};
341
+ function findPackageWithMicrofrontendsConfig({
342
+ repositoryRoot,
343
+ applicationContext,
344
+ customConfigFilename
345
+ }) {
346
+ const applicationName = applicationContext.name;
347
+ logger.debug(
348
+ "[MFE Config] Searching repository for configs containing application:",
349
+ applicationName
350
+ );
351
+ try {
352
+ const microfrontendsJsonPaths = fg.globSync(
353
+ `**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
354
+ {
355
+ cwd: repositoryRoot,
356
+ absolute: true,
357
+ onlyFiles: true,
358
+ followSymbolicLinks: false,
359
+ ignore: ["**/node_modules/**", "**/.git/**"]
360
+ }
361
+ );
362
+ logger.debug(
363
+ "[MFE Config] Found",
364
+ microfrontendsJsonPaths.length,
365
+ "config file(s) in repository"
366
+ );
367
+ const matchingPaths = [];
368
+ for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
369
+ if (doesApplicationExistInConfig(microfrontendsJsonPath, applicationName)) {
370
+ matchingPaths.push(microfrontendsJsonPath);
371
+ }
372
+ }
373
+ logger.debug(
374
+ "[MFE Config] Total matching config files:",
375
+ matchingPaths.length
376
+ );
377
+ if (matchingPaths.length > 1) {
378
+ throw new MicrofrontendError(
379
+ `Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
380
+ ${matchingPaths.join("\n \u2022 ")}`,
381
+ { type: "config", subtype: "inference_failed" }
382
+ );
383
+ }
384
+ if (matchingPaths.length === 0) {
385
+ if (repositoryRoot && doesMisplacedConfigExist(
386
+ repositoryRoot,
387
+ applicationName,
388
+ customConfigFilename
389
+ )) {
390
+ logger.debug(
391
+ "[MFE Config] Found misplaced config in wrong .vercel directory in repository"
392
+ );
393
+ const misplacedConfigPath = join2(
394
+ repositoryRoot,
395
+ ".vercel",
396
+ customConfigFilename || "microfrontends.json"
397
+ );
398
+ throw new MicrofrontendError(
399
+ `Unable to automatically infer the location of the \`microfrontends.json\` file.
400
+
401
+ A microfrontends config was found in the \`.vercel\` directory at the repository root: ${misplacedConfigPath}
402
+ However, in a monorepo, the config file should be placed in the \`.vercel\` directory in your application directory instead.
403
+
404
+ To fix this:
405
+ 1. If using \`vercel link\`, run it with \`vercel link --repo\` to handle monorepos, or run \`vercel microfrontends pull --cwd=<application-directory>\` to make sure it pulls the \`microfrontends.json\` file to the correct location
406
+ 2. If manually defined, move the config file to the \`.vercel\` directory in your application
407
+ 3. Alternatively, set the VC_MICROFRONTENDS_CONFIG environment variable to the correct path
408
+
409
+ For more information, see: https://vercel.com/docs/cli/project-linking`,
410
+ { type: "config", subtype: "inference_failed" }
411
+ );
412
+ }
413
+ let additionalErrorMessage = "";
414
+ if (microfrontendsJsonPaths.length > 0) {
415
+ if (!applicationContext.projectName) {
416
+ additionalErrorMessage = `
417
+
418
+ If the name in package.json (${applicationContext.packageJsonName}) differs from your Vercel Project name, set the \`packageName\` field for the application in \`microfrontends.json\` to ensure that the configuration can be found locally.`;
419
+ } else {
420
+ additionalErrorMessage = `
421
+
422
+ Names of applications in \`microfrontends.json\` must match the Vercel Project name (${applicationContext.projectName}).`;
423
+ }
424
+ }
425
+ throw new MicrofrontendError(
426
+ `Could not find a \`microfrontends.json\` file in the repository that contains the "${applicationName}" application.${additionalErrorMessage}
427
+
428
+ If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable.
429
+
430
+ If your Vercel Microfrontends configuration has a custom name, ensure the VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable is set, you can pull the vercel project environment variables using the "vercel env pull" command.
431
+
432
+ If you suspect this is thrown in error, please reach out to the Vercel team.`,
433
+ { type: "config", subtype: "inference_failed" }
434
+ );
435
+ }
436
+ const [packageJsonPath] = matchingPaths;
437
+ return dirname(packageJsonPath);
438
+ } catch (error2) {
439
+ if (error2 instanceof MicrofrontendError) {
440
+ throw error2;
441
+ }
442
+ return null;
443
+ }
444
+ }
445
+ function inferMicrofrontendsLocation(opts) {
446
+ const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
447
+ if (configCache[cacheKey]) {
448
+ return configCache[cacheKey];
449
+ }
450
+ const result = findPackageWithMicrofrontendsConfig(opts);
451
+ if (!result) {
452
+ throw new MicrofrontendError(
453
+ `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationContext.name}" starting in directory "${opts.repositoryRoot}".`,
454
+ { type: "config", subtype: "inference_failed" }
455
+ );
456
+ }
457
+ configCache[cacheKey] = result;
458
+ return result;
459
+ }
460
+ function existsSync(path7) {
461
+ try {
462
+ statSync(path7);
463
+ return true;
464
+ } catch (_) {
465
+ return false;
466
+ }
467
+ }
468
+ function doesMisplacedConfigExist(repositoryRoot, applicationName, customConfigFilename) {
469
+ logger.debug(
470
+ "[MFE Config] Looking for misplaced config in wrong .vercel directory"
471
+ );
472
+ const misplacedConfigPath = join2(
473
+ repositoryRoot,
474
+ ".vercel",
475
+ customConfigFilename || "microfrontends.json"
476
+ );
477
+ return existsSync(misplacedConfigPath) && doesApplicationExistInConfig(misplacedConfigPath, applicationName);
478
+ }
479
+ function doesApplicationExistInConfig(microfrontendsJsonPath, applicationName) {
480
+ try {
481
+ const microfrontendsJsonContent = readFileSync(
482
+ microfrontendsJsonPath,
483
+ "utf-8"
484
+ );
485
+ const microfrontendsJson = parse(microfrontendsJsonContent);
486
+ if (microfrontendsJson.applications[applicationName]) {
487
+ logger.debug(
488
+ "[MFE Config] Found application in config:",
489
+ microfrontendsJsonPath
490
+ );
491
+ return true;
492
+ }
493
+ for (const [_, app] of Object.entries(microfrontendsJson.applications)) {
494
+ if (app.packageName === applicationName) {
495
+ logger.debug(
496
+ "[MFE Config] Found application via packageName in config:",
497
+ microfrontendsJsonPath
498
+ );
499
+ return true;
500
+ }
501
+ }
502
+ } catch (error2) {
503
+ logger.debug("[MFE Config] Error checking application in config:", error2);
504
+ }
505
+ return false;
506
+ }
507
+
274
508
  // src/config/microfrontends-config/isomorphic/constants.ts
275
509
  var DEFAULT_LOCAL_PROXY_PORT = 3024;
276
510
  var MFE_APP_PORT_ENV = "MFE_APP_PORT";
@@ -409,26 +643,6 @@ var LocalHost = class extends Host {
409
643
  }
410
644
  };
411
645
 
412
- // src/config/microfrontends-config/isomorphic/utils/hash-application-name.ts
413
- import md5 from "md5";
414
- function hashApplicationName(name) {
415
- if (!name) {
416
- throw new Error("Application name is required to generate hash");
417
- }
418
- return md5(name).substring(0, 6).padStart(6, "0");
419
- }
420
-
421
- // src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
422
- var PREFIX = "vc-ap";
423
- function generateAssetPrefixFromName({
424
- name
425
- }) {
426
- if (!name) {
427
- throw new Error("Name is required to generate an asset prefix");
428
- }
429
- return `${PREFIX}-${hashApplicationName(name)}`;
430
- }
431
-
432
646
  // src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
433
647
  function generateAutomationBypassEnvVarName({
434
648
  name
@@ -646,7 +860,7 @@ var Application = class {
646
860
  return this.default;
647
861
  }
648
862
  getAssetPrefix() {
649
- const generatedAssetPrefix = generateAssetPrefixFromName({
863
+ const generatedAssetPrefix = generateDefaultAssetPrefixFromName({
650
864
  name: this.name
651
865
  });
652
866
  if ("assetPrefix" in this.serialized) {
@@ -654,6 +868,7 @@ var Application = class {
654
868
  }
655
869
  return generatedAssetPrefix;
656
870
  }
871
+ /** @deprecated Prefer `VERCEL_AUTOMATION_BYPASS_SECRET`. Use this only if each project needs its own distinct bypass secret. */
657
872
  getAutomationBypassEnvVarName() {
658
873
  return generateAutomationBypassEnvVarName({ name: this.name });
659
874
  }
@@ -740,7 +955,7 @@ var MicrofrontendConfigIsomorphic = class {
740
955
  };
741
956
  }
742
957
  static validate(config) {
743
- const c = typeof config === "string" ? parse(config) : config;
958
+ const c = typeof config === "string" ? parse2(config) : config;
744
959
  validateConfigPaths(c.applications);
745
960
  validateConfigDefaultApplication(c.applications);
746
961
  return c;
@@ -749,7 +964,7 @@ var MicrofrontendConfigIsomorphic = class {
749
964
  cookies
750
965
  }) {
751
966
  return new MicrofrontendConfigIsomorphic({
752
- config: parse(getConfigStringFromEnv()),
967
+ config: parse2(getConfigStringFromEnv()),
753
968
  overrides: parseOverrides(cookies ?? [])
754
969
  });
755
970
  }
@@ -863,47 +1078,6 @@ var MicrofrontendConfigIsomorphic = class {
863
1078
  }
864
1079
  };
865
1080
 
866
- // src/config/microfrontends/utils/find-config.ts
867
- import fs from "node:fs";
868
- import { join } from "node:path";
869
-
870
- // src/config/microfrontends/utils/get-config-file-name.ts
871
- var DEFAULT_CONFIGURATION_FILENAMES = [
872
- "microfrontends.json",
873
- "microfrontends.jsonc"
874
- ];
875
- function getPossibleConfigurationFilenames({
876
- customConfigFilename
877
- }) {
878
- if (customConfigFilename) {
879
- if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
880
- throw new Error(
881
- `Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}. The file name must end with '.json' or '.jsonc'. It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`
882
- );
883
- }
884
- return Array.from(
885
- /* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
886
- );
887
- }
888
- return DEFAULT_CONFIGURATION_FILENAMES;
889
- }
890
-
891
- // src/config/microfrontends/utils/find-config.ts
892
- function findConfig({
893
- dir,
894
- customConfigFilename
895
- }) {
896
- for (const filename of getPossibleConfigurationFilenames({
897
- customConfigFilename
898
- })) {
899
- const maybeConfig = join(dir, filename);
900
- if (fs.existsSync(maybeConfig)) {
901
- return maybeConfig;
902
- }
903
- }
904
- return null;
905
- }
906
-
907
1081
  // src/config/microfrontends/utils/find-package-root.ts
908
1082
  import fs2 from "node:fs";
909
1083
  import path from "node:path";
@@ -1036,179 +1210,6 @@ function getApplicationContext(opts) {
1036
1210
  }
1037
1211
  }
1038
1212
 
1039
- // src/config/microfrontends/utils/infer-microfrontends-location.ts
1040
- import { readFileSync, statSync } from "node:fs";
1041
- import { dirname, join as join2 } from "node:path";
1042
- import fg from "fast-glob";
1043
- import { parse as parse2 } from "jsonc-parser";
1044
- var configCache = {};
1045
- function findPackageWithMicrofrontendsConfig({
1046
- repositoryRoot,
1047
- applicationContext,
1048
- customConfigFilename
1049
- }) {
1050
- const applicationName = applicationContext.name;
1051
- logger.debug(
1052
- "[MFE Config] Searching repository for configs containing application:",
1053
- applicationName
1054
- );
1055
- try {
1056
- const microfrontendsJsonPaths = fg.globSync(
1057
- `**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
1058
- {
1059
- cwd: repositoryRoot,
1060
- absolute: true,
1061
- onlyFiles: true,
1062
- followSymbolicLinks: false,
1063
- ignore: ["**/node_modules/**", "**/.git/**"]
1064
- }
1065
- );
1066
- logger.debug(
1067
- "[MFE Config] Found",
1068
- microfrontendsJsonPaths.length,
1069
- "config file(s) in repository"
1070
- );
1071
- const matchingPaths = [];
1072
- for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
1073
- if (doesApplicationExistInConfig(microfrontendsJsonPath, applicationName)) {
1074
- matchingPaths.push(microfrontendsJsonPath);
1075
- }
1076
- }
1077
- logger.debug(
1078
- "[MFE Config] Total matching config files:",
1079
- matchingPaths.length
1080
- );
1081
- if (matchingPaths.length > 1) {
1082
- throw new MicrofrontendError(
1083
- `Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
1084
- ${matchingPaths.join("\n \u2022 ")}`,
1085
- { type: "config", subtype: "inference_failed" }
1086
- );
1087
- }
1088
- if (matchingPaths.length === 0) {
1089
- if (repositoryRoot && doesMisplacedConfigExist(
1090
- repositoryRoot,
1091
- applicationName,
1092
- customConfigFilename
1093
- )) {
1094
- logger.debug(
1095
- "[MFE Config] Found misplaced config in wrong .vercel directory in repository"
1096
- );
1097
- const misplacedConfigPath = join2(
1098
- repositoryRoot,
1099
- ".vercel",
1100
- customConfigFilename || "microfrontends.json"
1101
- );
1102
- throw new MicrofrontendError(
1103
- `Unable to automatically infer the location of the \`microfrontends.json\` file.
1104
-
1105
- A microfrontends config was found in the \`.vercel\` directory at the repository root: ${misplacedConfigPath}
1106
- However, in a monorepo, the config file should be placed in the \`.vercel\` directory in your application directory instead.
1107
-
1108
- To fix this:
1109
- 1. If using \`vercel link\`, run it with \`vercel link --repo\` to handle monorepos, or run \`vercel microfrontends pull --cwd=<application-directory>\` to make sure it pulls the \`microfrontends.json\` file to the correct location
1110
- 2. If manually defined, move the config file to the \`.vercel\` directory in your application
1111
- 3. Alternatively, set the VC_MICROFRONTENDS_CONFIG environment variable to the correct path
1112
-
1113
- For more information, see: https://vercel.com/docs/cli/project-linking`,
1114
- { type: "config", subtype: "inference_failed" }
1115
- );
1116
- }
1117
- let additionalErrorMessage = "";
1118
- if (microfrontendsJsonPaths.length > 0) {
1119
- if (!applicationContext.projectName) {
1120
- additionalErrorMessage = `
1121
-
1122
- If the name in package.json (${applicationContext.packageJsonName}) differs from your Vercel Project name, set the \`packageName\` field for the application in \`microfrontends.json\` to ensure that the configuration can be found locally.`;
1123
- } else {
1124
- additionalErrorMessage = `
1125
-
1126
- Names of applications in \`microfrontends.json\` must match the Vercel Project name (${applicationContext.projectName}).`;
1127
- }
1128
- }
1129
- throw new MicrofrontendError(
1130
- `Could not find a \`microfrontends.json\` file in the repository that contains the "${applicationName}" application.${additionalErrorMessage}
1131
-
1132
- If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable.
1133
-
1134
- If your Vercel Microfrontends configuration has a custom name, ensure the VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable is set, you can pull the vercel project environment variables using the "vercel env pull" command.
1135
-
1136
- If you suspect this is thrown in error, please reach out to the Vercel team.`,
1137
- { type: "config", subtype: "inference_failed" }
1138
- );
1139
- }
1140
- const [packageJsonPath] = matchingPaths;
1141
- return dirname(packageJsonPath);
1142
- } catch (error2) {
1143
- if (error2 instanceof MicrofrontendError) {
1144
- throw error2;
1145
- }
1146
- return null;
1147
- }
1148
- }
1149
- function inferMicrofrontendsLocation(opts) {
1150
- const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
1151
- if (configCache[cacheKey]) {
1152
- return configCache[cacheKey];
1153
- }
1154
- const result = findPackageWithMicrofrontendsConfig(opts);
1155
- if (!result) {
1156
- throw new MicrofrontendError(
1157
- `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationContext.name}" starting in directory "${opts.repositoryRoot}".`,
1158
- { type: "config", subtype: "inference_failed" }
1159
- );
1160
- }
1161
- configCache[cacheKey] = result;
1162
- return result;
1163
- }
1164
- function existsSync(path7) {
1165
- try {
1166
- statSync(path7);
1167
- return true;
1168
- } catch (_) {
1169
- return false;
1170
- }
1171
- }
1172
- function doesMisplacedConfigExist(repositoryRoot, applicationName, customConfigFilename) {
1173
- logger.debug(
1174
- "[MFE Config] Looking for misplaced config in wrong .vercel directory"
1175
- );
1176
- const misplacedConfigPath = join2(
1177
- repositoryRoot,
1178
- ".vercel",
1179
- customConfigFilename || "microfrontends.json"
1180
- );
1181
- return existsSync(misplacedConfigPath) && doesApplicationExistInConfig(misplacedConfigPath, applicationName);
1182
- }
1183
- function doesApplicationExistInConfig(microfrontendsJsonPath, applicationName) {
1184
- try {
1185
- const microfrontendsJsonContent = readFileSync(
1186
- microfrontendsJsonPath,
1187
- "utf-8"
1188
- );
1189
- const microfrontendsJson = parse2(microfrontendsJsonContent);
1190
- if (microfrontendsJson.applications[applicationName]) {
1191
- logger.debug(
1192
- "[MFE Config] Found application in config:",
1193
- microfrontendsJsonPath
1194
- );
1195
- return true;
1196
- }
1197
- for (const [_, app] of Object.entries(microfrontendsJson.applications)) {
1198
- if (app.packageName === applicationName) {
1199
- logger.debug(
1200
- "[MFE Config] Found application via packageName in config:",
1201
- microfrontendsJsonPath
1202
- );
1203
- return true;
1204
- }
1205
- }
1206
- } catch (error2) {
1207
- logger.debug("[MFE Config] Error checking application in config:", error2);
1208
- }
1209
- return false;
1210
- }
1211
-
1212
1213
  // src/config/microfrontends/utils/is-monorepo.ts
1213
1214
  import fs5 from "node:fs";
1214
1215
  import path4 from "node:path";