@vercel/microfrontends 1.0.1-canary.5 → 1.1.1-canary.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.
- package/dist/bin/cli.cjs +128 -53
- package/dist/config.cjs +80 -16
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +80 -16
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +116 -49
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +116 -49
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +116 -49
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +116 -49
- package/dist/experimental/vite.js.map +1 -1
- package/dist/{index-2b59c627.d.ts → index-7e69650e.d.ts} +11 -5
- package/dist/microfrontends/server.cjs +116 -49
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +4 -4
- package/dist/microfrontends/server.js +116 -49
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends.cjs +80 -16
- package/dist/microfrontends.cjs.map +1 -1
- package/dist/microfrontends.d.ts +4 -4
- package/dist/microfrontends.js +80 -16
- package/dist/microfrontends.js.map +1 -1
- package/dist/next/config.cjs +133 -56
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +133 -56
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/middleware.cjs +90 -16
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +90 -16
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +84 -21
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +84 -21
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.cjs +23 -0
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +7 -1
- package/dist/schema.js +13 -0
- package/dist/schema.js.map +1 -1
- package/dist/{index-2f78c0ca.d.ts → types-6ee19ccc.d.ts} +40 -9
- package/dist/{types-b6d38aea.d.ts → types-73527280.d.ts} +1 -1
- package/dist/{types-4ef2bddb.d.ts → types-74e3336c.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +116 -49
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +116 -49
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +36 -33
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +36 -33
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/schema/schema.json +28 -7
|
@@ -287,10 +287,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
if (errors.length) {
|
|
290
|
-
throw new MicrofrontendError(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
throw new MicrofrontendError(
|
|
291
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
292
|
+
{
|
|
293
|
+
type: "config",
|
|
294
|
+
subtype: "conflicting_paths"
|
|
295
|
+
}
|
|
296
|
+
);
|
|
294
297
|
}
|
|
295
298
|
};
|
|
296
299
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -405,9 +408,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
405
408
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
406
409
|
);
|
|
407
410
|
}
|
|
408
|
-
if (application.development?.
|
|
411
|
+
if (application.development?.localPort) {
|
|
412
|
+
errors.push(
|
|
413
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
417
|
+
const fallback = application.development.fallback;
|
|
418
|
+
let asString = fallback.host;
|
|
419
|
+
if (fallback.protocol) {
|
|
420
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
421
|
+
}
|
|
422
|
+
if (fallback.port) {
|
|
423
|
+
asString = `${asString}:${fallback.port}`;
|
|
424
|
+
}
|
|
425
|
+
errors.push(
|
|
426
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
430
|
+
const local = application.development.local;
|
|
431
|
+
let asString;
|
|
432
|
+
if (local.port && !local.protocol && !local.host) {
|
|
433
|
+
asString = String(local.port);
|
|
434
|
+
} else {
|
|
435
|
+
asString = local.host ?? "localhost";
|
|
436
|
+
if (local.protocol) {
|
|
437
|
+
asString = `${local.protocol}://${asString}`;
|
|
438
|
+
}
|
|
439
|
+
if (local.port) {
|
|
440
|
+
asString = `${asString}:${local.port}`;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
409
443
|
errors.push(
|
|
410
|
-
`Application '${applicationId}'
|
|
444
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
411
445
|
);
|
|
412
446
|
}
|
|
413
447
|
}
|
|
@@ -471,10 +505,10 @@ var Host = class {
|
|
|
471
505
|
}
|
|
472
506
|
this.local = options?.isLocal;
|
|
473
507
|
}
|
|
474
|
-
static parseUrl(url) {
|
|
508
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
475
509
|
let hostToParse = url;
|
|
476
510
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
477
|
-
hostToParse =
|
|
511
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
478
512
|
}
|
|
479
513
|
const parsed = new URL(hostToParse);
|
|
480
514
|
if (!parsed.hostname) {
|
|
@@ -527,12 +561,39 @@ var LocalHost = class extends Host {
|
|
|
527
561
|
constructor({
|
|
528
562
|
appName,
|
|
529
563
|
localPort,
|
|
530
|
-
|
|
564
|
+
local
|
|
531
565
|
}) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
566
|
+
if (localPort && local) {
|
|
567
|
+
throw new Error(
|
|
568
|
+
`Microfrontends configuration error: '${appName}' has both the 'development.local' and 'development.localPort' fields set. Please remove the 'development.localPort' field and ensure the 'development.local' field has the correct port.`
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
let protocol;
|
|
572
|
+
let host;
|
|
573
|
+
let port;
|
|
574
|
+
if (localPort) {
|
|
575
|
+
port = localPort;
|
|
576
|
+
} else if (typeof local === "number") {
|
|
577
|
+
port = local;
|
|
578
|
+
} else if (typeof local === "string") {
|
|
579
|
+
if (/^\d+$/.test(local)) {
|
|
580
|
+
port = Number.parseInt(local);
|
|
581
|
+
} else {
|
|
582
|
+
const parsed = Host.parseUrl(local, "http");
|
|
583
|
+
protocol = parsed.protocol;
|
|
584
|
+
host = parsed.host;
|
|
585
|
+
port = parsed.port;
|
|
586
|
+
}
|
|
587
|
+
} else if (local) {
|
|
588
|
+
protocol = local.protocol;
|
|
589
|
+
host = local.host;
|
|
590
|
+
port = local.port;
|
|
591
|
+
}
|
|
592
|
+
super({
|
|
593
|
+
protocol: protocol ?? "http",
|
|
594
|
+
host: host ?? "localhost",
|
|
595
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
596
|
+
});
|
|
536
597
|
}
|
|
537
598
|
};
|
|
538
599
|
|
|
@@ -548,7 +609,7 @@ var Application = class {
|
|
|
548
609
|
local: new LocalHost({
|
|
549
610
|
appName: name,
|
|
550
611
|
localPort: app.development?.localPort,
|
|
551
|
-
|
|
612
|
+
local: app.development?.local
|
|
552
613
|
}),
|
|
553
614
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
554
615
|
};
|
|
@@ -558,6 +619,7 @@ var Application = class {
|
|
|
558
619
|
this.fallback = new Host(app.production);
|
|
559
620
|
}
|
|
560
621
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
622
|
+
this.packageName = app.packageName;
|
|
561
623
|
this.overrides = overrides?.environment ? {
|
|
562
624
|
environment: new Host(overrides.environment)
|
|
563
625
|
} : void 0;
|
|
@@ -723,10 +785,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
723
785
|
].filter(Boolean);
|
|
724
786
|
}
|
|
725
787
|
getApplication(name) {
|
|
726
|
-
if (this.defaultApplication?.name === name) {
|
|
788
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
727
789
|
return this.defaultApplication;
|
|
728
790
|
}
|
|
729
|
-
const app = this.childApplications[name]
|
|
791
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
792
|
+
(child) => child.packageName === name
|
|
793
|
+
);
|
|
730
794
|
if (!app) {
|
|
731
795
|
throw new MicrofrontendError(
|
|
732
796
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
@@ -1175,9 +1239,7 @@ var schema_default = {
|
|
|
1175
1239
|
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"
|
|
1176
1240
|
}
|
|
1177
1241
|
},
|
|
1178
|
-
required: [
|
|
1179
|
-
"applications"
|
|
1180
|
-
],
|
|
1242
|
+
required: ["applications"],
|
|
1181
1243
|
additionalProperties: false
|
|
1182
1244
|
},
|
|
1183
1245
|
Options: {
|
|
@@ -1230,7 +1292,7 @@ var schema_default = {
|
|
|
1230
1292
|
$ref: "#/definitions/Application"
|
|
1231
1293
|
},
|
|
1232
1294
|
propertyNames: {
|
|
1233
|
-
description: "The unique identifier for a Microfrontend Application
|
|
1295
|
+
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."
|
|
1234
1296
|
}
|
|
1235
1297
|
},
|
|
1236
1298
|
Application: {
|
|
@@ -1252,7 +1314,12 @@ var schema_default = {
|
|
|
1252
1314
|
},
|
|
1253
1315
|
projectId: {
|
|
1254
1316
|
type: "string",
|
|
1255
|
-
description: "Vercel project ID"
|
|
1317
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1318
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1319
|
+
},
|
|
1320
|
+
packageName: {
|
|
1321
|
+
type: "string",
|
|
1322
|
+
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`."
|
|
1256
1323
|
},
|
|
1257
1324
|
production: {
|
|
1258
1325
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1272,9 +1339,7 @@ var schema_default = {
|
|
|
1272
1339
|
description: "Vercel project ID"
|
|
1273
1340
|
}
|
|
1274
1341
|
},
|
|
1275
|
-
required: [
|
|
1276
|
-
"projectId"
|
|
1277
|
-
],
|
|
1342
|
+
required: ["projectId"],
|
|
1278
1343
|
additionalProperties: false
|
|
1279
1344
|
},
|
|
1280
1345
|
HostConfig: {
|
|
@@ -1282,10 +1347,7 @@ var schema_default = {
|
|
|
1282
1347
|
properties: {
|
|
1283
1348
|
protocol: {
|
|
1284
1349
|
type: "string",
|
|
1285
|
-
enum: [
|
|
1286
|
-
"http",
|
|
1287
|
-
"https"
|
|
1288
|
-
],
|
|
1350
|
+
enum: ["http", "https"],
|
|
1289
1351
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1290
1352
|
},
|
|
1291
1353
|
host: {
|
|
@@ -1297,21 +1359,30 @@ var schema_default = {
|
|
|
1297
1359
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1298
1360
|
}
|
|
1299
1361
|
},
|
|
1300
|
-
required: [
|
|
1301
|
-
"host"
|
|
1302
|
-
],
|
|
1362
|
+
required: ["host"],
|
|
1303
1363
|
additionalProperties: false
|
|
1304
1364
|
},
|
|
1305
1365
|
Development: {
|
|
1306
1366
|
type: "object",
|
|
1307
1367
|
properties: {
|
|
1308
1368
|
local: {
|
|
1309
|
-
|
|
1310
|
-
|
|
1369
|
+
anyOf: [
|
|
1370
|
+
{
|
|
1371
|
+
type: "number"
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
type: "string"
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
$ref: "#/definitions/LocalHostConfig"
|
|
1378
|
+
}
|
|
1379
|
+
],
|
|
1380
|
+
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\n\nPassing a LocalHostConfig is deprecated and will go away soon, please pass a number or string."
|
|
1311
1381
|
},
|
|
1312
1382
|
localPort: {
|
|
1313
1383
|
type: "number",
|
|
1314
|
-
description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1384
|
+
description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
|
|
1385
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1315
1386
|
},
|
|
1316
1387
|
fallback: {
|
|
1317
1388
|
anyOf: [
|
|
@@ -1322,7 +1393,7 @@ var schema_default = {
|
|
|
1322
1393
|
type: "string"
|
|
1323
1394
|
}
|
|
1324
1395
|
],
|
|
1325
|
-
description: "Fallback for local development, could
|
|
1396
|
+
description: "Fallback for local development, could point to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\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\nPassing a HostConfig is deprecated and will go away soon, please pass a string."
|
|
1326
1397
|
},
|
|
1327
1398
|
task: {
|
|
1328
1399
|
type: "string",
|
|
@@ -1341,10 +1412,7 @@ var schema_default = {
|
|
|
1341
1412
|
},
|
|
1342
1413
|
protocol: {
|
|
1343
1414
|
type: "string",
|
|
1344
|
-
enum: [
|
|
1345
|
-
"http",
|
|
1346
|
-
"https"
|
|
1347
|
-
],
|
|
1415
|
+
enum: ["http", "https"],
|
|
1348
1416
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1349
1417
|
},
|
|
1350
1418
|
port: {
|
|
@@ -1362,7 +1430,12 @@ var schema_default = {
|
|
|
1362
1430
|
},
|
|
1363
1431
|
projectId: {
|
|
1364
1432
|
type: "string",
|
|
1365
|
-
description: "Vercel project ID"
|
|
1433
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1434
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1435
|
+
},
|
|
1436
|
+
packageName: {
|
|
1437
|
+
type: "string",
|
|
1438
|
+
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`."
|
|
1366
1439
|
},
|
|
1367
1440
|
production: {
|
|
1368
1441
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1376,9 +1449,7 @@ var schema_default = {
|
|
|
1376
1449
|
description: "Groups of path expressions that are routed to this application."
|
|
1377
1450
|
}
|
|
1378
1451
|
},
|
|
1379
|
-
required: [
|
|
1380
|
-
"routing"
|
|
1381
|
-
],
|
|
1452
|
+
required: ["routing"],
|
|
1382
1453
|
additionalProperties: false
|
|
1383
1454
|
},
|
|
1384
1455
|
Routing: {
|
|
@@ -1405,9 +1476,7 @@ var schema_default = {
|
|
|
1405
1476
|
}
|
|
1406
1477
|
}
|
|
1407
1478
|
},
|
|
1408
|
-
required: [
|
|
1409
|
-
"paths"
|
|
1410
|
-
],
|
|
1479
|
+
required: ["paths"],
|
|
1411
1480
|
additionalProperties: false
|
|
1412
1481
|
},
|
|
1413
1482
|
ChildConfig: {
|
|
@@ -1428,9 +1497,7 @@ var schema_default = {
|
|
|
1428
1497
|
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."
|
|
1429
1498
|
}
|
|
1430
1499
|
},
|
|
1431
|
-
required: [
|
|
1432
|
-
"partOf"
|
|
1433
|
-
],
|
|
1500
|
+
required: ["partOf"],
|
|
1434
1501
|
additionalProperties: false
|
|
1435
1502
|
}
|
|
1436
1503
|
}
|