@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HostConfig, L as LocalHostConfig, D as DefaultApplication$1, P as PathGroup, b as ChildApplication$1,
|
|
2
|
-
import { C as ClientConfig } from './types-
|
|
3
|
-
import { A as ApplicationOverrideConfig, O as OverridesConfig } from './types-
|
|
1
|
+
import { H as HostConfig, L as LocalHostConfig, D as DefaultApplication$1, P as PathGroup, b as ChildApplication$1, A as Application$1, C as Config } from './types-6ee19ccc.js';
|
|
2
|
+
import { C as ClientConfig } from './types-74e3336c.js';
|
|
3
|
+
import { A as ApplicationOverrideConfig, O as OverridesConfig } from './types-73527280.js';
|
|
4
4
|
|
|
5
5
|
interface MicrofrontendConfigClientOptions {
|
|
6
6
|
removeFlaggedPaths?: boolean;
|
|
@@ -29,7 +29,11 @@ declare class Host {
|
|
|
29
29
|
port?: number;
|
|
30
30
|
local: boolean | undefined;
|
|
31
31
|
constructor(hostConfig: HostConfig | string, options?: HostOptions);
|
|
32
|
-
|
|
32
|
+
protected static parseUrl(url: string, defaultProtocol?: string): {
|
|
33
|
+
protocol: Host['protocol'];
|
|
34
|
+
host: string;
|
|
35
|
+
port?: number;
|
|
36
|
+
};
|
|
33
37
|
private static getMicrofrontendsError;
|
|
34
38
|
isLocal(): boolean;
|
|
35
39
|
toString(): string;
|
|
@@ -39,9 +43,10 @@ declare class Host {
|
|
|
39
43
|
* A Host subclass with defaults for locally running applications
|
|
40
44
|
*/
|
|
41
45
|
declare class LocalHost extends Host {
|
|
42
|
-
constructor({ appName, localPort,
|
|
46
|
+
constructor({ appName, localPort, local, }: {
|
|
43
47
|
appName: string;
|
|
44
48
|
localPort?: number;
|
|
49
|
+
local?: string | number | LocalHostConfig;
|
|
45
50
|
});
|
|
46
51
|
}
|
|
47
52
|
|
|
@@ -54,6 +59,7 @@ declare class Application {
|
|
|
54
59
|
};
|
|
55
60
|
fallback?: Host;
|
|
56
61
|
projectId?: string;
|
|
62
|
+
packageName?: string;
|
|
57
63
|
overrides?: {
|
|
58
64
|
environment?: Host;
|
|
59
65
|
};
|
|
@@ -312,10 +312,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
if (errors.length) {
|
|
315
|
-
throw new MicrofrontendError(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
315
|
+
throw new MicrofrontendError(
|
|
316
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
317
|
+
{
|
|
318
|
+
type: "config",
|
|
319
|
+
subtype: "conflicting_paths"
|
|
320
|
+
}
|
|
321
|
+
);
|
|
319
322
|
}
|
|
320
323
|
};
|
|
321
324
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -430,9 +433,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
430
433
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
431
434
|
);
|
|
432
435
|
}
|
|
433
|
-
if (application.development?.
|
|
436
|
+
if (application.development?.localPort) {
|
|
437
|
+
errors.push(
|
|
438
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
442
|
+
const fallback = application.development.fallback;
|
|
443
|
+
let asString = fallback.host;
|
|
444
|
+
if (fallback.protocol) {
|
|
445
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
446
|
+
}
|
|
447
|
+
if (fallback.port) {
|
|
448
|
+
asString = `${asString}:${fallback.port}`;
|
|
449
|
+
}
|
|
450
|
+
errors.push(
|
|
451
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
455
|
+
const local = application.development.local;
|
|
456
|
+
let asString;
|
|
457
|
+
if (local.port && !local.protocol && !local.host) {
|
|
458
|
+
asString = String(local.port);
|
|
459
|
+
} else {
|
|
460
|
+
asString = local.host ?? "localhost";
|
|
461
|
+
if (local.protocol) {
|
|
462
|
+
asString = `${local.protocol}://${asString}`;
|
|
463
|
+
}
|
|
464
|
+
if (local.port) {
|
|
465
|
+
asString = `${asString}:${local.port}`;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
434
468
|
errors.push(
|
|
435
|
-
`Application '${applicationId}'
|
|
469
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
436
470
|
);
|
|
437
471
|
}
|
|
438
472
|
}
|
|
@@ -496,10 +530,10 @@ var Host = class {
|
|
|
496
530
|
}
|
|
497
531
|
this.local = options?.isLocal;
|
|
498
532
|
}
|
|
499
|
-
static parseUrl(url) {
|
|
533
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
500
534
|
let hostToParse = url;
|
|
501
535
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
502
|
-
hostToParse =
|
|
536
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
503
537
|
}
|
|
504
538
|
const parsed = new URL(hostToParse);
|
|
505
539
|
if (!parsed.hostname) {
|
|
@@ -552,12 +586,39 @@ var LocalHost = class extends Host {
|
|
|
552
586
|
constructor({
|
|
553
587
|
appName,
|
|
554
588
|
localPort,
|
|
555
|
-
|
|
589
|
+
local
|
|
556
590
|
}) {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
591
|
+
if (localPort && local) {
|
|
592
|
+
throw new Error(
|
|
593
|
+
`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.`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
let protocol;
|
|
597
|
+
let host;
|
|
598
|
+
let port;
|
|
599
|
+
if (localPort) {
|
|
600
|
+
port = localPort;
|
|
601
|
+
} else if (typeof local === "number") {
|
|
602
|
+
port = local;
|
|
603
|
+
} else if (typeof local === "string") {
|
|
604
|
+
if (/^\d+$/.test(local)) {
|
|
605
|
+
port = Number.parseInt(local);
|
|
606
|
+
} else {
|
|
607
|
+
const parsed = Host.parseUrl(local, "http");
|
|
608
|
+
protocol = parsed.protocol;
|
|
609
|
+
host = parsed.host;
|
|
610
|
+
port = parsed.port;
|
|
611
|
+
}
|
|
612
|
+
} else if (local) {
|
|
613
|
+
protocol = local.protocol;
|
|
614
|
+
host = local.host;
|
|
615
|
+
port = local.port;
|
|
616
|
+
}
|
|
617
|
+
super({
|
|
618
|
+
protocol: protocol ?? "http",
|
|
619
|
+
host: host ?? "localhost",
|
|
620
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
621
|
+
});
|
|
561
622
|
}
|
|
562
623
|
};
|
|
563
624
|
|
|
@@ -573,7 +634,7 @@ var Application = class {
|
|
|
573
634
|
local: new LocalHost({
|
|
574
635
|
appName: name,
|
|
575
636
|
localPort: app.development?.localPort,
|
|
576
|
-
|
|
637
|
+
local: app.development?.local
|
|
577
638
|
}),
|
|
578
639
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
579
640
|
};
|
|
@@ -583,6 +644,7 @@ var Application = class {
|
|
|
583
644
|
this.fallback = new Host(app.production);
|
|
584
645
|
}
|
|
585
646
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
647
|
+
this.packageName = app.packageName;
|
|
586
648
|
this.overrides = overrides?.environment ? {
|
|
587
649
|
environment: new Host(overrides.environment)
|
|
588
650
|
} : void 0;
|
|
@@ -748,10 +810,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
748
810
|
].filter(Boolean);
|
|
749
811
|
}
|
|
750
812
|
getApplication(name) {
|
|
751
|
-
if (this.defaultApplication?.name === name) {
|
|
813
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
752
814
|
return this.defaultApplication;
|
|
753
815
|
}
|
|
754
|
-
const app = this.childApplications[name]
|
|
816
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
817
|
+
(child) => child.packageName === name
|
|
818
|
+
);
|
|
755
819
|
if (!app) {
|
|
756
820
|
throw new MicrofrontendError(
|
|
757
821
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
@@ -1200,9 +1264,7 @@ var schema_default = {
|
|
|
1200
1264
|
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"
|
|
1201
1265
|
}
|
|
1202
1266
|
},
|
|
1203
|
-
required: [
|
|
1204
|
-
"applications"
|
|
1205
|
-
],
|
|
1267
|
+
required: ["applications"],
|
|
1206
1268
|
additionalProperties: false
|
|
1207
1269
|
},
|
|
1208
1270
|
Options: {
|
|
@@ -1255,7 +1317,7 @@ var schema_default = {
|
|
|
1255
1317
|
$ref: "#/definitions/Application"
|
|
1256
1318
|
},
|
|
1257
1319
|
propertyNames: {
|
|
1258
|
-
description: "The unique identifier for a Microfrontend Application
|
|
1320
|
+
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."
|
|
1259
1321
|
}
|
|
1260
1322
|
},
|
|
1261
1323
|
Application: {
|
|
@@ -1277,7 +1339,12 @@ var schema_default = {
|
|
|
1277
1339
|
},
|
|
1278
1340
|
projectId: {
|
|
1279
1341
|
type: "string",
|
|
1280
|
-
description: "Vercel project ID"
|
|
1342
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1343
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1344
|
+
},
|
|
1345
|
+
packageName: {
|
|
1346
|
+
type: "string",
|
|
1347
|
+
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`."
|
|
1281
1348
|
},
|
|
1282
1349
|
production: {
|
|
1283
1350
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1297,9 +1364,7 @@ var schema_default = {
|
|
|
1297
1364
|
description: "Vercel project ID"
|
|
1298
1365
|
}
|
|
1299
1366
|
},
|
|
1300
|
-
required: [
|
|
1301
|
-
"projectId"
|
|
1302
|
-
],
|
|
1367
|
+
required: ["projectId"],
|
|
1303
1368
|
additionalProperties: false
|
|
1304
1369
|
},
|
|
1305
1370
|
HostConfig: {
|
|
@@ -1307,10 +1372,7 @@ var schema_default = {
|
|
|
1307
1372
|
properties: {
|
|
1308
1373
|
protocol: {
|
|
1309
1374
|
type: "string",
|
|
1310
|
-
enum: [
|
|
1311
|
-
"http",
|
|
1312
|
-
"https"
|
|
1313
|
-
],
|
|
1375
|
+
enum: ["http", "https"],
|
|
1314
1376
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1315
1377
|
},
|
|
1316
1378
|
host: {
|
|
@@ -1322,21 +1384,30 @@ var schema_default = {
|
|
|
1322
1384
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1323
1385
|
}
|
|
1324
1386
|
},
|
|
1325
|
-
required: [
|
|
1326
|
-
"host"
|
|
1327
|
-
],
|
|
1387
|
+
required: ["host"],
|
|
1328
1388
|
additionalProperties: false
|
|
1329
1389
|
},
|
|
1330
1390
|
Development: {
|
|
1331
1391
|
type: "object",
|
|
1332
1392
|
properties: {
|
|
1333
1393
|
local: {
|
|
1334
|
-
|
|
1335
|
-
|
|
1394
|
+
anyOf: [
|
|
1395
|
+
{
|
|
1396
|
+
type: "number"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
type: "string"
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
$ref: "#/definitions/LocalHostConfig"
|
|
1403
|
+
}
|
|
1404
|
+
],
|
|
1405
|
+
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."
|
|
1336
1406
|
},
|
|
1337
1407
|
localPort: {
|
|
1338
1408
|
type: "number",
|
|
1339
|
-
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."
|
|
1409
|
+
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.",
|
|
1410
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1340
1411
|
},
|
|
1341
1412
|
fallback: {
|
|
1342
1413
|
anyOf: [
|
|
@@ -1347,7 +1418,7 @@ var schema_default = {
|
|
|
1347
1418
|
type: "string"
|
|
1348
1419
|
}
|
|
1349
1420
|
],
|
|
1350
|
-
description: "Fallback for local development, could
|
|
1421
|
+
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."
|
|
1351
1422
|
},
|
|
1352
1423
|
task: {
|
|
1353
1424
|
type: "string",
|
|
@@ -1366,10 +1437,7 @@ var schema_default = {
|
|
|
1366
1437
|
},
|
|
1367
1438
|
protocol: {
|
|
1368
1439
|
type: "string",
|
|
1369
|
-
enum: [
|
|
1370
|
-
"http",
|
|
1371
|
-
"https"
|
|
1372
|
-
],
|
|
1440
|
+
enum: ["http", "https"],
|
|
1373
1441
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1374
1442
|
},
|
|
1375
1443
|
port: {
|
|
@@ -1387,7 +1455,12 @@ var schema_default = {
|
|
|
1387
1455
|
},
|
|
1388
1456
|
projectId: {
|
|
1389
1457
|
type: "string",
|
|
1390
|
-
description: "Vercel project ID"
|
|
1458
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1459
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1460
|
+
},
|
|
1461
|
+
packageName: {
|
|
1462
|
+
type: "string",
|
|
1463
|
+
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`."
|
|
1391
1464
|
},
|
|
1392
1465
|
production: {
|
|
1393
1466
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1401,9 +1474,7 @@ var schema_default = {
|
|
|
1401
1474
|
description: "Groups of path expressions that are routed to this application."
|
|
1402
1475
|
}
|
|
1403
1476
|
},
|
|
1404
|
-
required: [
|
|
1405
|
-
"routing"
|
|
1406
|
-
],
|
|
1477
|
+
required: ["routing"],
|
|
1407
1478
|
additionalProperties: false
|
|
1408
1479
|
},
|
|
1409
1480
|
Routing: {
|
|
@@ -1430,9 +1501,7 @@ var schema_default = {
|
|
|
1430
1501
|
}
|
|
1431
1502
|
}
|
|
1432
1503
|
},
|
|
1433
|
-
required: [
|
|
1434
|
-
"paths"
|
|
1435
|
-
],
|
|
1504
|
+
required: ["paths"],
|
|
1436
1505
|
additionalProperties: false
|
|
1437
1506
|
},
|
|
1438
1507
|
ChildConfig: {
|
|
@@ -1453,9 +1522,7 @@ var schema_default = {
|
|
|
1453
1522
|
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."
|
|
1454
1523
|
}
|
|
1455
1524
|
},
|
|
1456
|
-
required: [
|
|
1457
|
-
"partOf"
|
|
1458
|
-
],
|
|
1525
|
+
required: ["partOf"],
|
|
1459
1526
|
additionalProperties: false
|
|
1460
1527
|
}
|
|
1461
1528
|
}
|