@vercel/microfrontends 0.10.1 → 0.12.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 (61) hide show
  1. package/dist/bin/cli.cjs +263 -102
  2. package/dist/config.cjs +0 -2
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.js +0 -2
  5. package/dist/config.js.map +1 -1
  6. package/dist/{index-acb44057.d.ts → index-35038aec.d.ts} +2 -2
  7. package/dist/next/config.cjs +10 -3
  8. package/dist/next/config.cjs.map +1 -1
  9. package/dist/next/config.js +10 -3
  10. package/dist/next/config.js.map +1 -1
  11. package/dist/next/middleware.cjs +17 -1
  12. package/dist/next/middleware.cjs.map +1 -1
  13. package/dist/next/middleware.js +17 -1
  14. package/dist/next/middleware.js.map +1 -1
  15. package/dist/next/testing.cjs +0 -2
  16. package/dist/next/testing.cjs.map +1 -1
  17. package/dist/next/testing.js +0 -2
  18. package/dist/next/testing.js.map +1 -1
  19. package/dist/{types-c3d15d04.d.ts → types-15b7f215.d.ts} +1 -1
  20. package/dist/{types-7b1cd9f7.d.ts → types-a995174e.d.ts} +1 -4
  21. package/dist/v2/config.cjs +1 -1
  22. package/dist/v2/config.cjs.map +1 -1
  23. package/dist/v2/config.d.ts +3 -3
  24. package/dist/v2/config.js +1 -1
  25. package/dist/v2/config.js.map +1 -1
  26. package/dist/v2/microfrontends/server.cjs +215 -53
  27. package/dist/v2/microfrontends/server.cjs.map +1 -1
  28. package/dist/v2/microfrontends/server.d.ts +22 -3
  29. package/dist/v2/microfrontends/server.js +215 -53
  30. package/dist/v2/microfrontends/server.js.map +1 -1
  31. package/dist/v2/microfrontends.cjs +1 -2
  32. package/dist/v2/microfrontends.cjs.map +1 -1
  33. package/dist/v2/microfrontends.d.ts +3 -4
  34. package/dist/v2/microfrontends.js +1 -2
  35. package/dist/v2/microfrontends.js.map +1 -1
  36. package/dist/v2/next/config.cjs +249 -82
  37. package/dist/v2/next/config.cjs.map +1 -1
  38. package/dist/v2/next/config.js +249 -82
  39. package/dist/v2/next/config.js.map +1 -1
  40. package/dist/v2/next/endpoints.cjs +5 -2
  41. package/dist/v2/next/endpoints.cjs.map +1 -1
  42. package/dist/v2/next/endpoints.d.ts +1 -1
  43. package/dist/v2/next/endpoints.js +5 -2
  44. package/dist/v2/next/endpoints.js.map +1 -1
  45. package/dist/v2/next/middleware.cjs +107 -88
  46. package/dist/v2/next/middleware.cjs.map +1 -1
  47. package/dist/v2/next/middleware.js +107 -88
  48. package/dist/v2/next/middleware.js.map +1 -1
  49. package/dist/v2/overrides.cjs +1 -1
  50. package/dist/v2/overrides.cjs.map +1 -1
  51. package/dist/v2/overrides.d.ts +3 -3
  52. package/dist/v2/overrides.js +1 -1
  53. package/dist/v2/overrides.js.map +1 -1
  54. package/dist/v2/schema.d.ts +1 -1
  55. package/dist/validation.cjs +1 -11
  56. package/dist/validation.cjs.map +1 -1
  57. package/dist/validation.d.ts +0 -3
  58. package/dist/validation.js +1 -11
  59. package/dist/validation.js.map +1 -1
  60. package/package.json +8 -7
  61. package/schema/schema-v2.json +0 -14
@@ -1,12 +1,12 @@
1
1
  // src/next-v2/config/index.ts
2
- import fs3 from "node:fs";
2
+ import fs5 from "node:fs";
3
3
 
4
4
  // src/config-v2/microfrontends/server/index.ts
5
- import fs2 from "node:fs";
6
- import { dirname as dirname2, join } from "node:path";
5
+ import fs4 from "node:fs";
6
+ import { dirname as dirname3, join } from "node:path";
7
7
 
8
8
  // src/config-v2/overrides/constants.ts
9
- var OVERRIDES_COOKIE_PREFIX = "vercel-microfrontends-override";
9
+ var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
10
10
  var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
11
11
 
12
12
  // src/config-v2/overrides/is-override-cookie.ts
@@ -187,21 +187,21 @@ var MicrofrontendConfigClient = class {
187
187
  isEqual(other) {
188
188
  return JSON.stringify(this.applications) === JSON.stringify(other.applications);
189
189
  }
190
- getApplicationNameForPath(path3) {
191
- if (!path3.startsWith("/")) {
190
+ getApplicationNameForPath(path5) {
191
+ if (!path5.startsWith("/")) {
192
192
  throw new Error(`Path must start with a /`);
193
193
  }
194
- if (this.pathCache[path3]) {
195
- return this.pathCache[path3];
194
+ if (this.pathCache[path5]) {
195
+ return this.pathCache[path5];
196
196
  }
197
- const pathname = new URL(path3, "https://example.com").pathname;
197
+ const pathname = new URL(path5, "https://example.com").pathname;
198
198
  for (const [name, application] of Object.entries(this.applications)) {
199
199
  if (application.routing) {
200
200
  for (const group of application.routing) {
201
201
  for (const childPath of group.paths) {
202
202
  const regexp = pathToRegexp(childPath);
203
203
  if (regexp.test(pathname)) {
204
- this.pathCache[path3] = name;
204
+ this.pathCache[path5] = name;
205
205
  return name;
206
206
  }
207
207
  }
@@ -214,7 +214,7 @@ var MicrofrontendConfigClient = class {
214
214
  if (!defaultApplication) {
215
215
  return null;
216
216
  }
217
- this.pathCache[path3] = defaultApplication[0];
217
+ this.pathCache[path5] = defaultApplication[0];
218
218
  return defaultApplication[0];
219
219
  }
220
220
  serialize() {
@@ -246,22 +246,22 @@ var validateConfigPaths = (applicationConfigsById) => {
246
246
  continue;
247
247
  }
248
248
  for (const pathMatch of app.routing) {
249
- for (const path3 of pathMatch.paths) {
250
- const tokens = parsePathRegexp(path3);
249
+ for (const path5 of pathMatch.paths) {
250
+ const tokens = parsePathRegexp(path5);
251
251
  for (const token of tokens.slice(0, -1)) {
252
252
  if (typeof token !== "string") {
253
253
  errors.push(
254
- `Path ${path3} may only have a :wildcard in the last path component`
254
+ `Path ${path5} may only have a :wildcard in the last path component`
255
255
  );
256
256
  }
257
257
  }
258
- const existing = pathsByApplicationId.get(path3);
258
+ const existing = pathsByApplicationId.get(path5);
259
259
  if (existing) {
260
260
  existing.applications.push(id);
261
261
  } else {
262
- pathsByApplicationId.set(path3, {
262
+ pathsByApplicationId.set(path5, {
263
263
  applications: [id],
264
- matcher: pathToRegexp2(path3),
264
+ matcher: pathToRegexp2(path5),
265
265
  applicationId: id
266
266
  });
267
267
  }
@@ -269,10 +269,10 @@ var validateConfigPaths = (applicationConfigsById) => {
269
269
  }
270
270
  }
271
271
  const entries = Array.from(pathsByApplicationId.entries());
272
- entries.forEach(([path3, { applications: ids, matcher, applicationId }]) => {
272
+ entries.forEach(([path5, { applications: ids, matcher, applicationId }]) => {
273
273
  if (ids.length > 1) {
274
274
  errors.push(
275
- `Duplicate path "${path3}" for applications "${ids.join(", ")}"`
275
+ `Duplicate path "${path5}" for applications "${ids.join(", ")}"`
276
276
  );
277
277
  }
278
278
  entries.forEach(
@@ -280,14 +280,14 @@ var validateConfigPaths = (applicationConfigsById) => {
280
280
  matchPath,
281
281
  { applications: matchIds, applicationId: matchApplicationId }
282
282
  ]) => {
283
- if (path3 === matchPath) {
283
+ if (path5 === matchPath) {
284
284
  return;
285
285
  }
286
286
  if (applicationId === matchApplicationId) {
287
287
  return;
288
288
  }
289
289
  if (matcher.test(matchPath)) {
290
- const source = `"${path3}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
290
+ const source = `"${path5}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
291
291
  const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
292
292
  errors.push(
293
293
  `Overlapping path detected between ${source} and ${destination}`
@@ -720,7 +720,6 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
720
720
  var _a, _b, _c;
721
721
  super({ config, overrides, meta });
722
722
  this.isMainConfig = true;
723
- this.provider = config.provider;
724
723
  const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
725
724
  let defaultApplication;
726
725
  for (const [appId, appConfig] of Object.entries(config.applications)) {
@@ -852,8 +851,115 @@ function findPackagePath(opts) {
852
851
  return result;
853
852
  }
854
853
 
855
- // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
854
+ // src/config-v2/microfrontends/utils/find-default-package.ts
855
+ import { dirname as dirname2 } from "node:path";
856
+ import { readFileSync as readFileSync2 } from "node:fs";
857
+ import fg2 from "fast-glob";
858
+ var configCache2 = {};
859
+ function findDefaultMicrofrontendsPackages({
860
+ repositoryRoot,
861
+ applicationName
862
+ }) {
863
+ try {
864
+ const microfrontendsJsonPaths = fg2.globSync("**/microfrontends.json", {
865
+ cwd: repositoryRoot,
866
+ absolute: true,
867
+ onlyFiles: true,
868
+ followSymbolicLinks: false,
869
+ ignore: ["**/node_modules/**", "**/.git/**"]
870
+ });
871
+ const matchingPaths = [];
872
+ for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
873
+ const microfrontendsJsonContent = readFileSync2(
874
+ microfrontendsJsonPath,
875
+ "utf-8"
876
+ );
877
+ const microfrontendsJson = JSON.parse(
878
+ microfrontendsJsonContent
879
+ );
880
+ if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
881
+ matchingPaths.push(microfrontendsJsonPath);
882
+ }
883
+ }
884
+ if (matchingPaths.length > 1) {
885
+ throw new Error(
886
+ `Found multiple default applications referencing "${applicationName}" in the repository, this is not yet supported.
887
+ ${matchingPaths.join("\n \u2022 ")}`
888
+ );
889
+ }
890
+ if (matchingPaths.length === 0) {
891
+ throw new Error(
892
+ `Could not find default application with "applications.${applicationName}"`
893
+ );
894
+ }
895
+ const [packageJsonPath] = matchingPaths;
896
+ return dirname2(packageJsonPath);
897
+ } catch (error) {
898
+ return null;
899
+ }
900
+ }
901
+ function findDefaultMicrofrontendsPackage(opts) {
902
+ const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
903
+ if (configCache2[cacheKey]) {
904
+ return configCache2[cacheKey];
905
+ }
906
+ const result = findDefaultMicrofrontendsPackages(opts);
907
+ if (!result) {
908
+ throw new Error(
909
+ `Error trying to resolve the main microfrontends.json configuration`
910
+ );
911
+ }
912
+ configCache2[cacheKey] = result;
913
+ return result;
914
+ }
915
+
916
+ // src/config-v2/microfrontends/utils/is-monorepo.ts
917
+ import fs2 from "node:fs";
856
918
  import path2 from "node:path";
919
+ function isMonorepo({
920
+ repositoryRoot
921
+ }) {
922
+ try {
923
+ if (fs2.existsSync(path2.join(repositoryRoot, "pnpm-workspace.yaml"))) {
924
+ return true;
925
+ }
926
+ if (fs2.existsSync(path2.join(repositoryRoot, "vlt-workspaces.json"))) {
927
+ return true;
928
+ }
929
+ const packageJsonPath = path2.join(repositoryRoot, "package.json");
930
+ if (!fs2.existsSync(packageJsonPath)) {
931
+ return false;
932
+ }
933
+ const packageJson = JSON.parse(
934
+ fs2.readFileSync(packageJsonPath, "utf-8")
935
+ );
936
+ return packageJson.workspaces !== void 0;
937
+ } catch (error) {
938
+ console.error("Error determining if repository is a monorepo", error);
939
+ return false;
940
+ }
941
+ }
942
+
943
+ // src/config-v2/microfrontends/utils/find-package-root.ts
944
+ import fs3 from "node:fs";
945
+ import path3 from "node:path";
946
+ var PACKAGE_JSON = "package.json";
947
+ function findPackageRoot(startDir) {
948
+ let currentDir = startDir || process.cwd();
949
+ while (currentDir !== path3.parse(currentDir).root) {
950
+ const pkgJsonPath = path3.join(currentDir, PACKAGE_JSON);
951
+ if (fs3.existsSync(pkgJsonPath)) {
952
+ return currentDir;
953
+ }
954
+ currentDir = path3.dirname(currentDir);
955
+ }
956
+ throw new Error(
957
+ "Package root not found. Specify the root of the package with the `package.root` option."
958
+ );
959
+ }
960
+
961
+ // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
962
+ import path4 from "node:path";
857
963
 
858
964
  // src/config-v2/microfrontends/server/constants.ts
859
965
  var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
@@ -867,13 +973,13 @@ function isVercel() {
867
973
  // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
868
974
  function getOutputFilePath() {
869
975
  if (isVercel()) {
870
- return path2.join(
976
+ return path4.join(
871
977
  ".vercel",
872
978
  MFE_CONFIG_DEFAULT_FILE_PATH,
873
979
  MFE_CONFIG_DEFAULT_FILE_NAME
874
980
  );
875
981
  }
876
- return path2.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
982
+ return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
877
983
  }
878
984
 
879
985
  // src/config-v2/microfrontends/server/validation.ts
@@ -1007,15 +1113,12 @@ var schema_v2_default = {
1007
1113
  },
1008
1114
  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."
1009
1115
  },
1010
- provider: {
1011
- $ref: "#/definitions/Provider"
1012
- },
1013
1116
  applications: {
1014
1117
  $ref: "#/definitions/ApplicationRouting",
1015
1118
  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"
1016
1119
  }
1017
1120
  },
1018
- required: ["applications", "provider", "version"]
1121
+ required: ["applications", "version"]
1019
1122
  },
1020
1123
  Options: {
1021
1124
  type: "object",
@@ -1087,9 +1190,6 @@ var schema_v2_default = {
1087
1190
  projectId: {
1088
1191
  type: "string",
1089
1192
  description: "Vercel project ID"
1090
- },
1091
- routeSpeedInsightsToDefaultZone: {
1092
- type: "boolean"
1093
1193
  }
1094
1194
  },
1095
1195
  required: ["projectId"]
@@ -1192,10 +1292,6 @@ var schema_v2_default = {
1192
1292
  },
1193
1293
  required: ["paths"]
1194
1294
  },
1195
- Provider: {
1196
- type: "string",
1197
- enum: ["vercel", "other"]
1198
- },
1199
1295
  ApplicationRouting: {
1200
1296
  type: "object",
1201
1297
  additionalProperties: {
@@ -1259,8 +1355,8 @@ var MicrofrontendsServer = class extends Microfrontends {
1259
1355
  pretty: true
1260
1356
  }) {
1261
1357
  const outputPath = getOutputFilePath();
1262
- fs2.mkdirSync(dirname2(outputPath), { recursive: true });
1263
- fs2.writeFileSync(
1358
+ fs4.mkdirSync(dirname3(outputPath), { recursive: true });
1359
+ fs4.writeFileSync(
1264
1360
  outputPath,
1265
1361
  JSON.stringify(
1266
1362
  this.config.toSchemaJson(),
@@ -1322,6 +1418,69 @@ var MicrofrontendsServer = class extends Microfrontends {
1322
1418
  }
1323
1419
  return config;
1324
1420
  }
1421
+ /**
1422
+ * Looks up the configuration by inferring the package root and looking for a microfrontends.json file. If a file is not found,
1423
+ * it will look for a package in the repository with a microfrontends.json file that contains the current application
1424
+ * and use that configuration.
1425
+ *
1426
+ * This can return either a Child or Main configuration.
1427
+ */
1428
+ static infer({
1429
+ directory,
1430
+ filePath,
1431
+ meta,
1432
+ cookies,
1433
+ options
1434
+ } = {}) {
1435
+ if (filePath && meta) {
1436
+ return MicrofrontendsServer.fromFile({
1437
+ filePath,
1438
+ cookies,
1439
+ meta,
1440
+ options
1441
+ });
1442
+ }
1443
+ try {
1444
+ const packageRoot = findPackageRoot(directory);
1445
+ const packageJsonPath = join(packageRoot, "package.json");
1446
+ const packageJson = JSON.parse(
1447
+ fs4.readFileSync(packageJsonPath, "utf-8")
1448
+ );
1449
+ if (!packageJson.name) {
1450
+ throw new Error(`No name found in package.json at ${packageJsonPath}`);
1451
+ }
1452
+ const configMeta = meta ?? { fromApp: packageJson.name };
1453
+ const maybeConfig = join(packageRoot, "microfrontends.json");
1454
+ if (fs4.existsSync(maybeConfig)) {
1455
+ return MicrofrontendsServer.fromFile({
1456
+ filePath: maybeConfig,
1457
+ cookies,
1458
+ meta: configMeta,
1459
+ options
1460
+ });
1461
+ }
1462
+ const repositoryRoot = findRepositoryRoot();
1463
+ const isMonorepo2 = isMonorepo({ repositoryRoot });
1464
+ if (isMonorepo2) {
1465
+ const defaultPackage = findDefaultMicrofrontendsPackage({
1466
+ repositoryRoot,
1467
+ applicationName: packageJson.name
1468
+ });
1469
+ return MicrofrontendsServer.fromFile({
1470
+ filePath: join(defaultPackage, "microfrontends.json"),
1471
+ cookies,
1472
+ meta: configMeta,
1473
+ options
1474
+ });
1475
+ }
1476
+ throw new Error("Unable to infer");
1477
+ } catch (e) {
1478
+ throw new MicrofrontendError(
1479
+ "Unable to infer microfrontends configuration",
1480
+ { type: "config", subtype: "inference_failed" }
1481
+ );
1482
+ }
1483
+ }
1325
1484
  /*
1326
1485
  * Generates a MicrofrontendsServer instance from a file.
1327
1486
  */
@@ -1332,25 +1491,28 @@ var MicrofrontendsServer = class extends Microfrontends {
1332
1491
  options
1333
1492
  }) {
1334
1493
  try {
1335
- const configJson = fs2.readFileSync(filePath, "utf-8");
1494
+ const configJson = fs4.readFileSync(filePath, "utf-8");
1336
1495
  const config = MicrofrontendsServer.validate(configJson);
1337
1496
  if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
1338
1497
  const repositoryRoot = findRepositoryRoot();
1339
- const packagePath = findPackagePath({
1340
- repositoryRoot,
1341
- name: config.partOf
1342
- });
1343
- if (!packagePath) {
1344
- throw new MicrofrontendError(
1345
- `Could not find default application "${config.partOf}" in the repository`,
1346
- { type: "config", subtype: "not_found" }
1347
- );
1498
+ const isMonorepo2 = isMonorepo({ repositoryRoot });
1499
+ if (isMonorepo2) {
1500
+ const packagePath = findPackagePath({
1501
+ repositoryRoot,
1502
+ name: config.partOf
1503
+ });
1504
+ if (!packagePath) {
1505
+ throw new MicrofrontendError(
1506
+ `Could not find default application "${config.partOf}" in the repository`,
1507
+ { type: "config", subtype: "not_found" }
1508
+ );
1509
+ }
1510
+ const mainConfigPath = join(packagePath, "microfrontends.json");
1511
+ return MicrofrontendsServer.fromMainConfigFile({
1512
+ filePath: mainConfigPath,
1513
+ overrides: cookies ? parseOverrides(cookies) : void 0
1514
+ });
1348
1515
  }
1349
- const mainConfigPath = join(packagePath, "microfrontends.json");
1350
- return MicrofrontendsServer.fromMainConfigFile({
1351
- filePath: mainConfigPath,
1352
- overrides: cookies ? parseOverrides(cookies) : void 0
1353
- });
1354
1516
  }
1355
1517
  return new MicrofrontendsServer({
1356
1518
  config,
@@ -1371,7 +1533,7 @@ var MicrofrontendsServer = class extends Microfrontends {
1371
1533
  overrides
1372
1534
  }) {
1373
1535
  try {
1374
- const config = fs2.readFileSync(filePath, "utf-8");
1536
+ const config = fs4.readFileSync(filePath, "utf-8");
1375
1537
  const validatedConfig = MicrofrontendsServer.validate(config);
1376
1538
  if (!isMainConfig(validatedConfig)) {
1377
1539
  throw new MicrofrontendError(
@@ -1509,24 +1671,26 @@ function getDomainFromEnvironment({
1509
1671
  app,
1510
1672
  target
1511
1673
  }) {
1512
- const projects = JSON.parse(
1513
- process.env.VERCEL_RELATED_PROJECTS ?? "[]"
1674
+ var _a, _b;
1675
+ const mfeProjects = JSON.parse(
1676
+ process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? "{}"
1514
1677
  );
1515
- if (projects.length === 0) {
1516
- throw new Error("Missing related vercel project information");
1678
+ if (Object.keys(mfeProjects).length === 0) {
1679
+ throw new Error("Missing related microfrontends project information");
1517
1680
  }
1518
- const vercelProject = projects.find(
1519
- (project) => {
1520
- var _a;
1521
- return project.projectId === ((_a = app.vercel) == null ? void 0 : _a.projectId) || project.appName === app.name;
1522
- }
1523
- );
1681
+ if (!((_a = app.vercel) == null ? void 0 : _a.projectId)) {
1682
+ throw new Error(`Missing applications[${app.name}].vercel.projectId`);
1683
+ }
1684
+ const vercelProject = (_b = mfeProjects.applications) == null ? void 0 : _b[app.vercel.projectId];
1524
1685
  if (!vercelProject) {
1525
1686
  throw new Error(
1526
- `Missing related vercel project information for application "${app.name}"`
1687
+ `Missing related microfrontends project information for application "${app.name}"`
1527
1688
  );
1528
1689
  }
1529
- return vercelProject.aliases[target];
1690
+ if (target === "preview" && vercelProject.deploymentAlias) {
1691
+ return vercelProject.deploymentAlias;
1692
+ }
1693
+ return vercelProject.productionHost;
1530
1694
  }
1531
1695
 
1532
1696
  // src/routing-v2/get-domain-for-current-environment.ts
@@ -1565,12 +1729,12 @@ function getDomainForCurrentEnvironment(config, appName) {
1565
1729
  const productionHost = config.getDefaultApplication().production.toString();
1566
1730
  switch (group) {
1567
1731
  case "development": {
1568
- const domain = process.env.NODE_ENV === "test" ? app.development.local.toString() : productionHost;
1732
+ const domain = ["test", "development"].includes(process.env.NODE_ENV) ? app.development.local.toString() : productionHost;
1569
1733
  debugDomains(appName, "development", domain);
1570
1734
  return domain;
1571
1735
  }
1572
1736
  case "preview": {
1573
- return getDomainFromEnvironment({ app, target: "branch" });
1737
+ return getDomainFromEnvironment({ app, target: "preview" });
1574
1738
  }
1575
1739
  case "production": {
1576
1740
  return getDomainFromEnvironment({ app, target: "production" });
@@ -1602,11 +1766,11 @@ ${table}
1602
1766
  `);
1603
1767
  }
1604
1768
  }
1605
- function pathToRewrites(path3) {
1769
+ function pathToRewrites(path5) {
1606
1770
  var _a;
1607
1771
  const regex = /(?<base>^.+)\/:.+\*$/;
1608
- const match = regex.exec(path3);
1609
- const paths = [path3];
1772
+ const match = regex.exec(path5);
1773
+ const paths = [path5];
1610
1774
  if ((_a = match == null ? void 0 : match.groups) == null ? void 0 : _a.base) {
1611
1775
  paths.unshift(match.groups.base);
1612
1776
  }
@@ -1620,7 +1784,16 @@ function rewritesMapToArr(rewrites) {
1620
1784
  return [
1621
1785
  {
1622
1786
  source,
1623
- destination
1787
+ destination,
1788
+ missing: [
1789
+ // if this header is present, the proxy has performed the rewrite.
1790
+ // once the proxy routing is fully rolled out, this package should
1791
+ // be updated to not perform any rewrites when deployed.
1792
+ {
1793
+ type: "header",
1794
+ key: "x-vercel-mfe-host"
1795
+ }
1796
+ ]
1624
1797
  }
1625
1798
  ];
1626
1799
  });
@@ -1628,15 +1801,9 @@ function rewritesMapToArr(rewrites) {
1628
1801
  function transform4(args) {
1629
1802
  const { next, microfrontend, app } = args;
1630
1803
  const buildBeforeFiles = () => {
1631
- var _a;
1632
1804
  const rewrites = /* @__PURE__ */ new Map();
1633
1805
  if (!app.isDefault()) {
1634
- rewrites.set(`/${app.getAssetPrefix()}/_next/:path+`, {
1635
- destination: {
1636
- pathname: `/_next/:path+`
1637
- }
1638
- });
1639
- if (!((_a = app.vercel) == null ? void 0 : _a.routeSpeedInsightsToDefaultZone)) {
1806
+ if (process.env.VERCEL_MICROFRONTENDS_CONSOLIDATE_SPEED_INSIGHTS === "1") {
1640
1807
  rewrites.set(`/${app.getAssetPrefix()}/_vercel/:path*`, {
1641
1808
  destination: { pathname: "/_vercel/:path*" }
1642
1809
  });
@@ -1854,7 +2021,7 @@ function getApplicationContext(opts) {
1854
2021
  return { name: opts.appName };
1855
2022
  }
1856
2023
  try {
1857
- const packageJsonString = fs3.readFileSync("./package.json", "utf-8");
2024
+ const packageJsonString = fs5.readFileSync("./package.json", "utf-8");
1858
2025
  const packageJson = JSON.parse(packageJsonString);
1859
2026
  if (!packageJson.name) {
1860
2027
  throw new MicrofrontendError(
@@ -1879,8 +2046,8 @@ function withMicrofrontends(nextConfig, opts) {
1879
2046
  process.env.MFE_DEBUG = "true";
1880
2047
  }
1881
2048
  const { name: fromApp } = getApplicationContext(opts);
1882
- const microfrontends = MicrofrontendsServer.fromFile({
1883
- filePath: (opts == null ? void 0 : opts.configPath) ?? "./microfrontends.json",
2049
+ const microfrontends = MicrofrontendsServer.infer({
2050
+ filePath: opts == null ? void 0 : opts.configPath,
1884
2051
  meta: {
1885
2052
  fromApp
1886
2053
  }