@vercel/microfrontends 1.1.1-canary.3 → 1.1.1-canary.4
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 +225 -493
- package/dist/config.cjs +27 -62
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +153 -4
- package/dist/config.js +27 -62
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +228 -480
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +218 -470
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +258 -502
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +244 -488
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +227 -476
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +14 -20
- package/dist/microfrontends/server.js +217 -466
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/next/config.cjs +229 -489
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +219 -479
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/middleware.cjs +42 -162
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +2 -4
- package/dist/next/middleware.js +42 -162
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +28 -64
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +28 -64
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.cjs +2 -9
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +3 -4
- package/dist/schema.js +1 -7
- package/dist/schema.js.map +1 -1
- package/dist/{types-6ee19ccc.d.ts → types-54064641.d.ts} +2 -13
- package/dist/{types-73527280.d.ts → types-a4add5ab.d.ts} +1 -1
- package/dist/{types-74e3336c.d.ts → types-f1260e44.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +232 -483
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +218 -469
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +0 -31
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +0 -31
- package/dist/validation.js.map +1 -1
- package/package.json +1 -8
- package/schema/schema.json +0 -33
- package/dist/index-7e69650e.d.ts +0 -165
- package/dist/microfrontends.cjs +0 -969
- package/dist/microfrontends.cjs.map +0 -1
- package/dist/microfrontends.d.ts +0 -45
- package/dist/microfrontends.js +0 -942
- package/dist/microfrontends.js.map +0 -1
package/dist/next/endpoints.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextApiResponse } from 'next';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
|
-
import { C as ClientConfig } from '../types-
|
|
4
|
-
import '../types-
|
|
3
|
+
import { C as ClientConfig } from '../types-f1260e44.js';
|
|
4
|
+
import '../types-54064641.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Data that is returned from the `.well-known/vercel/microfrontends/client-config`
|
package/dist/next/middleware.cjs
CHANGED
|
@@ -29,6 +29,12 @@ module.exports = __toCommonJS(middleware_exports);
|
|
|
29
29
|
var import_server = require("next/server");
|
|
30
30
|
var import_path_to_regexp3 = require("path-to-regexp");
|
|
31
31
|
|
|
32
|
+
// src/next/utils/route-to-local-proxy.ts
|
|
33
|
+
function routeToLocalProxy() {
|
|
34
|
+
const isDevEnv = (process.env.VERCEL_ENV ?? "development") === "development";
|
|
35
|
+
return isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY);
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
// src/config/microfrontends-config/isomorphic/index.ts
|
|
33
39
|
var import_jsonc_parser = require("jsonc-parser");
|
|
34
40
|
|
|
@@ -136,11 +142,6 @@ function getConfigStringFromEnv() {
|
|
|
136
142
|
return config;
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
// src/config/schema/utils/is-main-config.ts
|
|
140
|
-
function isMainConfig(c) {
|
|
141
|
-
return !("partOf" in c);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
145
|
// src/config/schema/utils/is-default-app.ts
|
|
145
146
|
function isDefaultApp(a) {
|
|
146
147
|
return !("routing" in a);
|
|
@@ -714,42 +715,28 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
714
715
|
constructor({
|
|
715
716
|
config,
|
|
716
717
|
overrides,
|
|
717
|
-
meta,
|
|
718
718
|
opts
|
|
719
719
|
}) {
|
|
720
720
|
this.childApplications = {};
|
|
721
721
|
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
722
722
|
const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
|
|
723
723
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
app: appConfig,
|
|
731
|
-
overrides: appOverrides
|
|
732
|
-
});
|
|
733
|
-
} else {
|
|
734
|
-
this.childApplications[appId] = new ChildApplication(appId, {
|
|
735
|
-
app: appConfig,
|
|
736
|
-
overrides: appOverrides
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
} else {
|
|
741
|
-
this.partOf = config.partOf;
|
|
742
|
-
const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
|
|
743
|
-
this.childApplications[meta.fromApp] = new ChildApplication(
|
|
744
|
-
meta.fromApp,
|
|
745
|
-
{
|
|
746
|
-
// we don't know routing because we're not in the main config
|
|
747
|
-
app: { routing: [] },
|
|
724
|
+
let defaultApplication;
|
|
725
|
+
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
726
|
+
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
727
|
+
if (isDefaultApp(appConfig)) {
|
|
728
|
+
defaultApplication = new DefaultApplication(appId, {
|
|
729
|
+
app: appConfig,
|
|
748
730
|
overrides: appOverrides
|
|
749
|
-
}
|
|
750
|
-
|
|
731
|
+
});
|
|
732
|
+
} else {
|
|
733
|
+
this.childApplications[appId] = new ChildApplication(appId, {
|
|
734
|
+
app: appConfig,
|
|
735
|
+
overrides: appOverrides
|
|
736
|
+
});
|
|
737
|
+
}
|
|
751
738
|
}
|
|
752
|
-
if (
|
|
739
|
+
if (!defaultApplication) {
|
|
753
740
|
throw new MicrofrontendError(
|
|
754
741
|
"Could not find default application in microfrontends configuration",
|
|
755
742
|
{
|
|
@@ -758,34 +745,30 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
758
745
|
}
|
|
759
746
|
);
|
|
760
747
|
}
|
|
748
|
+
this.defaultApplication = defaultApplication;
|
|
761
749
|
this.config = config;
|
|
762
750
|
this.options = config.options;
|
|
763
751
|
this.serialized = {
|
|
764
752
|
config,
|
|
765
|
-
overrides
|
|
766
|
-
meta
|
|
753
|
+
overrides
|
|
767
754
|
};
|
|
768
755
|
}
|
|
769
756
|
static validate(config, opts) {
|
|
770
757
|
const skipValidation = opts?.skipValidation ?? [];
|
|
771
758
|
const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
validateDeprecatedFields(c);
|
|
777
|
-
}
|
|
759
|
+
validateConfigPaths(c.applications);
|
|
760
|
+
validateConfigDefaultApplication(c.applications);
|
|
761
|
+
if (!skipValidation.includes("deprecatedFields")) {
|
|
762
|
+
validateDeprecatedFields(c);
|
|
778
763
|
}
|
|
779
764
|
return c;
|
|
780
765
|
}
|
|
781
766
|
static fromEnv({
|
|
782
|
-
meta,
|
|
783
767
|
cookies
|
|
784
768
|
}) {
|
|
785
769
|
return new MicrofrontendConfigIsomorphic({
|
|
786
770
|
config: (0, import_jsonc_parser.parse)(getConfigStringFromEnv()),
|
|
787
|
-
overrides: parseOverrides(cookies ?? [])
|
|
788
|
-
meta
|
|
771
|
+
overrides: parseOverrides(cookies ?? [])
|
|
789
772
|
});
|
|
790
773
|
}
|
|
791
774
|
isOverridesDisabled() {
|
|
@@ -810,7 +793,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
810
793
|
].filter(Boolean);
|
|
811
794
|
}
|
|
812
795
|
getApplication(name) {
|
|
813
|
-
if (this.defaultApplication
|
|
796
|
+
if (this.defaultApplication.name === name || this.defaultApplication.packageName === name) {
|
|
814
797
|
return this.defaultApplication;
|
|
815
798
|
}
|
|
816
799
|
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
@@ -828,7 +811,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
828
811
|
return app;
|
|
829
812
|
}
|
|
830
813
|
getApplicationByProjectId(projectId) {
|
|
831
|
-
if (this.defaultApplication
|
|
814
|
+
if (this.defaultApplication.projectId === projectId) {
|
|
832
815
|
return this.defaultApplication;
|
|
833
816
|
}
|
|
834
817
|
return Object.values(this.childApplications).find(
|
|
@@ -836,19 +819,9 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
836
819
|
);
|
|
837
820
|
}
|
|
838
821
|
/**
|
|
839
|
-
* Returns the default application.
|
|
840
|
-
* is undefined ( )
|
|
822
|
+
* Returns the default application.
|
|
841
823
|
*/
|
|
842
824
|
getDefaultApplication() {
|
|
843
|
-
if (!this.defaultApplication) {
|
|
844
|
-
throw new MicrofrontendError(
|
|
845
|
-
"Could not find default application in microfrontends configuration",
|
|
846
|
-
{
|
|
847
|
-
type: "application",
|
|
848
|
-
subtype: "not_found"
|
|
849
|
-
}
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
825
|
return this.defaultApplication;
|
|
853
826
|
}
|
|
854
827
|
/**
|
|
@@ -875,11 +848,9 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
875
848
|
}
|
|
876
849
|
])
|
|
877
850
|
);
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
};
|
|
882
|
-
}
|
|
851
|
+
applications[this.defaultApplication.name] = {
|
|
852
|
+
default: true
|
|
853
|
+
};
|
|
883
854
|
return new MicrofrontendConfigClient({
|
|
884
855
|
applications
|
|
885
856
|
});
|
|
@@ -889,97 +860,13 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
889
860
|
}
|
|
890
861
|
};
|
|
891
862
|
|
|
892
|
-
// src/config/microfrontends-config/isomorphic/child.ts
|
|
893
|
-
var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
894
|
-
constructor({
|
|
895
|
-
config,
|
|
896
|
-
overrides,
|
|
897
|
-
meta
|
|
898
|
-
}) {
|
|
899
|
-
super({ config, overrides, meta });
|
|
900
|
-
this.isMainConfig = false;
|
|
901
|
-
this.partOf = config.partOf;
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
// src/config/microfrontends-config/isomorphic/main.ts
|
|
906
|
-
var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
907
|
-
constructor({
|
|
908
|
-
config,
|
|
909
|
-
overrides,
|
|
910
|
-
meta
|
|
911
|
-
}) {
|
|
912
|
-
super({ config, overrides, meta });
|
|
913
|
-
this.isMainConfig = true;
|
|
914
|
-
const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
|
|
915
|
-
let defaultApplication;
|
|
916
|
-
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
917
|
-
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
918
|
-
if (isDefaultApp(appConfig)) {
|
|
919
|
-
defaultApplication = new DefaultApplication(appId, {
|
|
920
|
-
app: appConfig,
|
|
921
|
-
overrides: appOverrides
|
|
922
|
-
});
|
|
923
|
-
} else {
|
|
924
|
-
this.childApplications[appId] = new ChildApplication(appId, {
|
|
925
|
-
app: appConfig,
|
|
926
|
-
overrides: appOverrides
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
if (!defaultApplication) {
|
|
931
|
-
throw new MicrofrontendError(
|
|
932
|
-
"Could not find default application in microfrontends configuration",
|
|
933
|
-
{
|
|
934
|
-
type: "application",
|
|
935
|
-
subtype: "not_found"
|
|
936
|
-
}
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
|
-
this.defaultApplication = defaultApplication;
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
// src/config/microfrontends/isomorphic/index.ts
|
|
944
|
-
var Microfrontends = class {
|
|
945
|
-
constructor({
|
|
946
|
-
config,
|
|
947
|
-
overrides,
|
|
948
|
-
meta
|
|
949
|
-
}) {
|
|
950
|
-
if (isMainConfig(config)) {
|
|
951
|
-
this.config = new MicrofrontendMainConfig({ config, overrides, meta });
|
|
952
|
-
} else {
|
|
953
|
-
this.config = new MicrofrontendChildConfig({ config, overrides, meta });
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
isChildConfig() {
|
|
957
|
-
return this.config instanceof MicrofrontendChildConfig;
|
|
958
|
-
}
|
|
959
|
-
static fromEnv({
|
|
960
|
-
cookies,
|
|
961
|
-
meta
|
|
962
|
-
}) {
|
|
963
|
-
const config = MicrofrontendConfigIsomorphic.fromEnv({
|
|
964
|
-
cookies,
|
|
965
|
-
meta
|
|
966
|
-
});
|
|
967
|
-
return new Microfrontends(config.serialize());
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
|
|
971
|
-
// src/next/utils/route-to-local-proxy.ts
|
|
972
|
-
function routeToLocalProxy() {
|
|
973
|
-
const isDevEnv = (process.env.VERCEL_ENV ?? "development") === "development";
|
|
974
|
-
return isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
863
|
// src/next/middleware/middleware.ts
|
|
978
864
|
function getMfeFlagHeader(req) {
|
|
979
865
|
const flagValue = req.headers.get("x-vercel-mfe-flag-value");
|
|
980
866
|
if (flagValue === "true") {
|
|
981
867
|
return true;
|
|
982
|
-
}
|
|
868
|
+
}
|
|
869
|
+
if (flagValue === "false") {
|
|
983
870
|
return false;
|
|
984
871
|
}
|
|
985
872
|
return null;
|
|
@@ -1031,28 +918,23 @@ function getFlagHandler({
|
|
|
1031
918
|
}
|
|
1032
919
|
function getMicrofrontendsMiddleware({
|
|
1033
920
|
request,
|
|
1034
|
-
flagValues
|
|
1035
|
-
fromApp
|
|
921
|
+
flagValues
|
|
1036
922
|
}) {
|
|
1037
|
-
const microfrontends =
|
|
1038
|
-
cookies: request.cookies.getAll()
|
|
1039
|
-
meta: {
|
|
1040
|
-
fromApp
|
|
1041
|
-
}
|
|
923
|
+
const microfrontends = MicrofrontendConfigIsomorphic.fromEnv({
|
|
924
|
+
cookies: request.cookies.getAll()
|
|
1042
925
|
});
|
|
1043
926
|
const middlewares = [];
|
|
1044
927
|
if (!process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION) {
|
|
1045
928
|
throw new Error("NEXT_PUBLIC_MFE_CURRENT_APPLICATION is not set");
|
|
1046
929
|
}
|
|
1047
|
-
const currentApplication = microfrontends.
|
|
930
|
+
const currentApplication = microfrontends.getApplication(
|
|
1048
931
|
process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION
|
|
1049
932
|
);
|
|
1050
933
|
if (!currentApplication.isDefault()) {
|
|
1051
934
|
return middlewares;
|
|
1052
935
|
}
|
|
1053
|
-
const
|
|
1054
|
-
const
|
|
1055
|
-
for (const application of config.getChildApplications()) {
|
|
936
|
+
const localProxyPort = microfrontends.getLocalProxyPort();
|
|
937
|
+
for (const application of microfrontends.getChildApplications()) {
|
|
1056
938
|
for (const pathGroup of application.routing) {
|
|
1057
939
|
const flagName = pathGroup.flag;
|
|
1058
940
|
if (flagName) {
|
|
@@ -1082,14 +964,12 @@ function getMicrofrontendsMiddleware({
|
|
|
1082
964
|
}
|
|
1083
965
|
async function runMicrofrontendsMiddleware({
|
|
1084
966
|
request,
|
|
1085
|
-
fromApp,
|
|
1086
967
|
flagValues
|
|
1087
968
|
}) {
|
|
1088
969
|
const pathname = request.nextUrl.pathname;
|
|
1089
970
|
const middlewares = getMicrofrontendsMiddleware({
|
|
1090
971
|
request,
|
|
1091
|
-
flagValues
|
|
1092
|
-
fromApp
|
|
972
|
+
flagValues
|
|
1093
973
|
});
|
|
1094
974
|
for (const mware of middlewares) {
|
|
1095
975
|
if (typeof mware.src === "string" ? pathname === mware.src : mware.src.test(pathname)) {
|