@vercel/microfrontends 1.4.1 → 1.5.0-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/CHANGELOG.md +14 -0
- package/dist/bin/cli.cjs +38 -74
- package/dist/config.cjs +4 -46
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +5 -11
- package/dist/config.js +4 -46
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +37 -73
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +37 -73
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +37 -73
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +37 -73
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +37 -73
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +2 -2
- package/dist/microfrontends/server.js +37 -73
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/next/config.cjs +41 -73
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +41 -73
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +4 -46
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +4 -46
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +4 -46
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +2 -2
- package/dist/next/testing.js +4 -46
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.d.ts +2 -2
- package/dist/{types-ab31c948.d.ts → types-1cec43e6.d.ts} +0 -15
- package/dist/{types-d3cb74a6.d.ts → types-1fb60496.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +37 -73
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +37 -73
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +23 -27
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +23 -27
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/schema/schema.json +0 -20
package/dist/utils/mfe-port.cjs
CHANGED
|
@@ -193,17 +193,27 @@ function hasGitDirectory(dir) {
|
|
|
193
193
|
function hasPnpmWorkspaces(dir) {
|
|
194
194
|
return import_node_fs.default.existsSync(import_node_path.default.join(dir, "pnpm-workspace.yaml"));
|
|
195
195
|
}
|
|
196
|
+
function hasPackageJson(dir) {
|
|
197
|
+
return import_node_fs.default.existsSync(import_node_path.default.join(dir, "package.json"));
|
|
198
|
+
}
|
|
196
199
|
function findRepositoryRoot(startDir) {
|
|
197
200
|
if (process.env.NX_WORKSPACE_ROOT) {
|
|
198
201
|
return process.env.NX_WORKSPACE_ROOT;
|
|
199
202
|
}
|
|
200
203
|
let currentDir = startDir || process.cwd();
|
|
204
|
+
let lastPackageJsonDir = null;
|
|
201
205
|
while (currentDir !== import_node_path.default.parse(currentDir).root) {
|
|
202
206
|
if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
|
|
203
207
|
return currentDir;
|
|
204
208
|
}
|
|
209
|
+
if (hasPackageJson(currentDir)) {
|
|
210
|
+
lastPackageJsonDir = currentDir;
|
|
211
|
+
}
|
|
205
212
|
currentDir = import_node_path.default.dirname(currentDir);
|
|
206
213
|
}
|
|
214
|
+
if (lastPackageJsonDir) {
|
|
215
|
+
return lastPackageJsonDir;
|
|
216
|
+
}
|
|
207
217
|
throw new Error(
|
|
208
218
|
`Could not find the root of the repository for ${startDir}. Please ensure that the directory is part of a Git repository. If you suspect that this should work, please file an issue to the Vercel team.`
|
|
209
219
|
);
|
|
@@ -599,33 +609,6 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
599
609
|
);
|
|
600
610
|
}
|
|
601
611
|
};
|
|
602
|
-
var validateDeprecatedFields = (config) => {
|
|
603
|
-
const errors = [];
|
|
604
|
-
for (const [applicationId, application] of Object.entries(
|
|
605
|
-
config.applications
|
|
606
|
-
)) {
|
|
607
|
-
if (application.development?.localPort) {
|
|
608
|
-
errors.push(
|
|
609
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
if (application.projectId) {
|
|
613
|
-
errors.push(
|
|
614
|
-
`Application '${applicationId}' cannot contain deprecated field 'projectId'. If the application ID matches the Vercel project name, then please remove the 'projectId' field. Otherwise, either update the application ID / Vercel project name to match, or set the 'packageName' field to the name of the package.json name.`
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
if (errors.length) {
|
|
619
|
-
throw new MicrofrontendError(
|
|
620
|
-
`Microfrontends configuration file errors:
|
|
621
|
-
- ${errors.join("\n- ")}`,
|
|
622
|
-
{
|
|
623
|
-
type: "config",
|
|
624
|
-
subtype: "depcrecated_field"
|
|
625
|
-
}
|
|
626
|
-
);
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
612
|
|
|
630
613
|
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
631
614
|
var PREFIX = "vc-ap";
|
|
@@ -730,20 +713,12 @@ var Host = class {
|
|
|
730
713
|
var LocalHost = class extends Host {
|
|
731
714
|
constructor({
|
|
732
715
|
appName,
|
|
733
|
-
localPort,
|
|
734
716
|
local
|
|
735
717
|
}) {
|
|
736
|
-
if (localPort && local) {
|
|
737
|
-
throw new Error(
|
|
738
|
-
`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.`
|
|
739
|
-
);
|
|
740
|
-
}
|
|
741
718
|
let protocol;
|
|
742
719
|
let host;
|
|
743
720
|
let port;
|
|
744
|
-
if (
|
|
745
|
-
port = localPort;
|
|
746
|
-
} else if (typeof local === "number") {
|
|
721
|
+
if (typeof local === "number") {
|
|
747
722
|
port = local;
|
|
748
723
|
} else if (typeof local === "string") {
|
|
749
724
|
if (/^\d+$/.test(local)) {
|
|
@@ -785,7 +760,6 @@ var Application = class {
|
|
|
785
760
|
this.development = {
|
|
786
761
|
local: new LocalHost({
|
|
787
762
|
appName: name,
|
|
788
|
-
localPort: app.development?.localPort,
|
|
789
763
|
local: app.development?.local
|
|
790
764
|
}),
|
|
791
765
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
@@ -793,7 +767,6 @@ var Application = class {
|
|
|
793
767
|
if (app.development?.fallback) {
|
|
794
768
|
this.fallback = new Host(app.development.fallback);
|
|
795
769
|
}
|
|
796
|
-
this.projectId = app.projectId;
|
|
797
770
|
this.packageName = app.packageName;
|
|
798
771
|
this.overrides = overrides?.environment ? {
|
|
799
772
|
environment: new Host(overrides.environment)
|
|
@@ -857,11 +830,10 @@ var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
|
857
830
|
var MicrofrontendConfigIsomorphic = class {
|
|
858
831
|
constructor({
|
|
859
832
|
config,
|
|
860
|
-
overrides
|
|
861
|
-
opts
|
|
833
|
+
overrides
|
|
862
834
|
}) {
|
|
863
835
|
this.childApplications = {};
|
|
864
|
-
MicrofrontendConfigIsomorphic.validate(config
|
|
836
|
+
MicrofrontendConfigIsomorphic.validate(config);
|
|
865
837
|
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
866
838
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
867
839
|
let defaultApplication;
|
|
@@ -896,14 +868,10 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
896
868
|
overrides
|
|
897
869
|
};
|
|
898
870
|
}
|
|
899
|
-
static validate(config
|
|
900
|
-
const skipValidation = opts?.skipValidation ?? [];
|
|
871
|
+
static validate(config) {
|
|
901
872
|
const c = typeof config === "string" ? (0, import_jsonc_parser2.parse)(config) : config;
|
|
902
873
|
validateConfigPaths(c.applications);
|
|
903
874
|
validateConfigDefaultApplication(c.applications);
|
|
904
|
-
if (!skipValidation.includes("deprecatedFields")) {
|
|
905
|
-
validateDeprecatedFields(c);
|
|
906
|
-
}
|
|
907
875
|
return c;
|
|
908
876
|
}
|
|
909
877
|
static fromEnv({
|
|
@@ -1084,7 +1052,9 @@ var schema_default = {
|
|
|
1084
1052
|
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"
|
|
1085
1053
|
}
|
|
1086
1054
|
},
|
|
1087
|
-
required: [
|
|
1055
|
+
required: [
|
|
1056
|
+
"applications"
|
|
1057
|
+
],
|
|
1088
1058
|
additionalProperties: false
|
|
1089
1059
|
},
|
|
1090
1060
|
Options: {
|
|
@@ -1123,11 +1093,6 @@ var schema_default = {
|
|
|
1123
1093
|
DefaultApplication: {
|
|
1124
1094
|
type: "object",
|
|
1125
1095
|
properties: {
|
|
1126
|
-
projectId: {
|
|
1127
|
-
type: "string",
|
|
1128
|
-
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1129
|
-
deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
|
|
1130
|
-
},
|
|
1131
1096
|
packageName: {
|
|
1132
1097
|
type: "string",
|
|
1133
1098
|
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`."
|
|
@@ -1137,21 +1102,21 @@ var schema_default = {
|
|
|
1137
1102
|
description: "Development configuration for the default application."
|
|
1138
1103
|
}
|
|
1139
1104
|
},
|
|
1140
|
-
required: [
|
|
1105
|
+
required: [
|
|
1106
|
+
"development"
|
|
1107
|
+
],
|
|
1141
1108
|
additionalProperties: false
|
|
1142
1109
|
},
|
|
1143
1110
|
DefaultDevelopment: {
|
|
1144
1111
|
type: "object",
|
|
1145
1112
|
properties: {
|
|
1146
1113
|
local: {
|
|
1147
|
-
type: [
|
|
1114
|
+
type: [
|
|
1115
|
+
"number",
|
|
1116
|
+
"string"
|
|
1117
|
+
],
|
|
1148
1118
|
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"
|
|
1149
1119
|
},
|
|
1150
|
-
localPort: {
|
|
1151
|
-
type: "number",
|
|
1152
|
-
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.",
|
|
1153
|
-
deprecated: "Please set the port with the 'local' field instead."
|
|
1154
|
-
},
|
|
1155
1120
|
task: {
|
|
1156
1121
|
type: "string",
|
|
1157
1122
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
@@ -1161,17 +1126,14 @@ var schema_default = {
|
|
|
1161
1126
|
description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\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."
|
|
1162
1127
|
}
|
|
1163
1128
|
},
|
|
1164
|
-
required: [
|
|
1129
|
+
required: [
|
|
1130
|
+
"fallback"
|
|
1131
|
+
],
|
|
1165
1132
|
additionalProperties: false
|
|
1166
1133
|
},
|
|
1167
1134
|
ChildApplication: {
|
|
1168
1135
|
type: "object",
|
|
1169
1136
|
properties: {
|
|
1170
|
-
projectId: {
|
|
1171
|
-
type: "string",
|
|
1172
|
-
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1173
|
-
deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
|
|
1174
|
-
},
|
|
1175
1137
|
packageName: {
|
|
1176
1138
|
type: "string",
|
|
1177
1139
|
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`."
|
|
@@ -1185,21 +1147,21 @@ var schema_default = {
|
|
|
1185
1147
|
description: "Groups of path expressions that are routed to this application."
|
|
1186
1148
|
}
|
|
1187
1149
|
},
|
|
1188
|
-
required: [
|
|
1150
|
+
required: [
|
|
1151
|
+
"routing"
|
|
1152
|
+
],
|
|
1189
1153
|
additionalProperties: false
|
|
1190
1154
|
},
|
|
1191
1155
|
ChildDevelopment: {
|
|
1192
1156
|
type: "object",
|
|
1193
1157
|
properties: {
|
|
1194
1158
|
local: {
|
|
1195
|
-
type: [
|
|
1159
|
+
type: [
|
|
1160
|
+
"number",
|
|
1161
|
+
"string"
|
|
1162
|
+
],
|
|
1196
1163
|
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"
|
|
1197
1164
|
},
|
|
1198
|
-
localPort: {
|
|
1199
|
-
type: "number",
|
|
1200
|
-
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.",
|
|
1201
|
-
deprecated: "Please set the port with the 'local' field instead."
|
|
1202
|
-
},
|
|
1203
1165
|
task: {
|
|
1204
1166
|
type: "string",
|
|
1205
1167
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
@@ -1235,7 +1197,9 @@ var schema_default = {
|
|
|
1235
1197
|
}
|
|
1236
1198
|
}
|
|
1237
1199
|
},
|
|
1238
|
-
required: [
|
|
1200
|
+
required: [
|
|
1201
|
+
"paths"
|
|
1202
|
+
],
|
|
1239
1203
|
additionalProperties: false
|
|
1240
1204
|
}
|
|
1241
1205
|
}
|