@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
|
@@ -191,17 +191,27 @@ function hasGitDirectory(dir) {
|
|
|
191
191
|
function hasPnpmWorkspaces(dir) {
|
|
192
192
|
return import_node_fs.default.existsSync(import_node_path.default.join(dir, "pnpm-workspace.yaml"));
|
|
193
193
|
}
|
|
194
|
+
function hasPackageJson(dir) {
|
|
195
|
+
return import_node_fs.default.existsSync(import_node_path.default.join(dir, "package.json"));
|
|
196
|
+
}
|
|
194
197
|
function findRepositoryRoot(startDir) {
|
|
195
198
|
if (process.env.NX_WORKSPACE_ROOT) {
|
|
196
199
|
return process.env.NX_WORKSPACE_ROOT;
|
|
197
200
|
}
|
|
198
201
|
let currentDir = startDir || process.cwd();
|
|
202
|
+
let lastPackageJsonDir = null;
|
|
199
203
|
while (currentDir !== import_node_path.default.parse(currentDir).root) {
|
|
200
204
|
if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
|
|
201
205
|
return currentDir;
|
|
202
206
|
}
|
|
207
|
+
if (hasPackageJson(currentDir)) {
|
|
208
|
+
lastPackageJsonDir = currentDir;
|
|
209
|
+
}
|
|
203
210
|
currentDir = import_node_path.default.dirname(currentDir);
|
|
204
211
|
}
|
|
212
|
+
if (lastPackageJsonDir) {
|
|
213
|
+
return lastPackageJsonDir;
|
|
214
|
+
}
|
|
205
215
|
throw new Error(
|
|
206
216
|
`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.`
|
|
207
217
|
);
|
|
@@ -597,33 +607,6 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
597
607
|
);
|
|
598
608
|
}
|
|
599
609
|
};
|
|
600
|
-
var validateDeprecatedFields = (config) => {
|
|
601
|
-
const errors = [];
|
|
602
|
-
for (const [applicationId, application] of Object.entries(
|
|
603
|
-
config.applications
|
|
604
|
-
)) {
|
|
605
|
-
if (application.development?.localPort) {
|
|
606
|
-
errors.push(
|
|
607
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
608
|
-
);
|
|
609
|
-
}
|
|
610
|
-
if (application.projectId) {
|
|
611
|
-
errors.push(
|
|
612
|
-
`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.`
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
if (errors.length) {
|
|
617
|
-
throw new MicrofrontendError(
|
|
618
|
-
`Microfrontends configuration file errors:
|
|
619
|
-
- ${errors.join("\n- ")}`,
|
|
620
|
-
{
|
|
621
|
-
type: "config",
|
|
622
|
-
subtype: "depcrecated_field"
|
|
623
|
-
}
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
610
|
|
|
628
611
|
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
629
612
|
var PREFIX = "vc-ap";
|
|
@@ -728,20 +711,12 @@ var Host = class {
|
|
|
728
711
|
var LocalHost = class extends Host {
|
|
729
712
|
constructor({
|
|
730
713
|
appName,
|
|
731
|
-
localPort,
|
|
732
714
|
local
|
|
733
715
|
}) {
|
|
734
|
-
if (localPort && local) {
|
|
735
|
-
throw new Error(
|
|
736
|
-
`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.`
|
|
737
|
-
);
|
|
738
|
-
}
|
|
739
716
|
let protocol;
|
|
740
717
|
let host;
|
|
741
718
|
let port;
|
|
742
|
-
if (
|
|
743
|
-
port = localPort;
|
|
744
|
-
} else if (typeof local === "number") {
|
|
719
|
+
if (typeof local === "number") {
|
|
745
720
|
port = local;
|
|
746
721
|
} else if (typeof local === "string") {
|
|
747
722
|
if (/^\d+$/.test(local)) {
|
|
@@ -783,7 +758,6 @@ var Application = class {
|
|
|
783
758
|
this.development = {
|
|
784
759
|
local: new LocalHost({
|
|
785
760
|
appName: name,
|
|
786
|
-
localPort: app.development?.localPort,
|
|
787
761
|
local: app.development?.local
|
|
788
762
|
}),
|
|
789
763
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
@@ -791,7 +765,6 @@ var Application = class {
|
|
|
791
765
|
if (app.development?.fallback) {
|
|
792
766
|
this.fallback = new Host(app.development.fallback);
|
|
793
767
|
}
|
|
794
|
-
this.projectId = app.projectId;
|
|
795
768
|
this.packageName = app.packageName;
|
|
796
769
|
this.overrides = overrides?.environment ? {
|
|
797
770
|
environment: new Host(overrides.environment)
|
|
@@ -855,11 +828,10 @@ var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
|
855
828
|
var MicrofrontendConfigIsomorphic = class {
|
|
856
829
|
constructor({
|
|
857
830
|
config,
|
|
858
|
-
overrides
|
|
859
|
-
opts
|
|
831
|
+
overrides
|
|
860
832
|
}) {
|
|
861
833
|
this.childApplications = {};
|
|
862
|
-
MicrofrontendConfigIsomorphic.validate(config
|
|
834
|
+
MicrofrontendConfigIsomorphic.validate(config);
|
|
863
835
|
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
864
836
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
865
837
|
let defaultApplication;
|
|
@@ -894,14 +866,10 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
894
866
|
overrides
|
|
895
867
|
};
|
|
896
868
|
}
|
|
897
|
-
static validate(config
|
|
898
|
-
const skipValidation = opts?.skipValidation ?? [];
|
|
869
|
+
static validate(config) {
|
|
899
870
|
const c = typeof config === "string" ? (0, import_jsonc_parser2.parse)(config) : config;
|
|
900
871
|
validateConfigPaths(c.applications);
|
|
901
872
|
validateConfigDefaultApplication(c.applications);
|
|
902
|
-
if (!skipValidation.includes("deprecatedFields")) {
|
|
903
|
-
validateDeprecatedFields(c);
|
|
904
|
-
}
|
|
905
873
|
return c;
|
|
906
874
|
}
|
|
907
875
|
static fromEnv({
|
|
@@ -1082,7 +1050,9 @@ var schema_default = {
|
|
|
1082
1050
|
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"
|
|
1083
1051
|
}
|
|
1084
1052
|
},
|
|
1085
|
-
required: [
|
|
1053
|
+
required: [
|
|
1054
|
+
"applications"
|
|
1055
|
+
],
|
|
1086
1056
|
additionalProperties: false
|
|
1087
1057
|
},
|
|
1088
1058
|
Options: {
|
|
@@ -1121,11 +1091,6 @@ var schema_default = {
|
|
|
1121
1091
|
DefaultApplication: {
|
|
1122
1092
|
type: "object",
|
|
1123
1093
|
properties: {
|
|
1124
|
-
projectId: {
|
|
1125
|
-
type: "string",
|
|
1126
|
-
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1127
|
-
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)."
|
|
1128
|
-
},
|
|
1129
1094
|
packageName: {
|
|
1130
1095
|
type: "string",
|
|
1131
1096
|
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`."
|
|
@@ -1135,21 +1100,21 @@ var schema_default = {
|
|
|
1135
1100
|
description: "Development configuration for the default application."
|
|
1136
1101
|
}
|
|
1137
1102
|
},
|
|
1138
|
-
required: [
|
|
1103
|
+
required: [
|
|
1104
|
+
"development"
|
|
1105
|
+
],
|
|
1139
1106
|
additionalProperties: false
|
|
1140
1107
|
},
|
|
1141
1108
|
DefaultDevelopment: {
|
|
1142
1109
|
type: "object",
|
|
1143
1110
|
properties: {
|
|
1144
1111
|
local: {
|
|
1145
|
-
type: [
|
|
1112
|
+
type: [
|
|
1113
|
+
"number",
|
|
1114
|
+
"string"
|
|
1115
|
+
],
|
|
1146
1116
|
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"
|
|
1147
1117
|
},
|
|
1148
|
-
localPort: {
|
|
1149
|
-
type: "number",
|
|
1150
|
-
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.",
|
|
1151
|
-
deprecated: "Please set the port with the 'local' field instead."
|
|
1152
|
-
},
|
|
1153
1118
|
task: {
|
|
1154
1119
|
type: "string",
|
|
1155
1120
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
@@ -1159,17 +1124,14 @@ var schema_default = {
|
|
|
1159
1124
|
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."
|
|
1160
1125
|
}
|
|
1161
1126
|
},
|
|
1162
|
-
required: [
|
|
1127
|
+
required: [
|
|
1128
|
+
"fallback"
|
|
1129
|
+
],
|
|
1163
1130
|
additionalProperties: false
|
|
1164
1131
|
},
|
|
1165
1132
|
ChildApplication: {
|
|
1166
1133
|
type: "object",
|
|
1167
1134
|
properties: {
|
|
1168
|
-
projectId: {
|
|
1169
|
-
type: "string",
|
|
1170
|
-
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1171
|
-
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)."
|
|
1172
|
-
},
|
|
1173
1135
|
packageName: {
|
|
1174
1136
|
type: "string",
|
|
1175
1137
|
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`."
|
|
@@ -1183,21 +1145,21 @@ var schema_default = {
|
|
|
1183
1145
|
description: "Groups of path expressions that are routed to this application."
|
|
1184
1146
|
}
|
|
1185
1147
|
},
|
|
1186
|
-
required: [
|
|
1148
|
+
required: [
|
|
1149
|
+
"routing"
|
|
1150
|
+
],
|
|
1187
1151
|
additionalProperties: false
|
|
1188
1152
|
},
|
|
1189
1153
|
ChildDevelopment: {
|
|
1190
1154
|
type: "object",
|
|
1191
1155
|
properties: {
|
|
1192
1156
|
local: {
|
|
1193
|
-
type: [
|
|
1157
|
+
type: [
|
|
1158
|
+
"number",
|
|
1159
|
+
"string"
|
|
1160
|
+
],
|
|
1194
1161
|
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"
|
|
1195
1162
|
},
|
|
1196
|
-
localPort: {
|
|
1197
|
-
type: "number",
|
|
1198
|
-
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.",
|
|
1199
|
-
deprecated: "Please set the port with the 'local' field instead."
|
|
1200
|
-
},
|
|
1201
1163
|
task: {
|
|
1202
1164
|
type: "string",
|
|
1203
1165
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
@@ -1233,7 +1195,9 @@ var schema_default = {
|
|
|
1233
1195
|
}
|
|
1234
1196
|
}
|
|
1235
1197
|
},
|
|
1236
|
-
required: [
|
|
1198
|
+
required: [
|
|
1199
|
+
"paths"
|
|
1200
|
+
],
|
|
1237
1201
|
additionalProperties: false
|
|
1238
1202
|
}
|
|
1239
1203
|
}
|