@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
|
@@ -278,10 +278,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
if (errors.length) {
|
|
281
|
-
throw new MicrofrontendError(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
throw new MicrofrontendError(
|
|
282
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
283
|
+
{
|
|
284
|
+
type: "config",
|
|
285
|
+
subtype: "conflicting_paths"
|
|
286
|
+
}
|
|
287
|
+
);
|
|
285
288
|
}
|
|
286
289
|
};
|
|
287
290
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -396,9 +399,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
396
399
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
397
400
|
);
|
|
398
401
|
}
|
|
399
|
-
if (application.development?.
|
|
402
|
+
if (application.development?.localPort) {
|
|
403
|
+
errors.push(
|
|
404
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
408
|
+
const fallback = application.development.fallback;
|
|
409
|
+
let asString = fallback.host;
|
|
410
|
+
if (fallback.protocol) {
|
|
411
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
412
|
+
}
|
|
413
|
+
if (fallback.port) {
|
|
414
|
+
asString = `${asString}:${fallback.port}`;
|
|
415
|
+
}
|
|
416
|
+
errors.push(
|
|
417
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
421
|
+
const local = application.development.local;
|
|
422
|
+
let asString;
|
|
423
|
+
if (local.port && !local.protocol && !local.host) {
|
|
424
|
+
asString = String(local.port);
|
|
425
|
+
} else {
|
|
426
|
+
asString = local.host ?? "localhost";
|
|
427
|
+
if (local.protocol) {
|
|
428
|
+
asString = `${local.protocol}://${asString}`;
|
|
429
|
+
}
|
|
430
|
+
if (local.port) {
|
|
431
|
+
asString = `${asString}:${local.port}`;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
400
434
|
errors.push(
|
|
401
|
-
`Application '${applicationId}'
|
|
435
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
402
436
|
);
|
|
403
437
|
}
|
|
404
438
|
}
|
|
@@ -462,10 +496,10 @@ var Host = class {
|
|
|
462
496
|
}
|
|
463
497
|
this.local = options?.isLocal;
|
|
464
498
|
}
|
|
465
|
-
static parseUrl(url) {
|
|
499
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
466
500
|
let hostToParse = url;
|
|
467
501
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
468
|
-
hostToParse =
|
|
502
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
469
503
|
}
|
|
470
504
|
const parsed = new URL(hostToParse);
|
|
471
505
|
if (!parsed.hostname) {
|
|
@@ -518,12 +552,39 @@ var LocalHost = class extends Host {
|
|
|
518
552
|
constructor({
|
|
519
553
|
appName,
|
|
520
554
|
localPort,
|
|
521
|
-
|
|
555
|
+
local
|
|
522
556
|
}) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
557
|
+
if (localPort && local) {
|
|
558
|
+
throw new Error(
|
|
559
|
+
`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.`
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
let protocol;
|
|
563
|
+
let host;
|
|
564
|
+
let port;
|
|
565
|
+
if (localPort) {
|
|
566
|
+
port = localPort;
|
|
567
|
+
} else if (typeof local === "number") {
|
|
568
|
+
port = local;
|
|
569
|
+
} else if (typeof local === "string") {
|
|
570
|
+
if (/^\d+$/.test(local)) {
|
|
571
|
+
port = Number.parseInt(local);
|
|
572
|
+
} else {
|
|
573
|
+
const parsed = Host.parseUrl(local, "http");
|
|
574
|
+
protocol = parsed.protocol;
|
|
575
|
+
host = parsed.host;
|
|
576
|
+
port = parsed.port;
|
|
577
|
+
}
|
|
578
|
+
} else if (local) {
|
|
579
|
+
protocol = local.protocol;
|
|
580
|
+
host = local.host;
|
|
581
|
+
port = local.port;
|
|
582
|
+
}
|
|
583
|
+
super({
|
|
584
|
+
protocol: protocol ?? "http",
|
|
585
|
+
host: host ?? "localhost",
|
|
586
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
587
|
+
});
|
|
527
588
|
}
|
|
528
589
|
};
|
|
529
590
|
|
|
@@ -539,7 +600,7 @@ var Application = class {
|
|
|
539
600
|
local: new LocalHost({
|
|
540
601
|
appName: name,
|
|
541
602
|
localPort: app.development?.localPort,
|
|
542
|
-
|
|
603
|
+
local: app.development?.local
|
|
543
604
|
}),
|
|
544
605
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
545
606
|
};
|
|
@@ -549,6 +610,7 @@ var Application = class {
|
|
|
549
610
|
this.fallback = new Host(app.production);
|
|
550
611
|
}
|
|
551
612
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
613
|
+
this.packageName = app.packageName;
|
|
552
614
|
this.overrides = overrides?.environment ? {
|
|
553
615
|
environment: new Host(overrides.environment)
|
|
554
616
|
} : void 0;
|
|
@@ -714,10 +776,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
714
776
|
].filter(Boolean);
|
|
715
777
|
}
|
|
716
778
|
getApplication(name) {
|
|
717
|
-
if (this.defaultApplication?.name === name) {
|
|
779
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
718
780
|
return this.defaultApplication;
|
|
719
781
|
}
|
|
720
|
-
const app = this.childApplications[name]
|
|
782
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
783
|
+
(child) => child.packageName === name
|
|
784
|
+
);
|
|
721
785
|
if (!app) {
|
|
722
786
|
throw new MicrofrontendError(
|
|
723
787
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
@@ -1166,9 +1230,7 @@ var schema_default = {
|
|
|
1166
1230
|
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"
|
|
1167
1231
|
}
|
|
1168
1232
|
},
|
|
1169
|
-
required: [
|
|
1170
|
-
"applications"
|
|
1171
|
-
],
|
|
1233
|
+
required: ["applications"],
|
|
1172
1234
|
additionalProperties: false
|
|
1173
1235
|
},
|
|
1174
1236
|
Options: {
|
|
@@ -1221,7 +1283,7 @@ var schema_default = {
|
|
|
1221
1283
|
$ref: "#/definitions/Application"
|
|
1222
1284
|
},
|
|
1223
1285
|
propertyNames: {
|
|
1224
|
-
description: "The unique identifier for a Microfrontend Application
|
|
1286
|
+
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."
|
|
1225
1287
|
}
|
|
1226
1288
|
},
|
|
1227
1289
|
Application: {
|
|
@@ -1243,7 +1305,12 @@ var schema_default = {
|
|
|
1243
1305
|
},
|
|
1244
1306
|
projectId: {
|
|
1245
1307
|
type: "string",
|
|
1246
|
-
description: "Vercel project ID"
|
|
1308
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1309
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1310
|
+
},
|
|
1311
|
+
packageName: {
|
|
1312
|
+
type: "string",
|
|
1313
|
+
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
1314
|
},
|
|
1248
1315
|
production: {
|
|
1249
1316
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1263,9 +1330,7 @@ var schema_default = {
|
|
|
1263
1330
|
description: "Vercel project ID"
|
|
1264
1331
|
}
|
|
1265
1332
|
},
|
|
1266
|
-
required: [
|
|
1267
|
-
"projectId"
|
|
1268
|
-
],
|
|
1333
|
+
required: ["projectId"],
|
|
1269
1334
|
additionalProperties: false
|
|
1270
1335
|
},
|
|
1271
1336
|
HostConfig: {
|
|
@@ -1273,10 +1338,7 @@ var schema_default = {
|
|
|
1273
1338
|
properties: {
|
|
1274
1339
|
protocol: {
|
|
1275
1340
|
type: "string",
|
|
1276
|
-
enum: [
|
|
1277
|
-
"http",
|
|
1278
|
-
"https"
|
|
1279
|
-
],
|
|
1341
|
+
enum: ["http", "https"],
|
|
1280
1342
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1281
1343
|
},
|
|
1282
1344
|
host: {
|
|
@@ -1288,21 +1350,30 @@ var schema_default = {
|
|
|
1288
1350
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1289
1351
|
}
|
|
1290
1352
|
},
|
|
1291
|
-
required: [
|
|
1292
|
-
"host"
|
|
1293
|
-
],
|
|
1353
|
+
required: ["host"],
|
|
1294
1354
|
additionalProperties: false
|
|
1295
1355
|
},
|
|
1296
1356
|
Development: {
|
|
1297
1357
|
type: "object",
|
|
1298
1358
|
properties: {
|
|
1299
1359
|
local: {
|
|
1300
|
-
|
|
1301
|
-
|
|
1360
|
+
anyOf: [
|
|
1361
|
+
{
|
|
1362
|
+
type: "number"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
type: "string"
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
$ref: "#/definitions/LocalHostConfig"
|
|
1369
|
+
}
|
|
1370
|
+
],
|
|
1371
|
+
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."
|
|
1302
1372
|
},
|
|
1303
1373
|
localPort: {
|
|
1304
1374
|
type: "number",
|
|
1305
|
-
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."
|
|
1375
|
+
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.",
|
|
1376
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1306
1377
|
},
|
|
1307
1378
|
fallback: {
|
|
1308
1379
|
anyOf: [
|
|
@@ -1313,7 +1384,7 @@ var schema_default = {
|
|
|
1313
1384
|
type: "string"
|
|
1314
1385
|
}
|
|
1315
1386
|
],
|
|
1316
|
-
description: "Fallback for local development, could
|
|
1387
|
+
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."
|
|
1317
1388
|
},
|
|
1318
1389
|
task: {
|
|
1319
1390
|
type: "string",
|
|
@@ -1332,10 +1403,7 @@ var schema_default = {
|
|
|
1332
1403
|
},
|
|
1333
1404
|
protocol: {
|
|
1334
1405
|
type: "string",
|
|
1335
|
-
enum: [
|
|
1336
|
-
"http",
|
|
1337
|
-
"https"
|
|
1338
|
-
],
|
|
1406
|
+
enum: ["http", "https"],
|
|
1339
1407
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1340
1408
|
},
|
|
1341
1409
|
port: {
|
|
@@ -1353,7 +1421,12 @@ var schema_default = {
|
|
|
1353
1421
|
},
|
|
1354
1422
|
projectId: {
|
|
1355
1423
|
type: "string",
|
|
1356
|
-
description: "Vercel project ID"
|
|
1424
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1425
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1426
|
+
},
|
|
1427
|
+
packageName: {
|
|
1428
|
+
type: "string",
|
|
1429
|
+
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`."
|
|
1357
1430
|
},
|
|
1358
1431
|
production: {
|
|
1359
1432
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1367,9 +1440,7 @@ var schema_default = {
|
|
|
1367
1440
|
description: "Groups of path expressions that are routed to this application."
|
|
1368
1441
|
}
|
|
1369
1442
|
},
|
|
1370
|
-
required: [
|
|
1371
|
-
"routing"
|
|
1372
|
-
],
|
|
1443
|
+
required: ["routing"],
|
|
1373
1444
|
additionalProperties: false
|
|
1374
1445
|
},
|
|
1375
1446
|
Routing: {
|
|
@@ -1396,9 +1467,7 @@ var schema_default = {
|
|
|
1396
1467
|
}
|
|
1397
1468
|
}
|
|
1398
1469
|
},
|
|
1399
|
-
required: [
|
|
1400
|
-
"paths"
|
|
1401
|
-
],
|
|
1470
|
+
required: ["paths"],
|
|
1402
1471
|
additionalProperties: false
|
|
1403
1472
|
},
|
|
1404
1473
|
ChildConfig: {
|
|
@@ -1419,9 +1488,7 @@ var schema_default = {
|
|
|
1419
1488
|
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."
|
|
1420
1489
|
}
|
|
1421
1490
|
},
|
|
1422
|
-
required: [
|
|
1423
|
-
"partOf"
|
|
1424
|
-
],
|
|
1491
|
+
required: ["partOf"],
|
|
1425
1492
|
additionalProperties: false
|
|
1426
1493
|
}
|
|
1427
1494
|
}
|