@vercel/microfrontends 2.1.3 → 2.2.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 (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -0
  3. package/dist/bin/cli.cjs +125 -89
  4. package/dist/config.d.ts +2 -2
  5. package/dist/experimental/sveltekit.cjs +97 -62
  6. package/dist/experimental/sveltekit.cjs.map +1 -1
  7. package/dist/experimental/sveltekit.d.ts +6 -0
  8. package/dist/experimental/sveltekit.js +97 -62
  9. package/dist/experimental/sveltekit.js.map +1 -1
  10. package/dist/experimental/vite.cjs +96 -65
  11. package/dist/experimental/vite.cjs.map +1 -1
  12. package/dist/experimental/vite.js +96 -65
  13. package/dist/experimental/vite.js.map +1 -1
  14. package/dist/microfrontends/server.cjs +92 -59
  15. package/dist/microfrontends/server.cjs.map +1 -1
  16. package/dist/microfrontends/server.d.ts +2 -2
  17. package/dist/microfrontends/server.js +92 -59
  18. package/dist/microfrontends/server.js.map +1 -1
  19. package/dist/microfrontends/utils.cjs +3 -3
  20. package/dist/microfrontends/utils.cjs.map +1 -1
  21. package/dist/microfrontends/utils.d.ts +1 -1
  22. package/dist/microfrontends/utils.js +3 -3
  23. package/dist/microfrontends/utils.js.map +1 -1
  24. package/dist/next/config.cjs +125 -112
  25. package/dist/next/config.cjs.map +1 -1
  26. package/dist/next/config.d.ts +11 -1
  27. package/dist/next/config.js +125 -112
  28. package/dist/next/config.js.map +1 -1
  29. package/dist/next/middleware.cjs +35 -17
  30. package/dist/next/middleware.cjs.map +1 -1
  31. package/dist/next/middleware.js +35 -17
  32. package/dist/next/middleware.js.map +1 -1
  33. package/dist/next/testing.d.ts +2 -2
  34. package/dist/overrides.d.ts +3 -3
  35. package/dist/schema.d.ts +2 -2
  36. package/dist/{types-88602303.d.ts → types-b9ea41b2.d.ts} +1 -1
  37. package/dist/{types-e7523e61.d.ts → types-dcd8b17a.d.ts} +71 -24
  38. package/dist/utils/mfe-port.cjs +92 -59
  39. package/dist/utils/mfe-port.cjs.map +1 -1
  40. package/dist/utils/mfe-port.js +92 -59
  41. package/dist/utils/mfe-port.js.map +1 -1
  42. package/dist/validation.cjs +47 -38
  43. package/dist/validation.cjs.map +1 -1
  44. package/dist/validation.d.ts +1 -1
  45. package/dist/validation.js +47 -38
  46. package/dist/validation.js.map +1 -1
  47. package/package.json +1 -1
  48. package/schema/schema.json +47 -38
@@ -34,12 +34,38 @@ __export(config_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(config_exports);
36
36
 
37
+ // src/bin/local-proxy-is-running.ts
38
+ function localProxyIsRunning() {
39
+ return process.env.TURBO_TASK_HAS_MFE_PROXY === "true";
40
+ }
41
+
42
+ // src/bin/logger.ts
43
+ function debug(...args) {
44
+ if (process.env.MFE_DEBUG) {
45
+ console.log(...args);
46
+ }
47
+ }
48
+ function info(...args) {
49
+ console.log(...args);
50
+ }
51
+ function warn(...args) {
52
+ console.warn(...args);
53
+ }
54
+ function error(...args) {
55
+ console.error(...args);
56
+ }
57
+ var logger = {
58
+ debug,
59
+ info,
60
+ warn,
61
+ error
62
+ };
63
+
37
64
  // src/bin/check-proxy.ts
38
65
  function displayLocalProxyInfo(port) {
39
- const { MFE_PROXY_MESSAGE_PRINTED, TURBO_TASK_HAS_MFE_PROXY } = process.env;
40
- if (TURBO_TASK_HAS_MFE_PROXY === "true" && MFE_PROXY_MESSAGE_PRINTED !== "true") {
66
+ if (localProxyIsRunning() && process.env.MFE_PROXY_MESSAGE_PRINTED !== "true") {
41
67
  process.env.MFE_PROXY_MESSAGE_PRINTED = "true";
42
- console.log(`Microfrontends Proxy running on http://localhost:${port}`);
68
+ logger.info(`Microfrontends Proxy running on http://localhost:${port}`);
43
69
  }
44
70
  }
45
71
 
@@ -234,8 +260,8 @@ var import_fast_glob = __toESM(require("fast-glob"), 1);
234
260
 
235
261
  // src/config/microfrontends/utils/get-config-file-name.ts
236
262
  var DEFAULT_CONFIGURATION_FILENAMES = [
237
- "microfrontends.jsonc",
238
- "microfrontends.json"
263
+ "microfrontends.json",
264
+ "microfrontends.jsonc"
239
265
  ];
240
266
  function getPossibleConfigurationFilenames({
241
267
  customConfigFilename
@@ -243,7 +269,7 @@ function getPossibleConfigurationFilenames({
243
269
  if (customConfigFilename) {
244
270
  if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
245
271
  throw new Error(
246
- `The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
272
+ `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.`
247
273
  );
248
274
  }
249
275
  return Array.from(
@@ -291,7 +317,7 @@ function findPackageWithMicrofrontendsConfig({
291
317
  }
292
318
  }
293
319
  }
294
- } catch (error) {
320
+ } catch (error2) {
295
321
  }
296
322
  }
297
323
  if (matchingPaths.length > 1) {
@@ -327,9 +353,9 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
327
353
  }
328
354
  const [packageJsonPath] = matchingPaths;
329
355
  return (0, import_node_path2.dirname)(packageJsonPath);
330
- } catch (error) {
331
- if (error instanceof MicrofrontendError) {
332
- throw error;
356
+ } catch (error2) {
357
+ if (error2 instanceof MicrofrontendError) {
358
+ throw error2;
333
359
  }
334
360
  return null;
335
361
  }
@@ -374,8 +400,8 @@ function isMonorepo({
374
400
  import_node_fs3.default.readFileSync(packageJsonPath, "utf-8")
375
401
  );
376
402
  return packageJson.workspaces !== void 0;
377
- } catch (error) {
378
- console.error("Error determining if repository is a monorepo", error);
403
+ } catch (error2) {
404
+ logger.error("Error determining if repository is a monorepo", error2);
379
405
  return false;
380
406
  }
381
407
  }
@@ -1169,38 +1195,28 @@ var schema_default = {
1169
1195
  type: "object",
1170
1196
  properties: {
1171
1197
  $schema: {
1172
- type: "string"
1198
+ type: "string",
1199
+ description: "See https://openapi.vercel.sh/microfrontends.json."
1173
1200
  },
1174
1201
  version: {
1175
1202
  type: "string",
1176
- const: "1"
1177
- },
1178
- options: {
1179
- $ref: "#/definitions/Options"
1203
+ const: "1",
1204
+ description: "The version of the microfrontends config schema."
1180
1205
  },
1181
1206
  applications: {
1182
1207
  $ref: "#/definitions/ApplicationRouting",
1183
- 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"
1208
+ description: "Mapping of Vercel project names to their microfrontend configurations."
1209
+ },
1210
+ options: {
1211
+ $ref: "#/definitions/Options",
1212
+ description: "Optional configuration options for the microfrontend."
1184
1213
  }
1185
1214
  },
1186
1215
  required: [
1187
1216
  "applications"
1188
1217
  ],
1189
- additionalProperties: false
1190
- },
1191
- Options: {
1192
- type: "object",
1193
- properties: {
1194
- disableOverrides: {
1195
- type: "boolean",
1196
- 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."
1197
- },
1198
- localProxyPort: {
1199
- type: "number",
1200
- description: "The port number used by the local proxy server.\n\nThe default is `3024`."
1201
- }
1202
- },
1203
- additionalProperties: false
1218
+ additionalProperties: false,
1219
+ description: "The microfrontends configuration schema. See https://vercel.com/docs/microfrontends/configuration."
1204
1220
  },
1205
1221
  ApplicationRouting: {
1206
1222
  type: "object",
@@ -1208,8 +1224,9 @@ var schema_default = {
1208
1224
  $ref: "#/definitions/Application"
1209
1225
  },
1210
1226
  propertyNames: {
1211
- description: "The unique identifier for a Microfrontend Application.\n\nMust match the Vercel project name.\n\nNote: If this name does not also match the name used to run the application, (e.g. the `name` from the `package.json`), then the `packageName` field should be set."
1212
- }
1227
+ description: "The Vercel project name of the microfrontend application.\n\nNote: If this name does not also match the name `name` from the `package.json`, set `packageName` with the name used in `package.json`.\n\nSee https://vercel.com/docs/microfrontends/configuration#application-naming."
1228
+ },
1229
+ description: "Mapping of Vercel project names to their microfrontend configurations."
1213
1230
  },
1214
1231
  Application: {
1215
1232
  anyOf: [
@@ -1219,14 +1236,15 @@ var schema_default = {
1219
1236
  {
1220
1237
  $ref: "#/definitions/ChildApplication"
1221
1238
  }
1222
- ]
1239
+ ],
1240
+ description: "The configuration for a microfrontend application. There must always be one default application."
1223
1241
  },
1224
1242
  DefaultApplication: {
1225
1243
  type: "object",
1226
1244
  properties: {
1227
1245
  packageName: {
1228
1246
  type: "string",
1229
- description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
1247
+ description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`.\n\nSee https://vercel.com/docs/microfrontends/configuration#application-naming."
1230
1248
  },
1231
1249
  development: {
1232
1250
  $ref: "#/definitions/DefaultDevelopment",
@@ -1246,15 +1264,15 @@ var schema_default = {
1246
1264
  "number",
1247
1265
  "string"
1248
1266
  ],
1249
- description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1267
+ description: "A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\n\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\n\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\n\nSee https://vercel.com/docs/microfrontends/local-development."
1250
1268
  },
1251
1269
  task: {
1252
1270
  type: "string",
1253
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1271
+ description: 'The task to run when starting the development server. Should reference a script in the package.json of the application.\n\nThe default value is "dev".\n\nSee https://vercel.com/docs/microfrontends/local-development.'
1254
1272
  },
1255
1273
  fallback: {
1256
1274
  type: "string",
1257
- description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1275
+ description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\n\nSee https://vercel.com/docs/microfrontends/local-development."
1258
1276
  }
1259
1277
  },
1260
1278
  required: [
@@ -1267,7 +1285,7 @@ var schema_default = {
1267
1285
  properties: {
1268
1286
  packageName: {
1269
1287
  type: "string",
1270
- description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
1288
+ description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`.\n\nSee https://vercel.com/docs/microfrontends/configuration#application-naming."
1271
1289
  },
1272
1290
  development: {
1273
1291
  $ref: "#/definitions/ChildDevelopment",
@@ -1275,11 +1293,11 @@ var schema_default = {
1275
1293
  },
1276
1294
  routing: {
1277
1295
  $ref: "#/definitions/Routing",
1278
- description: "Groups of path expressions that are routed to this application."
1296
+ description: "Groups of path expressions that are routed to this application.\n\nSee https://vercel.com/docs/microfrontends/path-routing."
1279
1297
  },
1280
1298
  assetPrefix: {
1281
1299
  type: "string",
1282
- description: "The name of the asset prefix to use instead of the auto-generated name.\n\nThe asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain.\n\nAn auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided.\n\nWhen this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field."
1300
+ description: "The name of the asset prefix to use instead of the auto-generated name.\n\nThe asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain.\n\nAn auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided.\n\nWhen this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field.\n\nThe default value is the auto-generated asset prefix of the form `vc-ap-<hash>`.\n\nSee https://vercel.com/docs/microfrontends/path-routing#asset-prefix."
1283
1301
  }
1284
1302
  },
1285
1303
  required: [
@@ -1295,15 +1313,15 @@ var schema_default = {
1295
1313
  "number",
1296
1314
  "string"
1297
1315
  ],
1298
- description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1316
+ description: "A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\n\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\n\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\n\nSee https://vercel.com/docs/microfrontends/local-development."
1299
1317
  },
1300
1318
  task: {
1301
1319
  type: "string",
1302
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
1320
+ description: 'The task to run when starting the development server. Should reference a script in the package.json of the application.\n\nThe default value is "dev".\n\nSee https://vercel.com/docs/microfrontends/local-development.'
1303
1321
  },
1304
1322
  fallback: {
1305
1323
  type: "string",
1306
- description: "Fallback for local development, could point to any environment. This is optional for child apps. If not provided, the fallback of the default app will be used.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1324
+ description: "Fallback for local development, could point to any environment. If not provided for child apps, the fallback of the default app will be used.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\n\nSee https://vercel.com/docs/microfrontends/local-development."
1307
1325
  }
1308
1326
  },
1309
1327
  additionalProperties: false
@@ -1312,29 +1330,46 @@ var schema_default = {
1312
1330
  type: "array",
1313
1331
  items: {
1314
1332
  $ref: "#/definitions/PathGroup"
1315
- }
1333
+ },
1334
+ description: "A list of path groups that are routed to this application."
1316
1335
  },
1317
1336
  PathGroup: {
1318
1337
  type: "object",
1319
1338
  properties: {
1320
1339
  group: {
1321
1340
  type: "string",
1322
- description: "Optional group name for the paths"
1341
+ description: "Group name for the paths."
1323
1342
  },
1324
1343
  flag: {
1325
1344
  type: "string",
1326
- description: "flag name that can be used to enable/disable all paths in the group"
1345
+ description: "The name of the feature flag that controls routing for this group of paths. See https://vercel.com/docs/microfrontends/path-routing#routing-changes-safely-with-flags."
1327
1346
  },
1328
1347
  paths: {
1329
1348
  type: "array",
1330
1349
  items: {
1331
1350
  type: "string"
1332
- }
1351
+ },
1352
+ description: "A list of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions."
1333
1353
  }
1334
1354
  },
1335
1355
  required: [
1336
1356
  "paths"
1337
1357
  ],
1358
+ additionalProperties: false,
1359
+ description: "A group of paths that is routed to this application."
1360
+ },
1361
+ Options: {
1362
+ type: "object",
1363
+ properties: {
1364
+ disableOverrides: {
1365
+ type: "boolean",
1366
+ 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.\n\nSee https://vercel.com/docs/microfrontends/managing-microfrontends/vercel-toolbar#routing-overrides."
1367
+ },
1368
+ localProxyPort: {
1369
+ type: "number",
1370
+ description: "The port number used by the local proxy server.\n\nThe default value is 3024.\n\nSee https://vercel.com/docs/microfrontends/local-development."
1371
+ }
1372
+ },
1338
1373
  additionalProperties: false
1339
1374
  }
1340
1375
  }
@@ -1353,19 +1388,19 @@ function formatAjvErrors(errors) {
1353
1388
  return [];
1354
1389
  }
1355
1390
  const errorMessages = [];
1356
- for (const error of errors) {
1357
- if (error.instancePath === "" && (error.keyword === "anyOf" || error.keyword === "required" && error.params.missingProperty === "partOf")) {
1391
+ for (const error2 of errors) {
1392
+ if (error2.instancePath === "" && (error2.keyword === "anyOf" || error2.keyword === "required" && error2.params.missingProperty === "partOf")) {
1358
1393
  continue;
1359
1394
  }
1360
- const instancePath = error.instancePath.slice(1);
1395
+ const instancePath = error2.instancePath.slice(1);
1361
1396
  const formattedInstancePath = instancePath === "" ? "at the root" : `in field ${instancePath}`;
1362
- if (error.keyword === "required" && error.params.missingProperty === "routing" && instancePath.split("/").length === 2) {
1397
+ if (error2.keyword === "required" && error2.params.missingProperty === "routing" && instancePath.split("/").length === 2) {
1363
1398
  errorMessages.push(
1364
1399
  `Unable to infer if ${instancePath} is the default app or a child app. This usually means that there is another error in the configuration.`
1365
1400
  );
1366
- } else if (error.keyword === "anyOf" && instancePath.split("/").length > 2) {
1401
+ } else if (error2.keyword === "anyOf" && instancePath.split("/").length > 2) {
1367
1402
  const anyOfErrors = errors.filter(
1368
- (e) => e.instancePath === error.instancePath && e.keyword !== "anyOf"
1403
+ (e) => e.instancePath === error2.instancePath && e.keyword !== "anyOf"
1369
1404
  );
1370
1405
  if (anyOfErrors.every((e) => e.keyword === "type")) {
1371
1406
  const allowedTypes = LIST_FORMATTER2.format(
@@ -1381,13 +1416,13 @@ function formatAjvErrors(errors) {
1381
1416
  `Invalid field for ${instancePath}. Possible error messages are ${LIST_FORMATTER2.format(anyOfErrors.map((e) => e.message ?? ""))}`
1382
1417
  );
1383
1418
  }
1384
- } else if (error.keyword === "additionalProperties" && !(error.params.additionalProperty === "routing" && instancePath.split("/").length === 2)) {
1419
+ } else if (error2.keyword === "additionalProperties" && !(error2.params.additionalProperty === "routing" && instancePath.split("/").length === 2)) {
1385
1420
  errorMessages.push(
1386
- `Property '${error.params.additionalProperty}' is not allowed ${formattedInstancePath}`
1421
+ `Property '${error2.params.additionalProperty}' is not allowed ${formattedInstancePath}`
1387
1422
  );
1388
- } else if (error.keyword === "required") {
1423
+ } else if (error2.keyword === "required") {
1389
1424
  errorMessages.push(
1390
- `Property '${error.params.missingProperty}' is required ${formattedInstancePath}`
1425
+ `Property '${error2.params.missingProperty}' is required ${formattedInstancePath}`
1391
1426
  );
1392
1427
  }
1393
1428
  }
@@ -1400,8 +1435,8 @@ function validateSchema(configString) {
1400
1435
  const isValid = validate(parsedConfig);
1401
1436
  if (!isValid) {
1402
1437
  throw new MicrofrontendError(
1403
- `Invalid microfrontends config:${formatAjvErrors(validate.errors).map((error) => `
1404
- - ${error}`).join(
1438
+ `Invalid microfrontends config:${formatAjvErrors(validate.errors).map((error2) => `
1439
+ - ${error2}`).join(
1405
1440
  ""
1406
1441
  )}
1407
1442
 
@@ -1686,17 +1721,10 @@ function transform3(args) {
1686
1721
  };
1687
1722
  }
1688
1723
 
1689
- // src/next/utils/route-to-local-proxy.ts
1690
- function routeToLocalProxy() {
1691
- const isDevEnv = (process.env.VERCEL_ENV ?? "development") === "development";
1692
- return isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY);
1693
- }
1694
-
1695
1724
  // src/next/config/transforms/redirects.ts
1696
1725
  function transform4(args) {
1697
- const { next, microfrontend, opts } = args;
1698
- const isProduction2 = opts?.isProduction ?? false;
1699
- const requireLocalProxyHeader = routeToLocalProxy() && !isProduction2 && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
1726
+ const { next, microfrontend } = args;
1727
+ const requireLocalProxyHeader = localProxyIsRunning() && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
1700
1728
  if (requireLocalProxyHeader) {
1701
1729
  const proxyRedirects = [
1702
1730
  {
@@ -1723,17 +1751,15 @@ function transform4(args) {
1723
1751
  } else {
1724
1752
  next.redirects = async () => proxyRedirects;
1725
1753
  }
1726
- if (process.env.MFE_DEBUG) {
1727
- const indent = " ".repeat(4);
1728
- const header = "redirects";
1729
- const separator = "\u23AF".repeat(header.length);
1730
- console.log(
1731
- `${indent}${header}
1754
+ const indent = " ".repeat(4);
1755
+ const header = "redirects";
1756
+ const separator = "\u23AF".repeat(header.length);
1757
+ logger.debug(
1758
+ `${indent}${header}
1732
1759
  ${indent}${separator}
1733
1760
  ${indent} - Automatically redirecting all requests to local microfrontends proxy
1734
1761
  `
1735
- );
1736
- }
1762
+ );
1737
1763
  }
1738
1764
  return { next };
1739
1765
  }
@@ -1754,22 +1780,18 @@ function transform5(args) {
1754
1780
 
1755
1781
  // src/next/config/transforms/rewrites.ts
1756
1782
  function debugRewrites(rewrites) {
1757
- if (process.env.MFE_DEBUG) {
1758
- const indent = " ".repeat(4);
1759
- const header = "rewrites (source \u2192 destination)";
1760
- const separator = "\u23AF".repeat(header.length);
1761
- const maxSourceLength = Math.max(
1762
- ...rewrites.map((key) => key.source.length)
1763
- );
1764
- const table = rewrites.map((route, idx) => {
1765
- const paddedSource = route.source.padEnd(maxSourceLength);
1766
- return `${indent} ${idx + 1}. ${paddedSource} \u2192 ${route.destination}`;
1767
- }).join("\n");
1768
- console.log(`${indent}${header}
1783
+ const indent = " ".repeat(4);
1784
+ const header = "rewrites (source \u2192 destination)";
1785
+ const separator = "\u23AF".repeat(header.length);
1786
+ const maxSourceLength = Math.max(...rewrites.map((key) => key.source.length));
1787
+ const table = rewrites.map((route, idx) => {
1788
+ const paddedSource = route.source.padEnd(maxSourceLength);
1789
+ return `${indent} ${idx + 1}. ${paddedSource} \u2192 ${route.destination}`;
1790
+ }).join("\n");
1791
+ logger.debug(`${indent}${header}
1769
1792
  ${indent}${separator}
1770
1793
  ${table}
1771
1794
  `);
1772
- }
1773
1795
  }
1774
1796
  function rewritesMapToArr(rewrites) {
1775
1797
  return Array.from(rewrites.entries()).flatMap(([source, rewrite]) => {
@@ -1968,20 +1990,18 @@ var transforms = {
1968
1990
 
1969
1991
  // src/next/config/env.ts
1970
1992
  function debugEnv(env) {
1971
- if (process.env.MFE_DEBUG) {
1972
- const indent = " ".repeat(4);
1973
- const header = "env (key \u2192 val)";
1974
- const separator = "\u23AF".repeat(header.length);
1975
- const maxKeyLength = Math.max(...Object.keys(env).map((key) => key.length));
1976
- const table = Object.keys(env).map((key, idx) => {
1977
- const paddedKey = key.padEnd(maxKeyLength);
1978
- return `${indent} ${idx + 1}. ${paddedKey} = ${env[key]}`;
1979
- }).join("\n");
1980
- console.log(`${indent}${header}
1993
+ const indent = " ".repeat(4);
1994
+ const header = "env (key \u2192 val)";
1995
+ const separator = "\u23AF".repeat(header.length);
1996
+ const maxKeyLength = Math.max(...Object.keys(env).map((key) => key.length));
1997
+ const table = Object.keys(env).map((key, idx) => {
1998
+ const paddedKey = key.padEnd(maxKeyLength);
1999
+ return `${indent} ${idx + 1}. ${paddedKey} = ${env[key]}`;
2000
+ }).join("\n");
2001
+ logger.debug(`${indent}${header}
1981
2002
  ${indent}${separator}
1982
2003
  ${table}
1983
2004
  `);
1984
- }
1985
2005
  }
1986
2006
  function setEnvironment({
1987
2007
  app,
@@ -2017,12 +2037,6 @@ function setEnvironment({
2017
2037
  function typedEntries(obj) {
2018
2038
  return Object.entries(obj);
2019
2039
  }
2020
- function isProduction(opts) {
2021
- if (opts?.isProduction) {
2022
- return opts.isProduction();
2023
- }
2024
- return process.env.VERCEL_ENV === "production";
2025
- }
2026
2040
  function withMicrofrontends(nextConfig, opts) {
2027
2041
  if (opts?.debug) {
2028
2042
  process.env.MFE_DEBUG = "true";
@@ -2037,7 +2051,7 @@ function withMicrofrontends(nextConfig, opts) {
2037
2051
  let next = { ...nextConfig };
2038
2052
  for (const [key, transform8] of typedEntries(transforms)) {
2039
2053
  if (opts?.skipTransforms?.includes(key)) {
2040
- console.log(`Skipping ${key} transform`);
2054
+ logger.info(`Skipping ${key} transform`);
2041
2055
  continue;
2042
2056
  }
2043
2057
  try {
@@ -2046,13 +2060,12 @@ function withMicrofrontends(nextConfig, opts) {
2046
2060
  next,
2047
2061
  microfrontend: microfrontends.config,
2048
2062
  opts: {
2049
- isProduction: isProduction(opts),
2050
2063
  supportPagesRouter: opts?.supportPagesRouter
2051
2064
  }
2052
2065
  });
2053
2066
  next = transformedConfig.next;
2054
2067
  } catch (e) {
2055
- console.error("Error transforming next config", e);
2068
+ logger.error("Error transforming next config", e);
2056
2069
  throw e;
2057
2070
  }
2058
2071
  }