@vercel/microfrontends 2.1.3 → 2.2.1
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.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -0
- package/dist/bin/cli.cjs +207 -90
- package/dist/config.d.ts +2 -2
- package/dist/experimental/sveltekit.cjs +180 -63
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.d.ts +6 -0
- package/dist/experimental/sveltekit.js +180 -63
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +177 -66
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +177 -66
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +173 -60
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +2 -2
- package/dist/microfrontends/server.js +173 -60
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends/utils.cjs +50 -7
- package/dist/microfrontends/utils.cjs.map +1 -1
- package/dist/microfrontends/utils.d.ts +1 -1
- package/dist/microfrontends/utils.js +50 -7
- package/dist/microfrontends/utils.js.map +1 -1
- package/dist/next/config.cjs +208 -113
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +11 -1
- package/dist/next/config.js +208 -113
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +35 -17
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +35 -17
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.d.ts +2 -2
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.d.ts +2 -2
- package/dist/{types-88602303.d.ts → types-b9ea41b2.d.ts} +1 -1
- package/dist/{types-e7523e61.d.ts → types-dcd8b17a.d.ts} +71 -24
- package/dist/utils/mfe-port.cjs +173 -60
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +173 -60
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +47 -38
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +47 -38
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/schema/schema.json +47 -38
package/dist/utils/mfe-port.cjs
CHANGED
|
@@ -225,10 +225,32 @@ var import_node_fs2 = require("fs");
|
|
|
225
225
|
var import_jsonc_parser = require("jsonc-parser");
|
|
226
226
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
227
227
|
|
|
228
|
+
// src/bin/logger.ts
|
|
229
|
+
function debug(...args) {
|
|
230
|
+
if (process.env.MFE_DEBUG) {
|
|
231
|
+
console.log(...args);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function info(...args) {
|
|
235
|
+
console.log(...args);
|
|
236
|
+
}
|
|
237
|
+
function warn(...args) {
|
|
238
|
+
console.warn(...args);
|
|
239
|
+
}
|
|
240
|
+
function error(...args) {
|
|
241
|
+
console.error(...args);
|
|
242
|
+
}
|
|
243
|
+
var logger = {
|
|
244
|
+
debug,
|
|
245
|
+
info,
|
|
246
|
+
warn,
|
|
247
|
+
error
|
|
248
|
+
};
|
|
249
|
+
|
|
228
250
|
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
229
251
|
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
230
|
-
"microfrontends.
|
|
231
|
-
"microfrontends.
|
|
252
|
+
"microfrontends.json",
|
|
253
|
+
"microfrontends.jsonc"
|
|
232
254
|
];
|
|
233
255
|
function getPossibleConfigurationFilenames({
|
|
234
256
|
customConfigFilename
|
|
@@ -236,7 +258,7 @@ function getPossibleConfigurationFilenames({
|
|
|
236
258
|
if (customConfigFilename) {
|
|
237
259
|
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
238
260
|
throw new Error(
|
|
239
|
-
`
|
|
261
|
+
`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.`
|
|
240
262
|
);
|
|
241
263
|
}
|
|
242
264
|
return Array.from(
|
|
@@ -254,6 +276,10 @@ function findPackageWithMicrofrontendsConfig({
|
|
|
254
276
|
customConfigFilename
|
|
255
277
|
}) {
|
|
256
278
|
const applicationName = applicationContext.name;
|
|
279
|
+
logger.debug(
|
|
280
|
+
"[MFE Config] Searching repository for configs containing application:",
|
|
281
|
+
applicationName
|
|
282
|
+
);
|
|
257
283
|
try {
|
|
258
284
|
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
259
285
|
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
@@ -265,6 +291,11 @@ function findPackageWithMicrofrontendsConfig({
|
|
|
265
291
|
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
266
292
|
}
|
|
267
293
|
);
|
|
294
|
+
logger.debug(
|
|
295
|
+
"[MFE Config] Found",
|
|
296
|
+
microfrontendsJsonPaths.length,
|
|
297
|
+
"config file(s) in repository"
|
|
298
|
+
);
|
|
268
299
|
const matchingPaths = [];
|
|
269
300
|
for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
|
|
270
301
|
try {
|
|
@@ -274,19 +305,31 @@ function findPackageWithMicrofrontendsConfig({
|
|
|
274
305
|
);
|
|
275
306
|
const microfrontendsJson = (0, import_jsonc_parser.parse)(microfrontendsJsonContent);
|
|
276
307
|
if (microfrontendsJson.applications[applicationName]) {
|
|
308
|
+
logger.debug(
|
|
309
|
+
"[MFE Config] Found application in config:",
|
|
310
|
+
microfrontendsJsonPath
|
|
311
|
+
);
|
|
277
312
|
matchingPaths.push(microfrontendsJsonPath);
|
|
278
313
|
} else {
|
|
279
314
|
for (const [_, app] of Object.entries(
|
|
280
315
|
microfrontendsJson.applications
|
|
281
316
|
)) {
|
|
282
317
|
if (app.packageName === applicationName) {
|
|
318
|
+
logger.debug(
|
|
319
|
+
"[MFE Config] Found application via packageName in config:",
|
|
320
|
+
microfrontendsJsonPath
|
|
321
|
+
);
|
|
283
322
|
matchingPaths.push(microfrontendsJsonPath);
|
|
284
323
|
}
|
|
285
324
|
}
|
|
286
325
|
}
|
|
287
|
-
} catch (
|
|
326
|
+
} catch (error2) {
|
|
288
327
|
}
|
|
289
328
|
}
|
|
329
|
+
logger.debug(
|
|
330
|
+
"[MFE Config] Total matching config files:",
|
|
331
|
+
matchingPaths.length
|
|
332
|
+
);
|
|
290
333
|
if (matchingPaths.length > 1) {
|
|
291
334
|
throw new MicrofrontendError(
|
|
292
335
|
`Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
|
|
@@ -320,9 +363,9 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
320
363
|
}
|
|
321
364
|
const [packageJsonPath] = matchingPaths;
|
|
322
365
|
return (0, import_node_path2.dirname)(packageJsonPath);
|
|
323
|
-
} catch (
|
|
324
|
-
if (
|
|
325
|
-
throw
|
|
366
|
+
} catch (error2) {
|
|
367
|
+
if (error2 instanceof MicrofrontendError) {
|
|
368
|
+
throw error2;
|
|
326
369
|
}
|
|
327
370
|
return null;
|
|
328
371
|
}
|
|
@@ -367,8 +410,8 @@ function isMonorepo({
|
|
|
367
410
|
import_node_fs3.default.readFileSync(packageJsonPath, "utf-8")
|
|
368
411
|
);
|
|
369
412
|
return packageJson.workspaces !== void 0;
|
|
370
|
-
} catch (
|
|
371
|
-
|
|
413
|
+
} catch (error2) {
|
|
414
|
+
logger.error("Error determining if repository is a monorepo", error2);
|
|
372
415
|
return false;
|
|
373
416
|
}
|
|
374
417
|
}
|
|
@@ -1085,15 +1128,18 @@ var import_node_fs6 = __toESM(require("fs"), 1);
|
|
|
1085
1128
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
1086
1129
|
function getApplicationContext(opts) {
|
|
1087
1130
|
if (opts?.appName) {
|
|
1131
|
+
logger.debug("[MFE Config] Application name from appName parameter:", opts.appName);
|
|
1088
1132
|
return { name: opts.appName };
|
|
1089
1133
|
}
|
|
1090
1134
|
if (process.env.VERCEL_PROJECT_NAME) {
|
|
1135
|
+
logger.debug("[MFE Config] Application name from VERCEL_PROJECT_NAME:", process.env.VERCEL_PROJECT_NAME);
|
|
1091
1136
|
return {
|
|
1092
1137
|
name: process.env.VERCEL_PROJECT_NAME,
|
|
1093
1138
|
projectName: process.env.VERCEL_PROJECT_NAME
|
|
1094
1139
|
};
|
|
1095
1140
|
}
|
|
1096
1141
|
if (process.env.NX_TASK_TARGET_PROJECT) {
|
|
1142
|
+
logger.debug("[MFE Config] Application name from NX_TASK_TARGET_PROJECT:", process.env.NX_TASK_TARGET_PROJECT);
|
|
1097
1143
|
return {
|
|
1098
1144
|
name: process.env.NX_TASK_TARGET_PROJECT,
|
|
1099
1145
|
packageJsonName: process.env.NX_TASK_TARGET_PROJECT
|
|
@@ -1106,6 +1152,7 @@ function getApplicationContext(opts) {
|
|
|
1106
1152
|
);
|
|
1107
1153
|
const projectJson = JSON.parse(vercelProjectJsonPath);
|
|
1108
1154
|
if (projectJson.projectName) {
|
|
1155
|
+
logger.debug("[MFE Config] Application name from .vercel/project.json:", projectJson.projectName);
|
|
1109
1156
|
return {
|
|
1110
1157
|
name: projectJson.projectName,
|
|
1111
1158
|
projectName: projectJson.projectName
|
|
@@ -1129,6 +1176,7 @@ function getApplicationContext(opts) {
|
|
|
1129
1176
|
}
|
|
1130
1177
|
);
|
|
1131
1178
|
}
|
|
1179
|
+
logger.debug("[MFE Config] Application name from package.json:", packageJson.name);
|
|
1132
1180
|
return { name: packageJson.name, packageJsonName: packageJson.name };
|
|
1133
1181
|
} catch (err) {
|
|
1134
1182
|
throw MicrofrontendError.handle(err, {
|
|
@@ -1162,38 +1210,28 @@ var schema_default = {
|
|
|
1162
1210
|
type: "object",
|
|
1163
1211
|
properties: {
|
|
1164
1212
|
$schema: {
|
|
1165
|
-
type: "string"
|
|
1213
|
+
type: "string",
|
|
1214
|
+
description: "See https://openapi.vercel.sh/microfrontends.json."
|
|
1166
1215
|
},
|
|
1167
1216
|
version: {
|
|
1168
1217
|
type: "string",
|
|
1169
|
-
const: "1"
|
|
1170
|
-
|
|
1171
|
-
options: {
|
|
1172
|
-
$ref: "#/definitions/Options"
|
|
1218
|
+
const: "1",
|
|
1219
|
+
description: "The version of the microfrontends config schema."
|
|
1173
1220
|
},
|
|
1174
1221
|
applications: {
|
|
1175
1222
|
$ref: "#/definitions/ApplicationRouting",
|
|
1176
|
-
description: "Mapping of
|
|
1223
|
+
description: "Mapping of Vercel project names to their microfrontend configurations."
|
|
1224
|
+
},
|
|
1225
|
+
options: {
|
|
1226
|
+
$ref: "#/definitions/Options",
|
|
1227
|
+
description: "Optional configuration options for the microfrontend."
|
|
1177
1228
|
}
|
|
1178
1229
|
},
|
|
1179
1230
|
required: [
|
|
1180
1231
|
"applications"
|
|
1181
1232
|
],
|
|
1182
|
-
additionalProperties: false
|
|
1183
|
-
|
|
1184
|
-
Options: {
|
|
1185
|
-
type: "object",
|
|
1186
|
-
properties: {
|
|
1187
|
-
disableOverrides: {
|
|
1188
|
-
type: "boolean",
|
|
1189
|
-
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."
|
|
1190
|
-
},
|
|
1191
|
-
localProxyPort: {
|
|
1192
|
-
type: "number",
|
|
1193
|
-
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
1194
|
-
}
|
|
1195
|
-
},
|
|
1196
|
-
additionalProperties: false
|
|
1233
|
+
additionalProperties: false,
|
|
1234
|
+
description: "The microfrontends configuration schema. See https://vercel.com/docs/microfrontends/configuration."
|
|
1197
1235
|
},
|
|
1198
1236
|
ApplicationRouting: {
|
|
1199
1237
|
type: "object",
|
|
@@ -1201,8 +1239,9 @@ var schema_default = {
|
|
|
1201
1239
|
$ref: "#/definitions/Application"
|
|
1202
1240
|
},
|
|
1203
1241
|
propertyNames: {
|
|
1204
|
-
description: "The
|
|
1205
|
-
}
|
|
1242
|
+
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."
|
|
1243
|
+
},
|
|
1244
|
+
description: "Mapping of Vercel project names to their microfrontend configurations."
|
|
1206
1245
|
},
|
|
1207
1246
|
Application: {
|
|
1208
1247
|
anyOf: [
|
|
@@ -1212,14 +1251,15 @@ var schema_default = {
|
|
|
1212
1251
|
{
|
|
1213
1252
|
$ref: "#/definitions/ChildApplication"
|
|
1214
1253
|
}
|
|
1215
|
-
]
|
|
1254
|
+
],
|
|
1255
|
+
description: "The configuration for a microfrontend application. There must always be one default application."
|
|
1216
1256
|
},
|
|
1217
1257
|
DefaultApplication: {
|
|
1218
1258
|
type: "object",
|
|
1219
1259
|
properties: {
|
|
1220
1260
|
packageName: {
|
|
1221
1261
|
type: "string",
|
|
1222
|
-
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
|
|
1262
|
+
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."
|
|
1223
1263
|
},
|
|
1224
1264
|
development: {
|
|
1225
1265
|
$ref: "#/definitions/DefaultDevelopment",
|
|
@@ -1239,15 +1279,15 @@ var schema_default = {
|
|
|
1239
1279
|
"number",
|
|
1240
1280
|
"string"
|
|
1241
1281
|
],
|
|
1242
|
-
description: "A local port number or host
|
|
1282
|
+
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."
|
|
1243
1283
|
},
|
|
1244
1284
|
task: {
|
|
1245
1285
|
type: "string",
|
|
1246
|
-
description:
|
|
1286
|
+
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.'
|
|
1247
1287
|
},
|
|
1248
1288
|
fallback: {
|
|
1249
1289
|
type: "string",
|
|
1250
|
-
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."
|
|
1290
|
+
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."
|
|
1251
1291
|
}
|
|
1252
1292
|
},
|
|
1253
1293
|
required: [
|
|
@@ -1260,7 +1300,7 @@ var schema_default = {
|
|
|
1260
1300
|
properties: {
|
|
1261
1301
|
packageName: {
|
|
1262
1302
|
type: "string",
|
|
1263
|
-
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
|
|
1303
|
+
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."
|
|
1264
1304
|
},
|
|
1265
1305
|
development: {
|
|
1266
1306
|
$ref: "#/definitions/ChildDevelopment",
|
|
@@ -1268,11 +1308,11 @@ var schema_default = {
|
|
|
1268
1308
|
},
|
|
1269
1309
|
routing: {
|
|
1270
1310
|
$ref: "#/definitions/Routing",
|
|
1271
|
-
description: "Groups of path expressions that are routed to this application."
|
|
1311
|
+
description: "Groups of path expressions that are routed to this application.\n\nSee https://vercel.com/docs/microfrontends/path-routing."
|
|
1272
1312
|
},
|
|
1273
1313
|
assetPrefix: {
|
|
1274
1314
|
type: "string",
|
|
1275
|
-
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."
|
|
1315
|
+
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."
|
|
1276
1316
|
}
|
|
1277
1317
|
},
|
|
1278
1318
|
required: [
|
|
@@ -1288,15 +1328,15 @@ var schema_default = {
|
|
|
1288
1328
|
"number",
|
|
1289
1329
|
"string"
|
|
1290
1330
|
],
|
|
1291
|
-
description: "A local port number or host
|
|
1331
|
+
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."
|
|
1292
1332
|
},
|
|
1293
1333
|
task: {
|
|
1294
1334
|
type: "string",
|
|
1295
|
-
description:
|
|
1335
|
+
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.'
|
|
1296
1336
|
},
|
|
1297
1337
|
fallback: {
|
|
1298
1338
|
type: "string",
|
|
1299
|
-
description: "Fallback for local development, could point to any environment.
|
|
1339
|
+
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."
|
|
1300
1340
|
}
|
|
1301
1341
|
},
|
|
1302
1342
|
additionalProperties: false
|
|
@@ -1305,29 +1345,46 @@ var schema_default = {
|
|
|
1305
1345
|
type: "array",
|
|
1306
1346
|
items: {
|
|
1307
1347
|
$ref: "#/definitions/PathGroup"
|
|
1308
|
-
}
|
|
1348
|
+
},
|
|
1349
|
+
description: "A list of path groups that are routed to this application."
|
|
1309
1350
|
},
|
|
1310
1351
|
PathGroup: {
|
|
1311
1352
|
type: "object",
|
|
1312
1353
|
properties: {
|
|
1313
1354
|
group: {
|
|
1314
1355
|
type: "string",
|
|
1315
|
-
description: "
|
|
1356
|
+
description: "Group name for the paths."
|
|
1316
1357
|
},
|
|
1317
1358
|
flag: {
|
|
1318
1359
|
type: "string",
|
|
1319
|
-
description: "
|
|
1360
|
+
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."
|
|
1320
1361
|
},
|
|
1321
1362
|
paths: {
|
|
1322
1363
|
type: "array",
|
|
1323
1364
|
items: {
|
|
1324
1365
|
type: "string"
|
|
1325
|
-
}
|
|
1366
|
+
},
|
|
1367
|
+
description: "A list of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions."
|
|
1326
1368
|
}
|
|
1327
1369
|
},
|
|
1328
1370
|
required: [
|
|
1329
1371
|
"paths"
|
|
1330
1372
|
],
|
|
1373
|
+
additionalProperties: false,
|
|
1374
|
+
description: "A group of paths that is routed to this application."
|
|
1375
|
+
},
|
|
1376
|
+
Options: {
|
|
1377
|
+
type: "object",
|
|
1378
|
+
properties: {
|
|
1379
|
+
disableOverrides: {
|
|
1380
|
+
type: "boolean",
|
|
1381
|
+
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."
|
|
1382
|
+
},
|
|
1383
|
+
localProxyPort: {
|
|
1384
|
+
type: "number",
|
|
1385
|
+
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."
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1331
1388
|
additionalProperties: false
|
|
1332
1389
|
}
|
|
1333
1390
|
}
|
|
@@ -1346,19 +1403,19 @@ function formatAjvErrors(errors) {
|
|
|
1346
1403
|
return [];
|
|
1347
1404
|
}
|
|
1348
1405
|
const errorMessages = [];
|
|
1349
|
-
for (const
|
|
1350
|
-
if (
|
|
1406
|
+
for (const error2 of errors) {
|
|
1407
|
+
if (error2.instancePath === "" && (error2.keyword === "anyOf" || error2.keyword === "required" && error2.params.missingProperty === "partOf")) {
|
|
1351
1408
|
continue;
|
|
1352
1409
|
}
|
|
1353
|
-
const instancePath =
|
|
1410
|
+
const instancePath = error2.instancePath.slice(1);
|
|
1354
1411
|
const formattedInstancePath = instancePath === "" ? "at the root" : `in field ${instancePath}`;
|
|
1355
|
-
if (
|
|
1412
|
+
if (error2.keyword === "required" && error2.params.missingProperty === "routing" && instancePath.split("/").length === 2) {
|
|
1356
1413
|
errorMessages.push(
|
|
1357
1414
|
`Unable to infer if ${instancePath} is the default app or a child app. This usually means that there is another error in the configuration.`
|
|
1358
1415
|
);
|
|
1359
|
-
} else if (
|
|
1416
|
+
} else if (error2.keyword === "anyOf" && instancePath.split("/").length > 2) {
|
|
1360
1417
|
const anyOfErrors = errors.filter(
|
|
1361
|
-
(e) => e.instancePath ===
|
|
1418
|
+
(e) => e.instancePath === error2.instancePath && e.keyword !== "anyOf"
|
|
1362
1419
|
);
|
|
1363
1420
|
if (anyOfErrors.every((e) => e.keyword === "type")) {
|
|
1364
1421
|
const allowedTypes = LIST_FORMATTER2.format(
|
|
@@ -1374,13 +1431,13 @@ function formatAjvErrors(errors) {
|
|
|
1374
1431
|
`Invalid field for ${instancePath}. Possible error messages are ${LIST_FORMATTER2.format(anyOfErrors.map((e) => e.message ?? ""))}`
|
|
1375
1432
|
);
|
|
1376
1433
|
}
|
|
1377
|
-
} else if (
|
|
1434
|
+
} else if (error2.keyword === "additionalProperties" && !(error2.params.additionalProperty === "routing" && instancePath.split("/").length === 2)) {
|
|
1378
1435
|
errorMessages.push(
|
|
1379
|
-
`Property '${
|
|
1436
|
+
`Property '${error2.params.additionalProperty}' is not allowed ${formattedInstancePath}`
|
|
1380
1437
|
);
|
|
1381
|
-
} else if (
|
|
1438
|
+
} else if (error2.keyword === "required") {
|
|
1382
1439
|
errorMessages.push(
|
|
1383
|
-
`Property '${
|
|
1440
|
+
`Property '${error2.params.missingProperty}' is required ${formattedInstancePath}`
|
|
1384
1441
|
);
|
|
1385
1442
|
}
|
|
1386
1443
|
}
|
|
@@ -1393,8 +1450,8 @@ function validateSchema(configString) {
|
|
|
1393
1450
|
const isValid = validate(parsedConfig);
|
|
1394
1451
|
if (!isValid) {
|
|
1395
1452
|
throw new MicrofrontendError(
|
|
1396
|
-
`Invalid microfrontends config:${formatAjvErrors(validate.errors).map((
|
|
1397
|
-
- ${
|
|
1453
|
+
`Invalid microfrontends config:${formatAjvErrors(validate.errors).map((error2) => `
|
|
1454
|
+
- ${error2}`).join(
|
|
1398
1455
|
""
|
|
1399
1456
|
)}
|
|
1400
1457
|
|
|
@@ -1491,7 +1548,13 @@ var MicrofrontendsServer = class {
|
|
|
1491
1548
|
filePath,
|
|
1492
1549
|
cookies
|
|
1493
1550
|
} = {}) {
|
|
1551
|
+
logger.debug("[MFE Config] Starting config inference", {
|
|
1552
|
+
appName,
|
|
1553
|
+
directory: directory || process.cwd(),
|
|
1554
|
+
filePath
|
|
1555
|
+
});
|
|
1494
1556
|
if (filePath) {
|
|
1557
|
+
logger.debug("[MFE Config] Using explicit filePath:", filePath);
|
|
1495
1558
|
return MicrofrontendsServer.fromFile({
|
|
1496
1559
|
filePath,
|
|
1497
1560
|
cookies
|
|
@@ -1499,16 +1562,25 @@ var MicrofrontendsServer = class {
|
|
|
1499
1562
|
}
|
|
1500
1563
|
try {
|
|
1501
1564
|
const packageRoot = findPackageRoot(directory);
|
|
1565
|
+
logger.debug("[MFE Config] Package root:", packageRoot);
|
|
1502
1566
|
const applicationContext = getApplicationContext({
|
|
1503
1567
|
appName,
|
|
1504
1568
|
packageRoot
|
|
1505
1569
|
});
|
|
1570
|
+
logger.debug("[MFE Config] Application context:", applicationContext);
|
|
1506
1571
|
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1572
|
+
if (customConfigFilename) {
|
|
1573
|
+
logger.debug(
|
|
1574
|
+
"[MFE Config] Custom config filename from VC_MICROFRONTENDS_CONFIG_FILE_NAME:",
|
|
1575
|
+
customConfigFilename
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
1507
1578
|
const maybeConfig = findConfig({
|
|
1508
1579
|
dir: packageRoot,
|
|
1509
1580
|
customConfigFilename
|
|
1510
1581
|
});
|
|
1511
1582
|
if (maybeConfig) {
|
|
1583
|
+
logger.debug("[MFE Config] Config found at package root:", maybeConfig);
|
|
1512
1584
|
return MicrofrontendsServer.fromFile({
|
|
1513
1585
|
filePath: maybeConfig,
|
|
1514
1586
|
cookies
|
|
@@ -1516,42 +1588,78 @@ var MicrofrontendsServer = class {
|
|
|
1516
1588
|
}
|
|
1517
1589
|
const repositoryRoot = findRepositoryRoot();
|
|
1518
1590
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1591
|
+
logger.debug(
|
|
1592
|
+
"[MFE Config] Repository root:",
|
|
1593
|
+
repositoryRoot,
|
|
1594
|
+
"Is monorepo:",
|
|
1595
|
+
isMonorepo2
|
|
1596
|
+
);
|
|
1519
1597
|
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1520
1598
|
if (typeof configFromEnv === "string") {
|
|
1599
|
+
logger.debug(
|
|
1600
|
+
"[MFE Config] Checking VC_MICROFRONTENDS_CONFIG:",
|
|
1601
|
+
configFromEnv
|
|
1602
|
+
);
|
|
1521
1603
|
const maybeConfigFromEnv = (0, import_node_path8.resolve)(packageRoot, configFromEnv);
|
|
1522
1604
|
if (maybeConfigFromEnv) {
|
|
1605
|
+
logger.debug(
|
|
1606
|
+
"[MFE Config] Config loaded from VC_MICROFRONTENDS_CONFIG:",
|
|
1607
|
+
maybeConfigFromEnv
|
|
1608
|
+
);
|
|
1523
1609
|
return MicrofrontendsServer.fromFile({
|
|
1524
1610
|
filePath: maybeConfigFromEnv,
|
|
1525
1611
|
cookies
|
|
1526
1612
|
});
|
|
1527
1613
|
}
|
|
1528
1614
|
} else {
|
|
1615
|
+
const vercelDir = (0, import_node_path8.join)(packageRoot, ".vercel");
|
|
1616
|
+
logger.debug(
|
|
1617
|
+
"[MFE Config] Searching for config in .vercel directory:",
|
|
1618
|
+
vercelDir
|
|
1619
|
+
);
|
|
1529
1620
|
const maybeConfigFromVercel = findConfig({
|
|
1530
|
-
dir:
|
|
1621
|
+
dir: vercelDir,
|
|
1531
1622
|
customConfigFilename
|
|
1532
1623
|
});
|
|
1533
1624
|
if (maybeConfigFromVercel) {
|
|
1625
|
+
logger.debug(
|
|
1626
|
+
"[MFE Config] Config found in .vercel directory:",
|
|
1627
|
+
maybeConfigFromVercel
|
|
1628
|
+
);
|
|
1534
1629
|
return MicrofrontendsServer.fromFile({
|
|
1535
1630
|
filePath: maybeConfigFromVercel,
|
|
1536
1631
|
cookies
|
|
1537
1632
|
});
|
|
1538
1633
|
}
|
|
1539
1634
|
if (isMonorepo2) {
|
|
1635
|
+
logger.debug(
|
|
1636
|
+
"[MFE Config] Inferring microfrontends location in monorepo for application:",
|
|
1637
|
+
applicationContext.name
|
|
1638
|
+
);
|
|
1540
1639
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1541
1640
|
repositoryRoot,
|
|
1542
1641
|
applicationContext,
|
|
1543
1642
|
customConfigFilename
|
|
1544
1643
|
});
|
|
1644
|
+
logger.debug(
|
|
1645
|
+
"[MFE Config] Inferred package location:",
|
|
1646
|
+
defaultPackage
|
|
1647
|
+
);
|
|
1545
1648
|
const maybeConfigFromDefault = findConfig({
|
|
1546
1649
|
dir: defaultPackage,
|
|
1547
1650
|
customConfigFilename
|
|
1548
1651
|
});
|
|
1549
1652
|
if (maybeConfigFromDefault) {
|
|
1653
|
+
logger.debug(
|
|
1654
|
+
"[MFE Config] Config found in inferred package:",
|
|
1655
|
+
maybeConfigFromDefault
|
|
1656
|
+
);
|
|
1550
1657
|
return MicrofrontendsServer.fromFile({
|
|
1551
1658
|
filePath: maybeConfigFromDefault,
|
|
1552
1659
|
cookies
|
|
1553
1660
|
});
|
|
1554
1661
|
}
|
|
1662
|
+
logger.debug("[MFE Config] No config found in inferred package");
|
|
1555
1663
|
}
|
|
1556
1664
|
}
|
|
1557
1665
|
throw new MicrofrontendError(
|
|
@@ -1577,8 +1685,13 @@ var MicrofrontendsServer = class {
|
|
|
1577
1685
|
cookies
|
|
1578
1686
|
}) {
|
|
1579
1687
|
try {
|
|
1688
|
+
logger.debug("[MFE Config] Reading config from file:", filePath);
|
|
1580
1689
|
const configJson = import_node_fs7.default.readFileSync(filePath, "utf-8");
|
|
1581
1690
|
const config = MicrofrontendsServer.validate(configJson);
|
|
1691
|
+
logger.debug(
|
|
1692
|
+
"[MFE Config] Config loaded with applications:",
|
|
1693
|
+
Object.keys(config.applications)
|
|
1694
|
+
);
|
|
1582
1695
|
return new MicrofrontendsServer({
|
|
1583
1696
|
config,
|
|
1584
1697
|
overrides: cookies ? parseOverrides(cookies) : void 0
|