@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
package/dist/bin/cli.cjs
CHANGED
|
@@ -29,7 +29,7 @@ var import_commander = require("commander");
|
|
|
29
29
|
// package.json
|
|
30
30
|
var package_default = {
|
|
31
31
|
name: "@vercel/microfrontends",
|
|
32
|
-
version: "1.
|
|
32
|
+
version: "1.1.1-canary.0",
|
|
33
33
|
private: false,
|
|
34
34
|
description: "Defines configuration and utilities for microfrontends development",
|
|
35
35
|
keywords: [
|
|
@@ -418,10 +418,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
if (errors.length) {
|
|
421
|
-
throw new MicrofrontendError(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
421
|
+
throw new MicrofrontendError(
|
|
422
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
423
|
+
{
|
|
424
|
+
type: "config",
|
|
425
|
+
subtype: "conflicting_paths"
|
|
426
|
+
}
|
|
427
|
+
);
|
|
425
428
|
}
|
|
426
429
|
};
|
|
427
430
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -536,9 +539,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
536
539
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
537
540
|
);
|
|
538
541
|
}
|
|
539
|
-
if (application.development?.
|
|
542
|
+
if (application.development?.localPort) {
|
|
540
543
|
errors.push(
|
|
541
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.
|
|
544
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
548
|
+
const fallback = application.development.fallback;
|
|
549
|
+
let asString = fallback.host;
|
|
550
|
+
if (fallback.protocol) {
|
|
551
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
552
|
+
}
|
|
553
|
+
if (fallback.port) {
|
|
554
|
+
asString = `${asString}:${fallback.port}`;
|
|
555
|
+
}
|
|
556
|
+
errors.push(
|
|
557
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
561
|
+
const local = application.development.local;
|
|
562
|
+
let asString;
|
|
563
|
+
if (local.port && !local.protocol && !local.host) {
|
|
564
|
+
asString = String(local.port);
|
|
565
|
+
} else {
|
|
566
|
+
asString = local.host ?? "localhost";
|
|
567
|
+
if (local.protocol) {
|
|
568
|
+
asString = `${local.protocol}://${asString}`;
|
|
569
|
+
}
|
|
570
|
+
if (local.port) {
|
|
571
|
+
asString = `${asString}:${local.port}`;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
errors.push(
|
|
575
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
542
576
|
);
|
|
543
577
|
}
|
|
544
578
|
}
|
|
@@ -602,10 +636,10 @@ var Host = class {
|
|
|
602
636
|
}
|
|
603
637
|
this.local = options?.isLocal;
|
|
604
638
|
}
|
|
605
|
-
static parseUrl(url) {
|
|
639
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
606
640
|
let hostToParse = url;
|
|
607
641
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
608
|
-
hostToParse =
|
|
642
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
609
643
|
}
|
|
610
644
|
const parsed = new URL(hostToParse);
|
|
611
645
|
if (!parsed.hostname) {
|
|
@@ -658,12 +692,39 @@ var LocalHost = class extends Host {
|
|
|
658
692
|
constructor({
|
|
659
693
|
appName,
|
|
660
694
|
localPort,
|
|
661
|
-
|
|
695
|
+
local
|
|
662
696
|
}) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
697
|
+
if (localPort && local) {
|
|
698
|
+
throw new Error(
|
|
699
|
+
`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.`
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
let protocol;
|
|
703
|
+
let host;
|
|
704
|
+
let port;
|
|
705
|
+
if (localPort) {
|
|
706
|
+
port = localPort;
|
|
707
|
+
} else if (typeof local === "number") {
|
|
708
|
+
port = local;
|
|
709
|
+
} else if (typeof local === "string") {
|
|
710
|
+
if (/^\d+$/.test(local)) {
|
|
711
|
+
port = Number.parseInt(local);
|
|
712
|
+
} else {
|
|
713
|
+
const parsed = Host.parseUrl(local, "http");
|
|
714
|
+
protocol = parsed.protocol;
|
|
715
|
+
host = parsed.host;
|
|
716
|
+
port = parsed.port;
|
|
717
|
+
}
|
|
718
|
+
} else if (local) {
|
|
719
|
+
protocol = local.protocol;
|
|
720
|
+
host = local.host;
|
|
721
|
+
port = local.port;
|
|
722
|
+
}
|
|
723
|
+
super({
|
|
724
|
+
protocol: protocol ?? "http",
|
|
725
|
+
host: host ?? "localhost",
|
|
726
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
727
|
+
});
|
|
667
728
|
}
|
|
668
729
|
};
|
|
669
730
|
|
|
@@ -679,7 +740,7 @@ var Application = class {
|
|
|
679
740
|
local: new LocalHost({
|
|
680
741
|
appName: name,
|
|
681
742
|
localPort: app.development?.localPort,
|
|
682
|
-
|
|
743
|
+
local: app.development?.local
|
|
683
744
|
}),
|
|
684
745
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
685
746
|
};
|
|
@@ -689,6 +750,7 @@ var Application = class {
|
|
|
689
750
|
this.fallback = new Host(app.production);
|
|
690
751
|
}
|
|
691
752
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
753
|
+
this.packageName = app.packageName;
|
|
692
754
|
this.overrides = overrides?.environment ? {
|
|
693
755
|
environment: new Host(overrides.environment)
|
|
694
756
|
} : void 0;
|
|
@@ -973,10 +1035,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
973
1035
|
].filter(Boolean);
|
|
974
1036
|
}
|
|
975
1037
|
getApplication(name) {
|
|
976
|
-
if (this.defaultApplication?.name === name) {
|
|
1038
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
977
1039
|
return this.defaultApplication;
|
|
978
1040
|
}
|
|
979
|
-
const app = this.childApplications[name]
|
|
1041
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
1042
|
+
(child) => child.packageName === name
|
|
1043
|
+
);
|
|
980
1044
|
if (!app) {
|
|
981
1045
|
throw new MicrofrontendError(
|
|
982
1046
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
@@ -1434,9 +1498,7 @@ var schema_default = {
|
|
|
1434
1498
|
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"
|
|
1435
1499
|
}
|
|
1436
1500
|
},
|
|
1437
|
-
required: [
|
|
1438
|
-
"applications"
|
|
1439
|
-
],
|
|
1501
|
+
required: ["applications"],
|
|
1440
1502
|
additionalProperties: false
|
|
1441
1503
|
},
|
|
1442
1504
|
Options: {
|
|
@@ -1489,7 +1551,7 @@ var schema_default = {
|
|
|
1489
1551
|
$ref: "#/definitions/Application"
|
|
1490
1552
|
},
|
|
1491
1553
|
propertyNames: {
|
|
1492
|
-
description: "The unique identifier for a Microfrontend Application
|
|
1554
|
+
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."
|
|
1493
1555
|
}
|
|
1494
1556
|
},
|
|
1495
1557
|
Application: {
|
|
@@ -1511,7 +1573,12 @@ var schema_default = {
|
|
|
1511
1573
|
},
|
|
1512
1574
|
projectId: {
|
|
1513
1575
|
type: "string",
|
|
1514
|
-
description: "Vercel project ID"
|
|
1576
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1577
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1578
|
+
},
|
|
1579
|
+
packageName: {
|
|
1580
|
+
type: "string",
|
|
1581
|
+
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`."
|
|
1515
1582
|
},
|
|
1516
1583
|
production: {
|
|
1517
1584
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1531,9 +1598,7 @@ var schema_default = {
|
|
|
1531
1598
|
description: "Vercel project ID"
|
|
1532
1599
|
}
|
|
1533
1600
|
},
|
|
1534
|
-
required: [
|
|
1535
|
-
"projectId"
|
|
1536
|
-
],
|
|
1601
|
+
required: ["projectId"],
|
|
1537
1602
|
additionalProperties: false
|
|
1538
1603
|
},
|
|
1539
1604
|
HostConfig: {
|
|
@@ -1541,10 +1606,7 @@ var schema_default = {
|
|
|
1541
1606
|
properties: {
|
|
1542
1607
|
protocol: {
|
|
1543
1608
|
type: "string",
|
|
1544
|
-
enum: [
|
|
1545
|
-
"http",
|
|
1546
|
-
"https"
|
|
1547
|
-
],
|
|
1609
|
+
enum: ["http", "https"],
|
|
1548
1610
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1549
1611
|
},
|
|
1550
1612
|
host: {
|
|
@@ -1556,21 +1618,30 @@ var schema_default = {
|
|
|
1556
1618
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1557
1619
|
}
|
|
1558
1620
|
},
|
|
1559
|
-
required: [
|
|
1560
|
-
"host"
|
|
1561
|
-
],
|
|
1621
|
+
required: ["host"],
|
|
1562
1622
|
additionalProperties: false
|
|
1563
1623
|
},
|
|
1564
1624
|
Development: {
|
|
1565
1625
|
type: "object",
|
|
1566
1626
|
properties: {
|
|
1567
1627
|
local: {
|
|
1568
|
-
|
|
1569
|
-
|
|
1628
|
+
anyOf: [
|
|
1629
|
+
{
|
|
1630
|
+
type: "number"
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
type: "string"
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
$ref: "#/definitions/LocalHostConfig"
|
|
1637
|
+
}
|
|
1638
|
+
],
|
|
1639
|
+
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."
|
|
1570
1640
|
},
|
|
1571
1641
|
localPort: {
|
|
1572
1642
|
type: "number",
|
|
1573
|
-
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."
|
|
1643
|
+
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.",
|
|
1644
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1574
1645
|
},
|
|
1575
1646
|
fallback: {
|
|
1576
1647
|
anyOf: [
|
|
@@ -1581,7 +1652,7 @@ var schema_default = {
|
|
|
1581
1652
|
type: "string"
|
|
1582
1653
|
}
|
|
1583
1654
|
],
|
|
1584
|
-
description: "Fallback for local development, could
|
|
1655
|
+
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."
|
|
1585
1656
|
},
|
|
1586
1657
|
task: {
|
|
1587
1658
|
type: "string",
|
|
@@ -1600,10 +1671,7 @@ var schema_default = {
|
|
|
1600
1671
|
},
|
|
1601
1672
|
protocol: {
|
|
1602
1673
|
type: "string",
|
|
1603
|
-
enum: [
|
|
1604
|
-
"http",
|
|
1605
|
-
"https"
|
|
1606
|
-
],
|
|
1674
|
+
enum: ["http", "https"],
|
|
1607
1675
|
description: "The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n*"
|
|
1608
1676
|
},
|
|
1609
1677
|
port: {
|
|
@@ -1621,7 +1689,12 @@ var schema_default = {
|
|
|
1621
1689
|
},
|
|
1622
1690
|
projectId: {
|
|
1623
1691
|
type: "string",
|
|
1624
|
-
description: "Vercel project ID"
|
|
1692
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1693
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1694
|
+
},
|
|
1695
|
+
packageName: {
|
|
1696
|
+
type: "string",
|
|
1697
|
+
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`."
|
|
1625
1698
|
},
|
|
1626
1699
|
production: {
|
|
1627
1700
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1635,9 +1708,7 @@ var schema_default = {
|
|
|
1635
1708
|
description: "Groups of path expressions that are routed to this application."
|
|
1636
1709
|
}
|
|
1637
1710
|
},
|
|
1638
|
-
required: [
|
|
1639
|
-
"routing"
|
|
1640
|
-
],
|
|
1711
|
+
required: ["routing"],
|
|
1641
1712
|
additionalProperties: false
|
|
1642
1713
|
},
|
|
1643
1714
|
Routing: {
|
|
@@ -1664,9 +1735,7 @@ var schema_default = {
|
|
|
1664
1735
|
}
|
|
1665
1736
|
}
|
|
1666
1737
|
},
|
|
1667
|
-
required: [
|
|
1668
|
-
"paths"
|
|
1669
|
-
],
|
|
1738
|
+
required: ["paths"],
|
|
1670
1739
|
additionalProperties: false
|
|
1671
1740
|
},
|
|
1672
1741
|
ChildConfig: {
|
|
@@ -1687,9 +1756,7 @@ var schema_default = {
|
|
|
1687
1756
|
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."
|
|
1688
1757
|
}
|
|
1689
1758
|
},
|
|
1690
|
-
required: [
|
|
1691
|
-
"partOf"
|
|
1692
|
-
],
|
|
1759
|
+
required: ["partOf"],
|
|
1693
1760
|
additionalProperties: false
|
|
1694
1761
|
}
|
|
1695
1762
|
}
|
|
@@ -1967,7 +2034,9 @@ var ProxyRequestRouter = class {
|
|
|
1967
2034
|
return this.getApplicationTarget(defaultApp);
|
|
1968
2035
|
}
|
|
1969
2036
|
getApplicationTarget(application) {
|
|
1970
|
-
const useDev = this.localApps.
|
|
2037
|
+
const useDev = this.localApps.find(
|
|
2038
|
+
(name) => name === application.name || name === application.packageName
|
|
2039
|
+
);
|
|
1971
2040
|
let applicationName = application.name;
|
|
1972
2041
|
let host = useDev ? application.development.local : application.fallback;
|
|
1973
2042
|
if (application.overrides?.environment?.host) {
|
|
@@ -2181,7 +2250,12 @@ var ProxyRequestRouter = class {
|
|
|
2181
2250
|
} : null;
|
|
2182
2251
|
}
|
|
2183
2252
|
isDefaultAppLocal() {
|
|
2184
|
-
|
|
2253
|
+
const defaultApp = this.config.getDefaultApplication();
|
|
2254
|
+
return Boolean(
|
|
2255
|
+
this.localApps.find(
|
|
2256
|
+
(name) => name === defaultApp.name || name === defaultApp.packageName
|
|
2257
|
+
)
|
|
2258
|
+
);
|
|
2185
2259
|
}
|
|
2186
2260
|
};
|
|
2187
2261
|
var LocalProxy = class {
|
|
@@ -2330,7 +2404,8 @@ function extractMfeFlagValue(path7) {
|
|
|
2330
2404
|
function stringAsBoolean(value) {
|
|
2331
2405
|
if (value === "true") {
|
|
2332
2406
|
return true;
|
|
2333
|
-
}
|
|
2407
|
+
}
|
|
2408
|
+
if (value === "false") {
|
|
2334
2409
|
return false;
|
|
2335
2410
|
}
|
|
2336
2411
|
return void 0;
|
package/dist/config.cjs
CHANGED
|
@@ -298,10 +298,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
if (errors.length) {
|
|
301
|
-
throw new MicrofrontendError(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
301
|
+
throw new MicrofrontendError(
|
|
302
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
303
|
+
{
|
|
304
|
+
type: "config",
|
|
305
|
+
subtype: "conflicting_paths"
|
|
306
|
+
}
|
|
307
|
+
);
|
|
305
308
|
}
|
|
306
309
|
};
|
|
307
310
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -416,9 +419,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
416
419
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
417
420
|
);
|
|
418
421
|
}
|
|
419
|
-
if (application.development?.
|
|
422
|
+
if (application.development?.localPort) {
|
|
423
|
+
errors.push(
|
|
424
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
428
|
+
const fallback = application.development.fallback;
|
|
429
|
+
let asString = fallback.host;
|
|
430
|
+
if (fallback.protocol) {
|
|
431
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
432
|
+
}
|
|
433
|
+
if (fallback.port) {
|
|
434
|
+
asString = `${asString}:${fallback.port}`;
|
|
435
|
+
}
|
|
436
|
+
errors.push(
|
|
437
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
441
|
+
const local = application.development.local;
|
|
442
|
+
let asString;
|
|
443
|
+
if (local.port && !local.protocol && !local.host) {
|
|
444
|
+
asString = String(local.port);
|
|
445
|
+
} else {
|
|
446
|
+
asString = local.host ?? "localhost";
|
|
447
|
+
if (local.protocol) {
|
|
448
|
+
asString = `${local.protocol}://${asString}`;
|
|
449
|
+
}
|
|
450
|
+
if (local.port) {
|
|
451
|
+
asString = `${asString}:${local.port}`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
420
454
|
errors.push(
|
|
421
|
-
`Application '${applicationId}'
|
|
455
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
422
456
|
);
|
|
423
457
|
}
|
|
424
458
|
}
|
|
@@ -482,10 +516,10 @@ var Host = class {
|
|
|
482
516
|
}
|
|
483
517
|
this.local = options?.isLocal;
|
|
484
518
|
}
|
|
485
|
-
static parseUrl(url) {
|
|
519
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
486
520
|
let hostToParse = url;
|
|
487
521
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
488
|
-
hostToParse =
|
|
522
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
489
523
|
}
|
|
490
524
|
const parsed = new URL(hostToParse);
|
|
491
525
|
if (!parsed.hostname) {
|
|
@@ -538,12 +572,39 @@ var LocalHost = class extends Host {
|
|
|
538
572
|
constructor({
|
|
539
573
|
appName,
|
|
540
574
|
localPort,
|
|
541
|
-
|
|
575
|
+
local
|
|
542
576
|
}) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
577
|
+
if (localPort && local) {
|
|
578
|
+
throw new Error(
|
|
579
|
+
`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.`
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
let protocol;
|
|
583
|
+
let host;
|
|
584
|
+
let port;
|
|
585
|
+
if (localPort) {
|
|
586
|
+
port = localPort;
|
|
587
|
+
} else if (typeof local === "number") {
|
|
588
|
+
port = local;
|
|
589
|
+
} else if (typeof local === "string") {
|
|
590
|
+
if (/^\d+$/.test(local)) {
|
|
591
|
+
port = Number.parseInt(local);
|
|
592
|
+
} else {
|
|
593
|
+
const parsed = Host.parseUrl(local, "http");
|
|
594
|
+
protocol = parsed.protocol;
|
|
595
|
+
host = parsed.host;
|
|
596
|
+
port = parsed.port;
|
|
597
|
+
}
|
|
598
|
+
} else if (local) {
|
|
599
|
+
protocol = local.protocol;
|
|
600
|
+
host = local.host;
|
|
601
|
+
port = local.port;
|
|
602
|
+
}
|
|
603
|
+
super({
|
|
604
|
+
protocol: protocol ?? "http",
|
|
605
|
+
host: host ?? "localhost",
|
|
606
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
607
|
+
});
|
|
547
608
|
}
|
|
548
609
|
};
|
|
549
610
|
|
|
@@ -559,7 +620,7 @@ var Application = class {
|
|
|
559
620
|
local: new LocalHost({
|
|
560
621
|
appName: name,
|
|
561
622
|
localPort: app.development?.localPort,
|
|
562
|
-
|
|
623
|
+
local: app.development?.local
|
|
563
624
|
}),
|
|
564
625
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
565
626
|
};
|
|
@@ -569,6 +630,7 @@ var Application = class {
|
|
|
569
630
|
this.fallback = new Host(app.production);
|
|
570
631
|
}
|
|
571
632
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
633
|
+
this.packageName = app.packageName;
|
|
572
634
|
this.overrides = overrides?.environment ? {
|
|
573
635
|
environment: new Host(overrides.environment)
|
|
574
636
|
} : void 0;
|
|
@@ -734,10 +796,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
734
796
|
].filter(Boolean);
|
|
735
797
|
}
|
|
736
798
|
getApplication(name) {
|
|
737
|
-
if (this.defaultApplication?.name === name) {
|
|
799
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
738
800
|
return this.defaultApplication;
|
|
739
801
|
}
|
|
740
|
-
const app = this.childApplications[name]
|
|
802
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
803
|
+
(child) => child.packageName === name
|
|
804
|
+
);
|
|
741
805
|
if (!app) {
|
|
742
806
|
throw new MicrofrontendError(
|
|
743
807
|
`Could not find microfrontends configuration for application "${name}"`,
|