@vercel/microfrontends 0.12.0 → 0.13.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 (39) hide show
  1. package/dist/bin/cli.cjs +159 -67
  2. package/dist/{index-35038aec.d.ts → index-83133f2d.d.ts} +1 -0
  3. package/dist/next/config.cjs +2 -2
  4. package/dist/next/config.cjs.map +1 -1
  5. package/dist/next/config.js +2 -2
  6. package/dist/next/config.js.map +1 -1
  7. package/dist/next/middleware.cjs +5 -3
  8. package/dist/next/middleware.cjs.map +1 -1
  9. package/dist/next/middleware.js +5 -3
  10. package/dist/next/middleware.js.map +1 -1
  11. package/dist/utils/mfe-port.cjs +2690 -0
  12. package/dist/utils/mfe-port.cjs.map +1 -0
  13. package/dist/utils/mfe-port.d.ts +8 -0
  14. package/dist/utils/mfe-port.js +2655 -0
  15. package/dist/utils/mfe-port.js.map +1 -0
  16. package/dist/v2/config.cjs +3 -0
  17. package/dist/v2/config.cjs.map +1 -1
  18. package/dist/v2/config.d.ts +1 -1
  19. package/dist/v2/config.js +3 -0
  20. package/dist/v2/config.js.map +1 -1
  21. package/dist/v2/microfrontends/server.cjs +3 -0
  22. package/dist/v2/microfrontends/server.cjs.map +1 -1
  23. package/dist/v2/microfrontends/server.d.ts +1 -1
  24. package/dist/v2/microfrontends/server.js +3 -0
  25. package/dist/v2/microfrontends/server.js.map +1 -1
  26. package/dist/v2/microfrontends.cjs +3 -0
  27. package/dist/v2/microfrontends.cjs.map +1 -1
  28. package/dist/v2/microfrontends.d.ts +1 -1
  29. package/dist/v2/microfrontends.js +3 -0
  30. package/dist/v2/microfrontends.js.map +1 -1
  31. package/dist/v2/next/config.cjs +20 -9
  32. package/dist/v2/next/config.cjs.map +1 -1
  33. package/dist/v2/next/config.js +20 -9
  34. package/dist/v2/next/config.js.map +1 -1
  35. package/dist/v2/next/middleware.cjs +24 -10
  36. package/dist/v2/next/middleware.cjs.map +1 -1
  37. package/dist/v2/next/middleware.js +24 -10
  38. package/dist/v2/next/middleware.js.map +1 -1
  39. package/package.json +12 -5
package/dist/bin/cli.cjs CHANGED
@@ -29,7 +29,7 @@ var import_commander = require("commander");
29
29
  // package.json
30
30
  var package_default = {
31
31
  name: "@vercel/microfrontends",
32
- version: "0.12.0",
32
+ version: "0.13.0",
33
33
  private: false,
34
34
  description: "Defines configuration and utilities for micro-frontend development",
35
35
  repository: {
@@ -119,6 +119,10 @@ var package_default = {
119
119
  "./v2/next/client": {
120
120
  import: "./dist/v2/next/client.js",
121
121
  require: "./dist/v2/next/client.cjs"
122
+ },
123
+ "./utils/mfe-port": {
124
+ import: "./dist/utils/mfe-port.js",
125
+ require: "./dist/utils/mfe-port.cjs"
122
126
  }
123
127
  },
124
128
  typesVersions: {
@@ -141,7 +145,8 @@ var package_default = {
141
145
  "v2/next/middleware": ["./dist/v2/next/middleware.d.ts"],
142
146
  "v2/next/endpoints": ["./dist/v2/next/endpoints.d.ts"],
143
147
  "next/client": ["./dist/next/client.d.ts"],
144
- "v2/next/client": ["./dist/v2/next/client.d.ts"]
148
+ "v2/next/client": ["./dist/v2/next/client.d.ts"],
149
+ "utils/mfe-port": ["./dist/utils/mfe-port.d.ts"]
145
150
  }
146
151
  },
147
152
  files: ["dist", "schema"],
@@ -182,7 +187,7 @@ var package_default = {
182
187
  "@vercel-private/conformance": "^1.12.2-canary.0",
183
188
  jest: "^29.7.0",
184
189
  "jest-environment-jsdom": "29.2.2",
185
- next: "15.1.1-canary.0",
190
+ next: "15.1.1-canary.12",
186
191
  react: "19.0.0",
187
192
  "react-dom": "19.0.0",
188
193
  "ts-json-schema-generator": "^1.1.2",
@@ -192,7 +197,7 @@ var package_default = {
192
197
  webpack: "5"
193
198
  },
194
199
  peerDependencies: {
195
- next: "15.1.1-canary.0",
200
+ next: "15.1.1-canary.12",
196
201
  react: "19.0.0",
197
202
  "react-dom": "19.0.0"
198
203
  },
@@ -1091,8 +1096,8 @@ function validateMainPath(applicationConfigsById) {
1091
1096
  });
1092
1097
  }
1093
1098
  for (const { id: otherId, paths } of pathsWithApp) {
1094
- const isValid = paths.every((path6) => {
1095
- const matcher = (0, import_path_to_regexp.pathToRegexp)(path6);
1099
+ const isValid = paths.every((path7) => {
1100
+ const matcher = (0, import_path_to_regexp.pathToRegexp)(path7);
1096
1101
  return !matcher.test(defaultRoute);
1097
1102
  });
1098
1103
  if (!isValid) {
@@ -1104,8 +1109,8 @@ function validateMainPath(applicationConfigsById) {
1104
1109
  }
1105
1110
  } else {
1106
1111
  const allPaths = app.routing.matches.flatMap((match) => match.paths);
1107
- const isValid = allPaths.some((path6) => {
1108
- const matcher = (0, import_path_to_regexp.pathToRegexp)(path6);
1112
+ const isValid = allPaths.some((path7) => {
1113
+ const matcher = (0, import_path_to_regexp.pathToRegexp)(path7);
1109
1114
  return matcher.test(defaultRoute);
1110
1115
  });
1111
1116
  if (!isValid) {
@@ -1125,18 +1130,18 @@ var validatePaths = (applicationConfigsById) => {
1125
1130
  continue;
1126
1131
  }
1127
1132
  for (const pathMatch of app.routing.matches) {
1128
- for (const path6 of pathMatch.paths) {
1129
- const maybeError = validatePathExpression(path6);
1133
+ for (const path7 of pathMatch.paths) {
1134
+ const maybeError = validatePathExpression(path7);
1130
1135
  if (maybeError) {
1131
1136
  errors.push(maybeError);
1132
1137
  }
1133
- const existing = pathsByApplicationId.get(path6);
1138
+ const existing = pathsByApplicationId.get(path7);
1134
1139
  if (existing) {
1135
1140
  existing.applications.push(id);
1136
1141
  } else {
1137
- pathsByApplicationId.set(path6, {
1142
+ pathsByApplicationId.set(path7, {
1138
1143
  applications: [id],
1139
- matcher: (0, import_path_to_regexp.pathToRegexp)(path6),
1144
+ matcher: (0, import_path_to_regexp.pathToRegexp)(path7),
1140
1145
  applicationId: id
1141
1146
  });
1142
1147
  }
@@ -1144,10 +1149,10 @@ var validatePaths = (applicationConfigsById) => {
1144
1149
  }
1145
1150
  }
1146
1151
  const entries = Array.from(pathsByApplicationId.entries());
1147
- entries.forEach(([path6, { applications: ids, matcher, applicationId }]) => {
1152
+ entries.forEach(([path7, { applications: ids, matcher, applicationId }]) => {
1148
1153
  if (ids.length > 1) {
1149
1154
  errors.push(
1150
- `Duplicate path "${path6}" for applications "${ids.join(", ")}"`
1155
+ `Duplicate path "${path7}" for applications "${ids.join(", ")}"`
1151
1156
  );
1152
1157
  }
1153
1158
  entries.forEach(
@@ -1155,14 +1160,14 @@ var validatePaths = (applicationConfigsById) => {
1155
1160
  matchPath,
1156
1161
  { applications: matchIds, applicationId: matchApplicationId }
1157
1162
  ]) => {
1158
- if (path6 === matchPath) {
1163
+ if (path7 === matchPath) {
1159
1164
  return;
1160
1165
  }
1161
1166
  if (applicationId === matchApplicationId) {
1162
1167
  return;
1163
1168
  }
1164
1169
  if (matcher.test(matchPath)) {
1165
- const source = `"${path6}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
1170
+ const source = `"${path7}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
1166
1171
  const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
1167
1172
  errors.push(
1168
1173
  `Overlapping path detected between ${source} and ${destination}`
@@ -1179,25 +1184,25 @@ var validatePaths = (applicationConfigsById) => {
1179
1184
  }
1180
1185
  };
1181
1186
  var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
1182
- function validatePathExpression(path6) {
1183
- const tokens = (0, import_path_to_regexp.parse)(path6);
1187
+ function validatePathExpression(path7) {
1188
+ const tokens = (0, import_path_to_regexp.parse)(path7);
1184
1189
  for (let i = 0; i < tokens.length; i++) {
1185
1190
  const token = tokens[i];
1186
1191
  if (token === void 0) {
1187
- return `token ${i} in ${path6} is undefined, this shouldn't happen`;
1192
+ return `token ${i} in ${path7} is undefined, this shouldn't happen`;
1188
1193
  }
1189
1194
  if (typeof token !== "string") {
1190
1195
  if (token.pattern !== PATH_DEFAULT_PATTERN) {
1191
- return `Path ${path6} cannot use a regular expression wildcard`;
1196
+ return `Path ${path7} cannot use a regular expression wildcard`;
1192
1197
  }
1193
1198
  if (token.prefix !== "/") {
1194
- return `Wildcard :${token.name} must be immediately after a / in ${path6}`;
1199
+ return `Wildcard :${token.name} must be immediately after a / in ${path7}`;
1195
1200
  }
1196
1201
  if (token.suffix) {
1197
1202
  return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;
1198
1203
  }
1199
1204
  if (token.modifier && i !== tokens.length - 1) {
1200
- return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path6}. Modifiers are only allowed in the last path component`;
1205
+ return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path7}. Modifiers are only allowed in the last path component`;
1201
1206
  }
1202
1207
  }
1203
1208
  }
@@ -1473,22 +1478,22 @@ var validateConfigPaths = (applicationConfigsById) => {
1473
1478
  continue;
1474
1479
  }
1475
1480
  for (const pathMatch of app.routing) {
1476
- for (const path6 of pathMatch.paths) {
1477
- const tokens = (0, import_path_to_regexp2.parse)(path6);
1481
+ for (const path7 of pathMatch.paths) {
1482
+ const tokens = (0, import_path_to_regexp2.parse)(path7);
1478
1483
  for (const token of tokens.slice(0, -1)) {
1479
1484
  if (typeof token !== "string") {
1480
1485
  errors.push(
1481
- `Path ${path6} may only have a :wildcard in the last path component`
1486
+ `Path ${path7} may only have a :wildcard in the last path component`
1482
1487
  );
1483
1488
  }
1484
1489
  }
1485
- const existing = pathsByApplicationId.get(path6);
1490
+ const existing = pathsByApplicationId.get(path7);
1486
1491
  if (existing) {
1487
1492
  existing.applications.push(id);
1488
1493
  } else {
1489
- pathsByApplicationId.set(path6, {
1494
+ pathsByApplicationId.set(path7, {
1490
1495
  applications: [id],
1491
- matcher: (0, import_path_to_regexp2.pathToRegexp)(path6),
1496
+ matcher: (0, import_path_to_regexp2.pathToRegexp)(path7),
1492
1497
  applicationId: id
1493
1498
  });
1494
1499
  }
@@ -1496,10 +1501,10 @@ var validateConfigPaths = (applicationConfigsById) => {
1496
1501
  }
1497
1502
  }
1498
1503
  const entries = Array.from(pathsByApplicationId.entries());
1499
- entries.forEach(([path6, { applications: ids, matcher, applicationId }]) => {
1504
+ entries.forEach(([path7, { applications: ids, matcher, applicationId }]) => {
1500
1505
  if (ids.length > 1) {
1501
1506
  errors.push(
1502
- `Duplicate path "${path6}" for applications "${ids.join(", ")}"`
1507
+ `Duplicate path "${path7}" for applications "${ids.join(", ")}"`
1503
1508
  );
1504
1509
  }
1505
1510
  entries.forEach(
@@ -1507,14 +1512,14 @@ var validateConfigPaths = (applicationConfigsById) => {
1507
1512
  matchPath,
1508
1513
  { applications: matchIds, applicationId: matchApplicationId }
1509
1514
  ]) => {
1510
- if (path6 === matchPath) {
1515
+ if (path7 === matchPath) {
1511
1516
  return;
1512
1517
  }
1513
1518
  if (applicationId === matchApplicationId) {
1514
1519
  return;
1515
1520
  }
1516
1521
  if (matcher.test(matchPath)) {
1517
- const source = `"${path6}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
1522
+ const source = `"${path7}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
1518
1523
  const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
1519
1524
  errors.push(
1520
1525
  `Overlapping path detected between ${source} and ${destination}`
@@ -1718,6 +1723,9 @@ var DefaultApplication = class extends Application2 {
1718
1723
  this.default = true;
1719
1724
  this.production = new Host2(app.production);
1720
1725
  }
1726
+ getAssetPrefix() {
1727
+ return "";
1728
+ }
1721
1729
  };
1722
1730
  var ChildApplication = class extends Application2 {
1723
1731
  constructor(name, {
@@ -1789,21 +1797,21 @@ var MicrofrontendConfigClient = class {
1789
1797
  isEqual(other) {
1790
1798
  return JSON.stringify(this.applications) === JSON.stringify(other.applications);
1791
1799
  }
1792
- getApplicationNameForPath(path6) {
1793
- if (!path6.startsWith("/")) {
1800
+ getApplicationNameForPath(path7) {
1801
+ if (!path7.startsWith("/")) {
1794
1802
  throw new Error(`Path must start with a /`);
1795
1803
  }
1796
- if (this.pathCache[path6]) {
1797
- return this.pathCache[path6];
1804
+ if (this.pathCache[path7]) {
1805
+ return this.pathCache[path7];
1798
1806
  }
1799
- const pathname = new URL(path6, "https://example.com").pathname;
1807
+ const pathname = new URL(path7, "https://example.com").pathname;
1800
1808
  for (const [name, application] of Object.entries(this.applications)) {
1801
1809
  if (application.routing) {
1802
1810
  for (const group of application.routing) {
1803
1811
  for (const childPath of group.paths) {
1804
1812
  const regexp = (0, import_path_to_regexp3.pathToRegexp)(childPath);
1805
1813
  if (regexp.test(pathname)) {
1806
- this.pathCache[path6] = name;
1814
+ this.pathCache[path7] = name;
1807
1815
  return name;
1808
1816
  }
1809
1817
  }
@@ -1816,7 +1824,7 @@ var MicrofrontendConfigClient = class {
1816
1824
  if (!defaultApplication) {
1817
1825
  return null;
1818
1826
  }
1819
- this.pathCache[path6] = defaultApplication[0];
1827
+ this.pathCache[path7] = defaultApplication[0];
1820
1828
  return defaultApplication[0];
1821
1829
  }
1822
1830
  serialize() {
@@ -2841,13 +2849,14 @@ var LocalProxy = class {
2841
2849
  proxyPort
2842
2850
  }) {
2843
2851
  let configV2;
2852
+ let configV2Err;
2844
2853
  try {
2845
2854
  configV2 = MicrofrontendsServer.fromMainConfigFile({
2846
2855
  filePath
2847
2856
  });
2848
2857
  } catch (error) {
2849
2858
  if ((0, import_types2.isNativeError)(error)) {
2850
- mfeDebug(`unable to parse v2 version: ${error.toString()}`);
2859
+ configV2Err = error;
2851
2860
  }
2852
2861
  }
2853
2862
  if (configV2) {
@@ -2856,8 +2865,15 @@ var LocalProxy = class {
2856
2865
  }
2857
2866
  throw new Error("Got child config after parsing main config");
2858
2867
  }
2859
- const configV1 = MicrofrontendConfig.fromFile({ filePath });
2860
- return new LocalProxy(configV1, { localApps, proxyPort });
2868
+ try {
2869
+ const configV1 = MicrofrontendConfig.fromFile({ filePath });
2870
+ return new LocalProxy(configV1, { localApps, proxyPort });
2871
+ } catch (error) {
2872
+ if (configV2Err) {
2873
+ throw configV2Err;
2874
+ }
2875
+ throw error;
2876
+ }
2861
2877
  }
2862
2878
  getDefaultHost(config) {
2863
2879
  let defaultApp;
@@ -2907,7 +2923,7 @@ var LocalProxy = class {
2907
2923
  const isJWTRedirect = url.searchParams.has("_vercel_jwt");
2908
2924
  const defaultHost = this.getDefaultHost(config);
2909
2925
  let hostname = null;
2910
- let path6 = request2.url;
2926
+ let path7 = request2.url;
2911
2927
  if (isAuthRedirect) {
2912
2928
  hostname = url.searchParams.get("_host_override");
2913
2929
  }
@@ -2917,12 +2933,12 @@ var LocalProxy = class {
2917
2933
  if (isJWTRedirect) {
2918
2934
  hostname = url.searchParams.get("_host_override");
2919
2935
  url.searchParams.delete("_host_override");
2920
- path6 = `${url.pathname}${url.search}`;
2936
+ path7 = `${url.pathname}${url.search}`;
2921
2937
  }
2922
2938
  if (!hostname) {
2923
2939
  return void 0;
2924
2940
  }
2925
- return { ...defaultHost, path: path6, hostname, protocol: "https", port: 443 };
2941
+ return { ...defaultHost, path: path7, hostname, protocol: "https", port: 443 };
2926
2942
  }
2927
2943
  getConfigWithOverrides(cookies) {
2928
2944
  if (isV2Config(this.config)) {
@@ -2953,19 +2969,19 @@ var LocalProxy = class {
2953
2969
  getTarget(request2) {
2954
2970
  const cookies = (0, import_cookie.parse)(request2.headers.cookie || "");
2955
2971
  const config = this.getConfigWithOverrides(cookies);
2956
- const path6 = request2.url;
2957
- if (!path6) {
2972
+ const path7 = request2.url;
2973
+ if (!path7) {
2958
2974
  return this.getDefaultHost(config);
2959
2975
  }
2960
2976
  const authTarget = this.getAuthTarget(request2, config);
2961
2977
  if (authTarget) {
2962
2978
  return authTarget;
2963
2979
  }
2964
- const url = new URL(`http://example.com${path6}`);
2980
+ const url = new URL(`http://example.com${path7}`);
2965
2981
  const pathname = url.pathname;
2966
2982
  if (isV2Config(config)) {
2967
2983
  const target = this.findMatchingApplicationV2(
2968
- path6,
2984
+ path7,
2969
2985
  pathname,
2970
2986
  config.getChildApplications()
2971
2987
  );
@@ -2973,7 +2989,7 @@ var LocalProxy = class {
2973
2989
  return target;
2974
2990
  } else {
2975
2991
  const target = this.findMatchingApplicationV1(
2976
- path6,
2992
+ path7,
2977
2993
  pathname,
2978
2994
  config.getAllApplications()
2979
2995
  );
@@ -2982,11 +2998,11 @@ var LocalProxy = class {
2982
2998
  }
2983
2999
  const defaultHost = this.getDefaultHost(config);
2984
3000
  mfeDebug(
2985
- `no matching routes, routing ${path6} to default application: ${JSON.stringify(defaultHost)}`
3001
+ `no matching routes, routing ${path7} to default application: ${JSON.stringify(defaultHost)}`
2986
3002
  );
2987
- return { path: path6, ...defaultHost };
3003
+ return { path: path7, ...defaultHost };
2988
3004
  }
2989
- findMatchingApplicationV1(path6, pathname, applications) {
3005
+ findMatchingApplicationV1(path7, pathname, applications) {
2990
3006
  for (const application of Object.values(applications)) {
2991
3007
  if (application.routing) {
2992
3008
  for (const group of application.routing.matches) {
@@ -2995,9 +3011,9 @@ var LocalProxy = class {
2995
3011
  if (regexp.test(pathname)) {
2996
3012
  const target = this.getApplicationTarget(application);
2997
3013
  mfeDebug(
2998
- `routing ${path6} to '${target.application}' at ${target.hostname}`
3014
+ `routing ${path7} to '${target.application}' at ${target.hostname}`
2999
3015
  );
3000
- return { path: path6, ...target };
3016
+ return { path: path7, ...target };
3001
3017
  }
3002
3018
  }
3003
3019
  if (application.routing.assetPrefix) {
@@ -3007,9 +3023,9 @@ var LocalProxy = class {
3007
3023
  if (pattern.test(pathname)) {
3008
3024
  const target = this.getApplicationTarget(application);
3009
3025
  mfeDebug(
3010
- `routing ${path6} to '${target.application}' at ${target.hostname}`
3026
+ `routing ${path7} to '${target.application}' at ${target.hostname}`
3011
3027
  );
3012
- return { path: path6, ...target };
3028
+ return { path: path7, ...target };
3013
3029
  }
3014
3030
  }
3015
3031
  }
@@ -3017,7 +3033,7 @@ var LocalProxy = class {
3017
3033
  }
3018
3034
  return null;
3019
3035
  }
3020
- findMatchingApplicationV2(path6, pathname, applications) {
3036
+ findMatchingApplicationV2(path7, pathname, applications) {
3021
3037
  for (const application of Object.values(applications)) {
3022
3038
  for (const group of application.routing) {
3023
3039
  for (const childPath of group.paths) {
@@ -3025,9 +3041,9 @@ var LocalProxy = class {
3025
3041
  if (regexp.test(pathname)) {
3026
3042
  const target = this.getApplicationTarget(application);
3027
3043
  mfeDebug(
3028
- `routing ${path6} to '${target.application}' at ${target.hostname}`
3044
+ `routing ${path7} to '${target.application}' at ${target.hostname}`
3029
3045
  );
3030
- return { path: path6, ...target };
3046
+ return { path: path7, ...target };
3031
3047
  }
3032
3048
  }
3033
3049
  }
@@ -3036,11 +3052,11 @@ var LocalProxy = class {
3036
3052
  }
3037
3053
  // Handles requests that return data from the local proxy itself.
3038
3054
  // Returns true if the request was handled, false otherwise.
3039
- handleProxyInfoRequest(path6, res) {
3040
- if (!path6) {
3055
+ handleProxyInfoRequest(path7, res) {
3056
+ if (!path7) {
3041
3057
  return false;
3042
3058
  }
3043
- const url = new URL(`http://example.comf${path6}`);
3059
+ const url = new URL(`http://example.comf${path7}`);
3044
3060
  const pathname = url.pathname;
3045
3061
  switch (pathname) {
3046
3062
  case "/.well-known/vercel/microfrontend-routing": {
@@ -3068,10 +3084,10 @@ var LocalProxy = class {
3068
3084
  }
3069
3085
  const target = this.getTarget(req);
3070
3086
  if (target.protocol === "https") {
3071
- const { hostname, port, path: path6 } = target;
3087
+ const { hostname, port, path: path7 } = target;
3072
3088
  const requestOptions = {
3073
3089
  hostname,
3074
- path: path6,
3090
+ path: path7,
3075
3091
  method: req.method,
3076
3092
  headers: {
3077
3093
  ...req.headers,
@@ -3099,7 +3115,7 @@ var LocalProxy = class {
3099
3115
  console.error("Proxy request error: ", err);
3100
3116
  res.writeHead(500, { "Content-Type": "text/plain" });
3101
3117
  res.end(
3102
- `Error proxying request for ${target.application} to ${hostname}:${port}${path6}`
3118
+ `Error proxying request for ${target.application} to ${hostname}:${port}${path7}`
3103
3119
  );
3104
3120
  });
3105
3121
  } else {
@@ -3126,6 +3142,79 @@ var LocalProxy = class {
3126
3142
  }
3127
3143
  };
3128
3144
 
3145
+ // src/bin/port.ts
3146
+ var import_node_process = require("process");
3147
+
3148
+ // src/utils/mfe-port.ts
3149
+ var import_node_path10 = __toESM(require("path"), 1);
3150
+ var import_node_fs9 = __toESM(require("fs"), 1);
3151
+ function mfePort(packageDir) {
3152
+ const { name: appName, version } = getPackageJson(packageDir);
3153
+ const result = loadV2({ packageDir, appName }) || loadV1({ packageDir, appName });
3154
+ if (!result) {
3155
+ throw new MicrofrontendError2(
3156
+ `Unable to determine configured port for ${appName}`,
3157
+ { type: "config", subtype: "not_found" }
3158
+ );
3159
+ }
3160
+ const { port } = result;
3161
+ return {
3162
+ name: appName,
3163
+ version,
3164
+ port
3165
+ };
3166
+ }
3167
+ function getPackageJson(packageDir) {
3168
+ const filePath = import_node_path10.default.join(packageDir, "package.json");
3169
+ return JSON.parse(import_node_fs9.default.readFileSync(filePath, "utf-8"));
3170
+ }
3171
+ function loadV2({
3172
+ packageDir,
3173
+ appName
3174
+ }) {
3175
+ let config;
3176
+ try {
3177
+ config = MicrofrontendsServer.infer({
3178
+ directory: packageDir,
3179
+ meta: { fromApp: appName },
3180
+ options: { resolveMainConfig: true }
3181
+ });
3182
+ } catch (e) {
3183
+ return void 0;
3184
+ }
3185
+ const app = config.config.getApplication(appName);
3186
+ const port = app.development.local.port;
3187
+ return { port };
3188
+ }
3189
+ function loadV1({
3190
+ packageDir,
3191
+ appName
3192
+ }) {
3193
+ const filePath = import_node_path10.default.join(packageDir, "micro-frontends.jsonc");
3194
+ let config;
3195
+ try {
3196
+ config = MicrofrontendConfig.fromFile({ filePath });
3197
+ } catch (e) {
3198
+ return void 0;
3199
+ }
3200
+ const zone = config.getZone(appName);
3201
+ const port = zone.development.local.port;
3202
+ return { port };
3203
+ }
3204
+
3205
+ // src/bin/port.ts
3206
+ function displayPort() {
3207
+ const portInfo = mfePort((0, import_node_process.cwd)());
3208
+ header(portInfo);
3209
+ console.log(portInfo.port);
3210
+ }
3211
+ function header({ name, version, port }) {
3212
+ console.error(`
3213
+ \u25B2 ${name}@${version}
3214
+ \xB7 setting port to ${port}
3215
+ `);
3216
+ }
3217
+
3129
3218
  // src/bin/index.ts
3130
3219
  function main() {
3131
3220
  const program = new import_commander.Command();
@@ -3143,6 +3232,9 @@ function main() {
3143
3232
  });
3144
3233
  localProxy.startServer();
3145
3234
  });
3235
+ program.command("port").description("Prints development port").action(() => {
3236
+ displayPort();
3237
+ });
3146
3238
  program.parse(process.argv);
3147
3239
  }
3148
3240
  main();
@@ -86,6 +86,7 @@ declare class DefaultApplication extends Application {
86
86
  app: DefaultApplication$1;
87
87
  overrides?: ApplicationOverrideConfig;
88
88
  });
89
+ getAssetPrefix(): string;
89
90
  }
90
91
  declare class ChildApplication extends Application {
91
92
  readonly default = false;
@@ -1367,9 +1367,9 @@ ${line}
1367
1367
  `);
1368
1368
  }
1369
1369
  }
1370
- function getDomainForCurrentEnvironment(zone) {
1370
+ function getDomainForCurrentEnvironment(zone, opts = {}) {
1371
1371
  var _a;
1372
- if ((_a = zone.overrides) == null ? void 0 : _a.environment) {
1372
+ if (!opts.ignoreOverride && ((_a = zone.overrides) == null ? void 0 : _a.environment)) {
1373
1373
  return zone.overrides.environment.toString();
1374
1374
  }
1375
1375
  const zoneName = zone.name;