@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/next/config.js
CHANGED
|
@@ -172,17 +172,27 @@ function hasGitDirectory(dir) {
|
|
|
172
172
|
function hasPnpmWorkspaces(dir) {
|
|
173
173
|
return fs.existsSync(path.join(dir, "pnpm-workspace.yaml"));
|
|
174
174
|
}
|
|
175
|
+
function hasPackageJson(dir) {
|
|
176
|
+
return fs.existsSync(path.join(dir, "package.json"));
|
|
177
|
+
}
|
|
175
178
|
function findRepositoryRoot(startDir) {
|
|
176
179
|
if (process.env.NX_WORKSPACE_ROOT) {
|
|
177
180
|
return process.env.NX_WORKSPACE_ROOT;
|
|
178
181
|
}
|
|
179
182
|
let currentDir = startDir || process.cwd();
|
|
183
|
+
let lastPackageJsonDir = null;
|
|
180
184
|
while (currentDir !== path.parse(currentDir).root) {
|
|
181
185
|
if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
|
|
182
186
|
return currentDir;
|
|
183
187
|
}
|
|
188
|
+
if (hasPackageJson(currentDir)) {
|
|
189
|
+
lastPackageJsonDir = currentDir;
|
|
190
|
+
}
|
|
184
191
|
currentDir = path.dirname(currentDir);
|
|
185
192
|
}
|
|
193
|
+
if (lastPackageJsonDir) {
|
|
194
|
+
return lastPackageJsonDir;
|
|
195
|
+
}
|
|
186
196
|
throw new Error(
|
|
187
197
|
`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.`
|
|
188
198
|
);
|
|
@@ -578,33 +588,6 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
578
588
|
);
|
|
579
589
|
}
|
|
580
590
|
};
|
|
581
|
-
var validateDeprecatedFields = (config) => {
|
|
582
|
-
const errors = [];
|
|
583
|
-
for (const [applicationId, application] of Object.entries(
|
|
584
|
-
config.applications
|
|
585
|
-
)) {
|
|
586
|
-
if (application.development?.localPort) {
|
|
587
|
-
errors.push(
|
|
588
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
if (application.projectId) {
|
|
592
|
-
errors.push(
|
|
593
|
-
`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.`
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
if (errors.length) {
|
|
598
|
-
throw new MicrofrontendError(
|
|
599
|
-
`Microfrontends configuration file errors:
|
|
600
|
-
- ${errors.join("\n- ")}`,
|
|
601
|
-
{
|
|
602
|
-
type: "config",
|
|
603
|
-
subtype: "depcrecated_field"
|
|
604
|
-
}
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
591
|
|
|
609
592
|
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
610
593
|
var PREFIX = "vc-ap";
|
|
@@ -709,20 +692,12 @@ var Host = class {
|
|
|
709
692
|
var LocalHost = class extends Host {
|
|
710
693
|
constructor({
|
|
711
694
|
appName,
|
|
712
|
-
localPort,
|
|
713
695
|
local
|
|
714
696
|
}) {
|
|
715
|
-
if (localPort && local) {
|
|
716
|
-
throw new Error(
|
|
717
|
-
`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.`
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
697
|
let protocol;
|
|
721
698
|
let host;
|
|
722
699
|
let port;
|
|
723
|
-
if (
|
|
724
|
-
port = localPort;
|
|
725
|
-
} else if (typeof local === "number") {
|
|
700
|
+
if (typeof local === "number") {
|
|
726
701
|
port = local;
|
|
727
702
|
} else if (typeof local === "string") {
|
|
728
703
|
if (/^\d+$/.test(local)) {
|
|
@@ -764,7 +739,6 @@ var Application = class {
|
|
|
764
739
|
this.development = {
|
|
765
740
|
local: new LocalHost({
|
|
766
741
|
appName: name,
|
|
767
|
-
localPort: app.development?.localPort,
|
|
768
742
|
local: app.development?.local
|
|
769
743
|
}),
|
|
770
744
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
@@ -772,7 +746,6 @@ var Application = class {
|
|
|
772
746
|
if (app.development?.fallback) {
|
|
773
747
|
this.fallback = new Host(app.development.fallback);
|
|
774
748
|
}
|
|
775
|
-
this.projectId = app.projectId;
|
|
776
749
|
this.packageName = app.packageName;
|
|
777
750
|
this.overrides = overrides?.environment ? {
|
|
778
751
|
environment: new Host(overrides.environment)
|
|
@@ -836,11 +809,10 @@ var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
|
836
809
|
var MicrofrontendConfigIsomorphic = class {
|
|
837
810
|
constructor({
|
|
838
811
|
config,
|
|
839
|
-
overrides
|
|
840
|
-
opts
|
|
812
|
+
overrides
|
|
841
813
|
}) {
|
|
842
814
|
this.childApplications = {};
|
|
843
|
-
MicrofrontendConfigIsomorphic.validate(config
|
|
815
|
+
MicrofrontendConfigIsomorphic.validate(config);
|
|
844
816
|
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
845
817
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
846
818
|
let defaultApplication;
|
|
@@ -875,14 +847,10 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
875
847
|
overrides
|
|
876
848
|
};
|
|
877
849
|
}
|
|
878
|
-
static validate(config
|
|
879
|
-
const skipValidation = opts?.skipValidation ?? [];
|
|
850
|
+
static validate(config) {
|
|
880
851
|
const c = typeof config === "string" ? parse2(config) : config;
|
|
881
852
|
validateConfigPaths(c.applications);
|
|
882
853
|
validateConfigDefaultApplication(c.applications);
|
|
883
|
-
if (!skipValidation.includes("deprecatedFields")) {
|
|
884
|
-
validateDeprecatedFields(c);
|
|
885
|
-
}
|
|
886
854
|
return c;
|
|
887
855
|
}
|
|
888
856
|
static fromEnv({
|
|
@@ -1063,7 +1031,9 @@ var schema_default = {
|
|
|
1063
1031
|
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"
|
|
1064
1032
|
}
|
|
1065
1033
|
},
|
|
1066
|
-
required: [
|
|
1034
|
+
required: [
|
|
1035
|
+
"applications"
|
|
1036
|
+
],
|
|
1067
1037
|
additionalProperties: false
|
|
1068
1038
|
},
|
|
1069
1039
|
Options: {
|
|
@@ -1102,11 +1072,6 @@ var schema_default = {
|
|
|
1102
1072
|
DefaultApplication: {
|
|
1103
1073
|
type: "object",
|
|
1104
1074
|
properties: {
|
|
1105
|
-
projectId: {
|
|
1106
|
-
type: "string",
|
|
1107
|
-
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1108
|
-
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)."
|
|
1109
|
-
},
|
|
1110
1075
|
packageName: {
|
|
1111
1076
|
type: "string",
|
|
1112
1077
|
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`."
|
|
@@ -1116,21 +1081,21 @@ var schema_default = {
|
|
|
1116
1081
|
description: "Development configuration for the default application."
|
|
1117
1082
|
}
|
|
1118
1083
|
},
|
|
1119
|
-
required: [
|
|
1084
|
+
required: [
|
|
1085
|
+
"development"
|
|
1086
|
+
],
|
|
1120
1087
|
additionalProperties: false
|
|
1121
1088
|
},
|
|
1122
1089
|
DefaultDevelopment: {
|
|
1123
1090
|
type: "object",
|
|
1124
1091
|
properties: {
|
|
1125
1092
|
local: {
|
|
1126
|
-
type: [
|
|
1093
|
+
type: [
|
|
1094
|
+
"number",
|
|
1095
|
+
"string"
|
|
1096
|
+
],
|
|
1127
1097
|
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"
|
|
1128
1098
|
},
|
|
1129
|
-
localPort: {
|
|
1130
|
-
type: "number",
|
|
1131
|
-
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.",
|
|
1132
|
-
deprecated: "Please set the port with the 'local' field instead."
|
|
1133
|
-
},
|
|
1134
1099
|
task: {
|
|
1135
1100
|
type: "string",
|
|
1136
1101
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
@@ -1140,17 +1105,14 @@ var schema_default = {
|
|
|
1140
1105
|
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."
|
|
1141
1106
|
}
|
|
1142
1107
|
},
|
|
1143
|
-
required: [
|
|
1108
|
+
required: [
|
|
1109
|
+
"fallback"
|
|
1110
|
+
],
|
|
1144
1111
|
additionalProperties: false
|
|
1145
1112
|
},
|
|
1146
1113
|
ChildApplication: {
|
|
1147
1114
|
type: "object",
|
|
1148
1115
|
properties: {
|
|
1149
|
-
projectId: {
|
|
1150
|
-
type: "string",
|
|
1151
|
-
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1152
|
-
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)."
|
|
1153
|
-
},
|
|
1154
1116
|
packageName: {
|
|
1155
1117
|
type: "string",
|
|
1156
1118
|
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`."
|
|
@@ -1164,21 +1126,21 @@ var schema_default = {
|
|
|
1164
1126
|
description: "Groups of path expressions that are routed to this application."
|
|
1165
1127
|
}
|
|
1166
1128
|
},
|
|
1167
|
-
required: [
|
|
1129
|
+
required: [
|
|
1130
|
+
"routing"
|
|
1131
|
+
],
|
|
1168
1132
|
additionalProperties: false
|
|
1169
1133
|
},
|
|
1170
1134
|
ChildDevelopment: {
|
|
1171
1135
|
type: "object",
|
|
1172
1136
|
properties: {
|
|
1173
1137
|
local: {
|
|
1174
|
-
type: [
|
|
1138
|
+
type: [
|
|
1139
|
+
"number",
|
|
1140
|
+
"string"
|
|
1141
|
+
],
|
|
1175
1142
|
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"
|
|
1176
1143
|
},
|
|
1177
|
-
localPort: {
|
|
1178
|
-
type: "number",
|
|
1179
|
-
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.",
|
|
1180
|
-
deprecated: "Please set the port with the 'local' field instead."
|
|
1181
|
-
},
|
|
1182
1144
|
task: {
|
|
1183
1145
|
type: "string",
|
|
1184
1146
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
@@ -1214,7 +1176,9 @@ var schema_default = {
|
|
|
1214
1176
|
}
|
|
1215
1177
|
}
|
|
1216
1178
|
},
|
|
1217
|
-
required: [
|
|
1179
|
+
required: [
|
|
1180
|
+
"paths"
|
|
1181
|
+
],
|
|
1218
1182
|
additionalProperties: false
|
|
1219
1183
|
}
|
|
1220
1184
|
}
|
|
@@ -1509,6 +1473,10 @@ function transform(args) {
|
|
|
1509
1473
|
);
|
|
1510
1474
|
}
|
|
1511
1475
|
next.assetPrefix = assetPrefix;
|
|
1476
|
+
next.images = {
|
|
1477
|
+
...next.images,
|
|
1478
|
+
path: `${assetPrefix}/_next/image`
|
|
1479
|
+
};
|
|
1512
1480
|
return {
|
|
1513
1481
|
next
|
|
1514
1482
|
};
|