@vercel/microfrontends 1.1.0 → 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 +120 -27
- 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 +108 -23
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +108 -23
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +108 -23
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +108 -23
- 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 +108 -23
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +4 -4
- package/dist/microfrontends/server.js +108 -23
- 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 +125 -30
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +125 -30
- 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 +108 -23
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +108 -23
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +28 -7
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +28 -7
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/schema/schema.json +28 -7
|
@@ -314,10 +314,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
if (errors.length) {
|
|
317
|
-
throw new MicrofrontendError(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
throw new MicrofrontendError(
|
|
318
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
319
|
+
{
|
|
320
|
+
type: "config",
|
|
321
|
+
subtype: "conflicting_paths"
|
|
322
|
+
}
|
|
323
|
+
);
|
|
321
324
|
}
|
|
322
325
|
};
|
|
323
326
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -432,9 +435,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
432
435
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
433
436
|
);
|
|
434
437
|
}
|
|
435
|
-
if (application.development?.
|
|
438
|
+
if (application.development?.localPort) {
|
|
436
439
|
errors.push(
|
|
437
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.
|
|
440
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
444
|
+
const fallback = application.development.fallback;
|
|
445
|
+
let asString = fallback.host;
|
|
446
|
+
if (fallback.protocol) {
|
|
447
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
448
|
+
}
|
|
449
|
+
if (fallback.port) {
|
|
450
|
+
asString = `${asString}:${fallback.port}`;
|
|
451
|
+
}
|
|
452
|
+
errors.push(
|
|
453
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
457
|
+
const local = application.development.local;
|
|
458
|
+
let asString;
|
|
459
|
+
if (local.port && !local.protocol && !local.host) {
|
|
460
|
+
asString = String(local.port);
|
|
461
|
+
} else {
|
|
462
|
+
asString = local.host ?? "localhost";
|
|
463
|
+
if (local.protocol) {
|
|
464
|
+
asString = `${local.protocol}://${asString}`;
|
|
465
|
+
}
|
|
466
|
+
if (local.port) {
|
|
467
|
+
asString = `${asString}:${local.port}`;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
errors.push(
|
|
471
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
438
472
|
);
|
|
439
473
|
}
|
|
440
474
|
}
|
|
@@ -498,10 +532,10 @@ var Host = class {
|
|
|
498
532
|
}
|
|
499
533
|
this.local = options?.isLocal;
|
|
500
534
|
}
|
|
501
|
-
static parseUrl(url) {
|
|
535
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
502
536
|
let hostToParse = url;
|
|
503
537
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
504
|
-
hostToParse =
|
|
538
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
505
539
|
}
|
|
506
540
|
const parsed = new URL(hostToParse);
|
|
507
541
|
if (!parsed.hostname) {
|
|
@@ -554,12 +588,39 @@ var LocalHost = class extends Host {
|
|
|
554
588
|
constructor({
|
|
555
589
|
appName,
|
|
556
590
|
localPort,
|
|
557
|
-
|
|
591
|
+
local
|
|
558
592
|
}) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
593
|
+
if (localPort && local) {
|
|
594
|
+
throw new Error(
|
|
595
|
+
`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.`
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
let protocol;
|
|
599
|
+
let host;
|
|
600
|
+
let port;
|
|
601
|
+
if (localPort) {
|
|
602
|
+
port = localPort;
|
|
603
|
+
} else if (typeof local === "number") {
|
|
604
|
+
port = local;
|
|
605
|
+
} else if (typeof local === "string") {
|
|
606
|
+
if (/^\d+$/.test(local)) {
|
|
607
|
+
port = Number.parseInt(local);
|
|
608
|
+
} else {
|
|
609
|
+
const parsed = Host.parseUrl(local, "http");
|
|
610
|
+
protocol = parsed.protocol;
|
|
611
|
+
host = parsed.host;
|
|
612
|
+
port = parsed.port;
|
|
613
|
+
}
|
|
614
|
+
} else if (local) {
|
|
615
|
+
protocol = local.protocol;
|
|
616
|
+
host = local.host;
|
|
617
|
+
port = local.port;
|
|
618
|
+
}
|
|
619
|
+
super({
|
|
620
|
+
protocol: protocol ?? "http",
|
|
621
|
+
host: host ?? "localhost",
|
|
622
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
623
|
+
});
|
|
563
624
|
}
|
|
564
625
|
};
|
|
565
626
|
|
|
@@ -575,7 +636,7 @@ var Application = class {
|
|
|
575
636
|
local: new LocalHost({
|
|
576
637
|
appName: name,
|
|
577
638
|
localPort: app.development?.localPort,
|
|
578
|
-
|
|
639
|
+
local: app.development?.local
|
|
579
640
|
}),
|
|
580
641
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
581
642
|
};
|
|
@@ -585,6 +646,7 @@ var Application = class {
|
|
|
585
646
|
this.fallback = new Host(app.production);
|
|
586
647
|
}
|
|
587
648
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
649
|
+
this.packageName = app.packageName;
|
|
588
650
|
this.overrides = overrides?.environment ? {
|
|
589
651
|
environment: new Host(overrides.environment)
|
|
590
652
|
} : void 0;
|
|
@@ -750,10 +812,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
750
812
|
].filter(Boolean);
|
|
751
813
|
}
|
|
752
814
|
getApplication(name) {
|
|
753
|
-
if (this.defaultApplication?.name === name) {
|
|
815
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
754
816
|
return this.defaultApplication;
|
|
755
817
|
}
|
|
756
|
-
const app = this.childApplications[name]
|
|
818
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
819
|
+
(child) => child.packageName === name
|
|
820
|
+
);
|
|
757
821
|
if (!app) {
|
|
758
822
|
throw new MicrofrontendError(
|
|
759
823
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
@@ -1255,7 +1319,7 @@ var schema_default = {
|
|
|
1255
1319
|
$ref: "#/definitions/Application"
|
|
1256
1320
|
},
|
|
1257
1321
|
propertyNames: {
|
|
1258
|
-
description: "The unique identifier for a Microfrontend Application
|
|
1322
|
+
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
1323
|
}
|
|
1260
1324
|
},
|
|
1261
1325
|
Application: {
|
|
@@ -1277,7 +1341,12 @@ var schema_default = {
|
|
|
1277
1341
|
},
|
|
1278
1342
|
projectId: {
|
|
1279
1343
|
type: "string",
|
|
1280
|
-
description: "Vercel project ID"
|
|
1344
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1345
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1346
|
+
},
|
|
1347
|
+
packageName: {
|
|
1348
|
+
type: "string",
|
|
1349
|
+
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
1350
|
},
|
|
1282
1351
|
production: {
|
|
1283
1352
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1324,12 +1393,23 @@ var schema_default = {
|
|
|
1324
1393
|
type: "object",
|
|
1325
1394
|
properties: {
|
|
1326
1395
|
local: {
|
|
1327
|
-
|
|
1328
|
-
|
|
1396
|
+
anyOf: [
|
|
1397
|
+
{
|
|
1398
|
+
type: "number"
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
type: "string"
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
$ref: "#/definitions/LocalHostConfig"
|
|
1405
|
+
}
|
|
1406
|
+
],
|
|
1407
|
+
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."
|
|
1329
1408
|
},
|
|
1330
1409
|
localPort: {
|
|
1331
1410
|
type: "number",
|
|
1332
|
-
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."
|
|
1411
|
+
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.",
|
|
1412
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1333
1413
|
},
|
|
1334
1414
|
fallback: {
|
|
1335
1415
|
anyOf: [
|
|
@@ -1340,7 +1420,7 @@ var schema_default = {
|
|
|
1340
1420
|
type: "string"
|
|
1341
1421
|
}
|
|
1342
1422
|
],
|
|
1343
|
-
description: "Fallback for local development, could
|
|
1423
|
+
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."
|
|
1344
1424
|
},
|
|
1345
1425
|
task: {
|
|
1346
1426
|
type: "string",
|
|
@@ -1377,7 +1457,12 @@ var schema_default = {
|
|
|
1377
1457
|
},
|
|
1378
1458
|
projectId: {
|
|
1379
1459
|
type: "string",
|
|
1380
|
-
description: "Vercel project ID"
|
|
1460
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1461
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1462
|
+
},
|
|
1463
|
+
packageName: {
|
|
1464
|
+
type: "string",
|
|
1465
|
+
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`."
|
|
1381
1466
|
},
|
|
1382
1467
|
production: {
|
|
1383
1468
|
$ref: "#/definitions/HostConfig",
|