@vercel/microfrontends 0.13.0 → 0.15.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/README.md +3 -3
- package/dist/bin/cli.cjs +403 -1627
- package/dist/config.cjs +460 -1004
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -25
- package/dist/config.js +456 -983
- package/dist/config.js.map +1 -1
- package/dist/{index-83133f2d.d.ts → index-bf67a461.d.ts} +3 -10
- package/dist/{v2/microfrontends → microfrontends}/server.cjs +128 -194
- package/dist/microfrontends/server.cjs.map +1 -0
- package/dist/{v2/microfrontends → microfrontends}/server.d.ts +6 -5
- package/dist/{v2/microfrontends → microfrontends}/server.js +125 -191
- package/dist/microfrontends/server.js.map +1 -0
- package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +21 -35
- package/dist/microfrontends.cjs.map +1 -0
- package/dist/{v2/microfrontends.d.ts → microfrontends.d.ts} +4 -3
- package/dist/{v2/microfrontends.js → microfrontends.js} +20 -34
- package/dist/microfrontends.js.map +1 -0
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +1323 -1024
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +1327 -1028
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.cjs +77 -18
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.d.ts +14 -3
- package/dist/next/endpoints.js +77 -18
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +745 -425
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +10 -5
- package/dist/next/middleware.js +745 -425
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +595 -1032
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +14 -12
- package/dist/next/testing.js +589 -1016
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +40 -108
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +24 -2
- package/dist/overrides.js +36 -106
- package/dist/overrides.js.map +1 -1
- package/dist/routing.cjs +19 -0
- package/dist/routing.cjs.map +1 -0
- package/dist/routing.d.ts +26 -0
- package/dist/routing.js +1 -0
- package/dist/{v2/schema.cjs → schema.cjs} +1 -1
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js.map +1 -0
- package/dist/{types-a995174e.d.ts → types-a29d224a.d.ts} +1 -7
- package/dist/{types-15b7f215.d.ts → types-cfe3308b.d.ts} +1 -1
- package/dist/types-fc30696d.d.ts +11 -0
- package/dist/utils/mfe-port.cjs +254 -1362
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +250 -1358
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +31 -365
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +3 -152
- package/dist/validation.js +30 -363
- package/dist/validation.js.map +1 -1
- package/package.json +32 -80
- package/schema/schema.json +174 -244
- package/dist/config/client.cjs +0 -54
- package/dist/config/client.cjs.map +0 -1
- package/dist/config/client.d.ts +0 -23
- package/dist/config/client.js +0 -28
- package/dist/config/client.js.map +0 -1
- package/dist/config/edge.cjs +0 -508
- package/dist/config/edge.cjs.map +0 -1
- package/dist/config/edge.d.ts +0 -20
- package/dist/config/edge.js +0 -481
- package/dist/config/edge.js.map +0 -1
- package/dist/microfrontend-config-983a5139.d.ts +0 -154
- package/dist/schema-2922d49e.d.ts +0 -182
- package/dist/v2/config.cjs +0 -723
- package/dist/v2/config.cjs.map +0 -1
- package/dist/v2/config.d.ts +0 -3
- package/dist/v2/config.js +0 -698
- package/dist/v2/config.js.map +0 -1
- package/dist/v2/microfrontends/server.cjs.map +0 -1
- package/dist/v2/microfrontends/server.js.map +0 -1
- package/dist/v2/microfrontends.cjs.map +0 -1
- package/dist/v2/microfrontends.js.map +0 -1
- package/dist/v2/next/client.cjs +0 -3
- package/dist/v2/next/client.cjs.map +0 -1
- package/dist/v2/next/client.d.ts +0 -45
- package/dist/v2/next/client.js +0 -3
- package/dist/v2/next/client.js.map +0 -1
- package/dist/v2/next/config.cjs +0 -2132
- package/dist/v2/next/config.cjs.map +0 -1
- package/dist/v2/next/config.d.ts +0 -22
- package/dist/v2/next/config.js +0 -2097
- package/dist/v2/next/config.js.map +0 -1
- package/dist/v2/next/endpoints.cjs +0 -141
- package/dist/v2/next/endpoints.cjs.map +0 -1
- package/dist/v2/next/endpoints.d.ts +0 -15
- package/dist/v2/next/endpoints.js +0 -116
- package/dist/v2/next/endpoints.js.map +0 -1
- package/dist/v2/next/middleware.cjs +0 -1143
- package/dist/v2/next/middleware.cjs.map +0 -1
- package/dist/v2/next/middleware.d.ts +0 -29
- package/dist/v2/next/middleware.js +0 -1115
- package/dist/v2/next/middleware.js.map +0 -1
- package/dist/v2/overrides.cjs +0 -75
- package/dist/v2/overrides.cjs.map +0 -1
- package/dist/v2/overrides.d.ts +0 -24
- package/dist/v2/overrides.js +0 -45
- package/dist/v2/overrides.js.map +0 -1
- package/dist/v2/schema.cjs.map +0 -1
- package/dist/v2/schema.d.ts +0 -1
- package/schema/schema-v2.json +0 -270
- /package/dist/{v2/schema.js.map → routing.js.map} +0 -0
- /package/dist/{v2/schema.js → schema.js} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// src/config
|
|
2
|
-
import
|
|
3
|
-
import { dirname as dirname3, join } from "node:path";
|
|
1
|
+
// src/config/microfrontends/server/index.ts
|
|
2
|
+
import fs5 from "node:fs";
|
|
3
|
+
import { dirname as dirname3, join as join2 } from "node:path";
|
|
4
4
|
|
|
5
|
-
// src/config
|
|
5
|
+
// src/config/overrides/constants.ts
|
|
6
6
|
var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
|
|
7
7
|
var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
|
|
8
8
|
|
|
9
|
-
// src/config
|
|
9
|
+
// src/config/overrides/is-override-cookie.ts
|
|
10
10
|
function isOverrideCookie(cookie) {
|
|
11
11
|
var _a;
|
|
12
12
|
return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// src/config
|
|
15
|
+
// src/config/overrides/get-override-from-cookie.ts
|
|
16
16
|
function getOverrideFromCookie(cookie) {
|
|
17
17
|
if (!isOverrideCookie(cookie) || !cookie.value)
|
|
18
18
|
return;
|
|
@@ -22,7 +22,7 @@ function getOverrideFromCookie(cookie) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// src/config
|
|
25
|
+
// src/config/overrides/parse-overrides.ts
|
|
26
26
|
function parseOverrides(cookies) {
|
|
27
27
|
const overridesConfig = { applications: {} };
|
|
28
28
|
cookies.forEach((cookie) => {
|
|
@@ -36,7 +36,7 @@ function parseOverrides(cookies) {
|
|
|
36
36
|
return overridesConfig;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
// src/config
|
|
39
|
+
// src/config/errors.ts
|
|
40
40
|
var MicrofrontendError = class extends Error {
|
|
41
41
|
constructor(message, opts) {
|
|
42
42
|
super(message);
|
|
@@ -128,7 +128,7 @@ var MicrofrontendError = class extends Error {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
// src/config
|
|
131
|
+
// src/config/microfrontends-config/utils/get-config-from-env.ts
|
|
132
132
|
function getConfigStringFromEnv() {
|
|
133
133
|
const config = process.env.MFE_CONFIG;
|
|
134
134
|
if (!config) {
|
|
@@ -140,20 +140,20 @@ function getConfigStringFromEnv() {
|
|
|
140
140
|
return config;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
// src/config
|
|
143
|
+
// src/config/microfrontends-config/isomorphic/index.ts
|
|
144
144
|
import { parse } from "jsonc-parser";
|
|
145
145
|
|
|
146
|
-
// src/config
|
|
146
|
+
// src/config/schema/utils/is-main-config.ts
|
|
147
147
|
function isMainConfig(c) {
|
|
148
148
|
return !("partOf" in c);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
// src/config
|
|
151
|
+
// src/config/schema/utils/is-default-app.ts
|
|
152
152
|
function isDefaultApp(a) {
|
|
153
153
|
return !("routing" in a);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
// src/config
|
|
156
|
+
// src/config/microfrontends-config/client/index.ts
|
|
157
157
|
import { pathToRegexp } from "path-to-regexp";
|
|
158
158
|
var MicrofrontendConfigClient = class {
|
|
159
159
|
constructor(config, opts) {
|
|
@@ -219,7 +219,7 @@ var MicrofrontendConfigClient = class {
|
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
-
// src/config
|
|
222
|
+
// src/config/microfrontends-config/isomorphic/validation.ts
|
|
223
223
|
import { pathToRegexp as pathToRegexp2, parse as parsePathRegexp } from "path-to-regexp";
|
|
224
224
|
var SUPPORTED_VERSIONS = ["2"];
|
|
225
225
|
var validateConfigVersion = (version) => {
|
|
@@ -347,21 +347,8 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
347
347
|
);
|
|
348
348
|
}
|
|
349
349
|
};
|
|
350
|
-
var validateConfigOptions = (options) => {
|
|
351
|
-
var _a;
|
|
352
|
-
if ((_a = options == null ? void 0 : options.vercel) == null ? void 0 : _a.previewDeploymentSuffix) {
|
|
353
|
-
if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
|
|
354
|
-
options.vercel.previewDeploymentSuffix
|
|
355
|
-
)) {
|
|
356
|
-
throw new MicrofrontendError(
|
|
357
|
-
`Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
|
|
358
|
-
{ type: "config", subtype: "invalid_preview_deployment_suffix" }
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
350
|
|
|
364
|
-
// src/config
|
|
351
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
365
352
|
var PREFIX = "vc-ap";
|
|
366
353
|
function generateAssetPrefixFromName({
|
|
367
354
|
name
|
|
@@ -372,7 +359,7 @@ function generateAssetPrefixFromName({
|
|
|
372
359
|
return `${PREFIX}-${name}`;
|
|
373
360
|
}
|
|
374
361
|
|
|
375
|
-
// src/config
|
|
362
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-port.ts
|
|
376
363
|
function generatePortFromName({
|
|
377
364
|
name,
|
|
378
365
|
minPort = 3e3,
|
|
@@ -392,7 +379,7 @@ function generatePortFromName({
|
|
|
392
379
|
return port;
|
|
393
380
|
}
|
|
394
381
|
|
|
395
|
-
// src/config
|
|
382
|
+
// src/config/microfrontends-config/isomorphic/host.ts
|
|
396
383
|
var Host = class {
|
|
397
384
|
constructor(hostConfig, options) {
|
|
398
385
|
const { protocol = "https", host, port } = hostConfig;
|
|
@@ -441,7 +428,7 @@ var LocalHost = class extends Host {
|
|
|
441
428
|
}
|
|
442
429
|
};
|
|
443
430
|
|
|
444
|
-
// src/config
|
|
431
|
+
// src/config/microfrontends-config/isomorphic/application.ts
|
|
445
432
|
var Application = class {
|
|
446
433
|
constructor(name, {
|
|
447
434
|
app,
|
|
@@ -511,10 +498,10 @@ var ChildApplication = class extends Application {
|
|
|
511
498
|
}
|
|
512
499
|
};
|
|
513
500
|
|
|
514
|
-
// src/config
|
|
501
|
+
// src/config/microfrontends-config/isomorphic/constants.ts
|
|
515
502
|
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
516
503
|
|
|
517
|
-
// src/config
|
|
504
|
+
// src/config/microfrontends-config/isomorphic/index.ts
|
|
518
505
|
var MicrofrontendConfigIsomorphic = class {
|
|
519
506
|
constructor({
|
|
520
507
|
config,
|
|
@@ -578,7 +565,6 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
578
565
|
validateConfigPaths(c.applications);
|
|
579
566
|
validateConfigDefaultApplication(c.applications);
|
|
580
567
|
}
|
|
581
|
-
validateConfigOptions(c.options);
|
|
582
568
|
return c;
|
|
583
569
|
}
|
|
584
570
|
static fromEnv({
|
|
@@ -697,7 +683,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
697
683
|
}
|
|
698
684
|
};
|
|
699
685
|
|
|
700
|
-
// src/config
|
|
686
|
+
// src/config/microfrontends-config/isomorphic/child.ts
|
|
701
687
|
var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
702
688
|
constructor({
|
|
703
689
|
config,
|
|
@@ -710,7 +696,7 @@ var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
710
696
|
}
|
|
711
697
|
};
|
|
712
698
|
|
|
713
|
-
// src/config
|
|
699
|
+
// src/config/microfrontends-config/isomorphic/main.ts
|
|
714
700
|
var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
715
701
|
constructor({
|
|
716
702
|
config,
|
|
@@ -749,7 +735,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
749
735
|
}
|
|
750
736
|
};
|
|
751
737
|
|
|
752
|
-
// src/config
|
|
738
|
+
// src/config/microfrontends/isomorphic/index.ts
|
|
753
739
|
var Microfrontends = class {
|
|
754
740
|
constructor({
|
|
755
741
|
config,
|
|
@@ -777,7 +763,7 @@ var Microfrontends = class {
|
|
|
777
763
|
}
|
|
778
764
|
};
|
|
779
765
|
|
|
780
|
-
// src/config
|
|
766
|
+
// src/config/microfrontends/utils/find-repository-root.ts
|
|
781
767
|
import fs from "node:fs";
|
|
782
768
|
import path from "node:path";
|
|
783
769
|
var GIT_DIRECTORY = ".git";
|
|
@@ -795,7 +781,7 @@ function findRepositoryRoot(startDir) {
|
|
|
795
781
|
);
|
|
796
782
|
}
|
|
797
783
|
|
|
798
|
-
// src/config
|
|
784
|
+
// src/config/microfrontends/utils/find-package-path.ts
|
|
799
785
|
import { dirname } from "node:path";
|
|
800
786
|
import { readFileSync } from "node:fs";
|
|
801
787
|
import fg from "fast-glob";
|
|
@@ -851,32 +837,42 @@ function findPackagePath(opts) {
|
|
|
851
837
|
return result;
|
|
852
838
|
}
|
|
853
839
|
|
|
854
|
-
// src/config
|
|
840
|
+
// src/config/microfrontends/utils/find-default-package.ts
|
|
855
841
|
import { dirname as dirname2 } from "node:path";
|
|
856
842
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
843
|
+
import { parse as parse2 } from "jsonc-parser";
|
|
857
844
|
import fg2 from "fast-glob";
|
|
845
|
+
|
|
846
|
+
// src/config/constants.ts
|
|
847
|
+
var CONFIGURATION_FILENAMES = [
|
|
848
|
+
"microfrontends.jsonc",
|
|
849
|
+
"microfrontends.json"
|
|
850
|
+
];
|
|
851
|
+
|
|
852
|
+
// src/config/microfrontends/utils/find-default-package.ts
|
|
858
853
|
var configCache2 = {};
|
|
859
854
|
function findDefaultMicrofrontendsPackages({
|
|
860
855
|
repositoryRoot,
|
|
861
856
|
applicationName
|
|
862
857
|
}) {
|
|
863
858
|
try {
|
|
864
|
-
const microfrontendsJsonPaths = fg2.globSync(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
859
|
+
const microfrontendsJsonPaths = fg2.globSync(
|
|
860
|
+
`**/{${CONFIGURATION_FILENAMES.join(",")}}`,
|
|
861
|
+
{
|
|
862
|
+
cwd: repositoryRoot,
|
|
863
|
+
absolute: true,
|
|
864
|
+
onlyFiles: true,
|
|
865
|
+
followSymbolicLinks: false,
|
|
866
|
+
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
867
|
+
}
|
|
868
|
+
);
|
|
871
869
|
const matchingPaths = [];
|
|
872
870
|
for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
|
|
873
871
|
const microfrontendsJsonContent = readFileSync2(
|
|
874
872
|
microfrontendsJsonPath,
|
|
875
873
|
"utf-8"
|
|
876
874
|
);
|
|
877
|
-
const microfrontendsJson =
|
|
878
|
-
microfrontendsJsonContent
|
|
879
|
-
);
|
|
875
|
+
const microfrontendsJson = parse2(microfrontendsJsonContent);
|
|
880
876
|
if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
|
|
881
877
|
matchingPaths.push(microfrontendsJsonPath);
|
|
882
878
|
}
|
|
@@ -906,14 +902,14 @@ function findDefaultMicrofrontendsPackage(opts) {
|
|
|
906
902
|
const result = findDefaultMicrofrontendsPackages(opts);
|
|
907
903
|
if (!result) {
|
|
908
904
|
throw new Error(
|
|
909
|
-
`Error trying to resolve the main microfrontends
|
|
905
|
+
`Error trying to resolve the main microfrontends configuration`
|
|
910
906
|
);
|
|
911
907
|
}
|
|
912
908
|
configCache2[cacheKey] = result;
|
|
913
909
|
return result;
|
|
914
910
|
}
|
|
915
911
|
|
|
916
|
-
// src/config
|
|
912
|
+
// src/config/microfrontends/utils/is-monorepo.ts
|
|
917
913
|
import fs2 from "node:fs";
|
|
918
914
|
import path2 from "node:path";
|
|
919
915
|
function isMonorepo({
|
|
@@ -940,7 +936,7 @@ function isMonorepo({
|
|
|
940
936
|
}
|
|
941
937
|
}
|
|
942
938
|
|
|
943
|
-
// src/config
|
|
939
|
+
// src/config/microfrontends/utils/find-package-root.ts
|
|
944
940
|
import fs3 from "node:fs";
|
|
945
941
|
import path3 from "node:path";
|
|
946
942
|
var PACKAGE_JSON = "package.json";
|
|
@@ -958,10 +954,23 @@ function findPackageRoot(startDir) {
|
|
|
958
954
|
);
|
|
959
955
|
}
|
|
960
956
|
|
|
961
|
-
// src/config
|
|
957
|
+
// src/config/microfrontends/utils/find-config.ts
|
|
958
|
+
import fs4 from "node:fs";
|
|
959
|
+
import { join } from "node:path";
|
|
960
|
+
function findConfig({ dir }) {
|
|
961
|
+
for (const filename of CONFIGURATION_FILENAMES) {
|
|
962
|
+
const maybeConfig = join(dir, filename);
|
|
963
|
+
if (fs4.existsSync(maybeConfig)) {
|
|
964
|
+
return maybeConfig;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
962
971
|
import path4 from "node:path";
|
|
963
972
|
|
|
964
|
-
// src/config
|
|
973
|
+
// src/config/microfrontends/server/constants.ts
|
|
965
974
|
var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
|
|
966
975
|
var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
|
|
967
976
|
|
|
@@ -970,7 +979,7 @@ function isVercel() {
|
|
|
970
979
|
return process.env.VERCEL === "1";
|
|
971
980
|
}
|
|
972
981
|
|
|
973
|
-
// src/config
|
|
982
|
+
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
974
983
|
function getOutputFilePath() {
|
|
975
984
|
if (isVercel()) {
|
|
976
985
|
return path4.join(
|
|
@@ -982,104 +991,12 @@ function getOutputFilePath() {
|
|
|
982
991
|
return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
|
|
983
992
|
}
|
|
984
993
|
|
|
985
|
-
// src/config
|
|
986
|
-
import { parse as
|
|
994
|
+
// src/config/microfrontends/server/validation.ts
|
|
995
|
+
import { parse as parse3 } from "jsonc-parser";
|
|
987
996
|
import { Ajv } from "ajv";
|
|
988
997
|
|
|
989
|
-
//
|
|
990
|
-
var
|
|
991
|
-
constructor(message, opts) {
|
|
992
|
-
super(message);
|
|
993
|
-
this.name = "MicrofrontendsError";
|
|
994
|
-
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
|
|
995
|
-
this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
|
|
996
|
-
this.subtype = opts == null ? void 0 : opts.subtype;
|
|
997
|
-
Error.captureStackTrace(this, MicrofrontendError2);
|
|
998
|
-
}
|
|
999
|
-
isKnown() {
|
|
1000
|
-
return this.type !== "unknown";
|
|
1001
|
-
}
|
|
1002
|
-
isUnknown() {
|
|
1003
|
-
return !this.isKnown();
|
|
1004
|
-
}
|
|
1005
|
-
/**
|
|
1006
|
-
* Converts an error to a MicrofrontendsError.
|
|
1007
|
-
* @param original - The original error to convert.
|
|
1008
|
-
* @returns The converted MicrofrontendsError.
|
|
1009
|
-
*/
|
|
1010
|
-
static convert(original, opts) {
|
|
1011
|
-
if (opts == null ? void 0 : opts.fileName) {
|
|
1012
|
-
const err = MicrofrontendError2.convertFSError(original, opts.fileName);
|
|
1013
|
-
if (err) {
|
|
1014
|
-
return err;
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
if (original.message.includes(
|
|
1018
|
-
"Code generation from strings disallowed for this context"
|
|
1019
|
-
)) {
|
|
1020
|
-
return new MicrofrontendError2(original.message, {
|
|
1021
|
-
type: "config",
|
|
1022
|
-
subtype: "unsupported_validation_env",
|
|
1023
|
-
source: "ajv"
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
return new MicrofrontendError2(original.message);
|
|
1027
|
-
}
|
|
1028
|
-
static convertFSError(original, fileName) {
|
|
1029
|
-
if (original instanceof Error && "code" in original) {
|
|
1030
|
-
if (original.code === "ENOENT") {
|
|
1031
|
-
return new MicrofrontendError2(`Could not find "${fileName}"`, {
|
|
1032
|
-
type: "config",
|
|
1033
|
-
subtype: "unable_to_read_file",
|
|
1034
|
-
source: "fs"
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
if (original.code === "EACCES") {
|
|
1038
|
-
return new MicrofrontendError2(
|
|
1039
|
-
`Permission denied while accessing "${fileName}"`,
|
|
1040
|
-
{
|
|
1041
|
-
type: "config",
|
|
1042
|
-
subtype: "invalid_permissions",
|
|
1043
|
-
source: "fs"
|
|
1044
|
-
}
|
|
1045
|
-
);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (original instanceof SyntaxError) {
|
|
1049
|
-
return new MicrofrontendError2(
|
|
1050
|
-
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
1051
|
-
{
|
|
1052
|
-
type: "config",
|
|
1053
|
-
subtype: "invalid_syntax",
|
|
1054
|
-
source: "fs"
|
|
1055
|
-
}
|
|
1056
|
-
);
|
|
1057
|
-
}
|
|
1058
|
-
return null;
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
1062
|
-
* @param err - The error to handle.
|
|
1063
|
-
* @returns A MicrofrontendsError instance.
|
|
1064
|
-
*/
|
|
1065
|
-
static handle(err, opts) {
|
|
1066
|
-
if (err instanceof MicrofrontendError2) {
|
|
1067
|
-
return err;
|
|
1068
|
-
}
|
|
1069
|
-
if (err instanceof Error) {
|
|
1070
|
-
return MicrofrontendError2.convert(err, opts);
|
|
1071
|
-
}
|
|
1072
|
-
if (typeof err === "object" && err !== null) {
|
|
1073
|
-
if ("message" in err && typeof err.message === "string") {
|
|
1074
|
-
return MicrofrontendError2.convert(new Error(err.message), opts);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
return new MicrofrontendError2("An unknown error occurred");
|
|
1078
|
-
}
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
// schema/schema-v2.json
|
|
1082
|
-
var schema_v2_default = {
|
|
998
|
+
// schema/schema.json
|
|
999
|
+
var schema_default = {
|
|
1083
1000
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
1084
1001
|
$ref: "#/definitions/Config",
|
|
1085
1002
|
definitions: {
|
|
@@ -1118,7 +1035,8 @@ var schema_v2_default = {
|
|
|
1118
1035
|
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"
|
|
1119
1036
|
}
|
|
1120
1037
|
},
|
|
1121
|
-
required: ["applications", "version"]
|
|
1038
|
+
required: ["applications", "version"],
|
|
1039
|
+
additionalProperties: false
|
|
1122
1040
|
},
|
|
1123
1041
|
Options: {
|
|
1124
1042
|
type: "object",
|
|
@@ -1131,15 +1049,12 @@ var schema_v2_default = {
|
|
|
1131
1049
|
$ref: "#/definitions/LocalProxyOptions",
|
|
1132
1050
|
description: "Options for local proxy."
|
|
1133
1051
|
}
|
|
1134
|
-
}
|
|
1052
|
+
},
|
|
1053
|
+
additionalProperties: false
|
|
1135
1054
|
},
|
|
1136
1055
|
VercelOptions: {
|
|
1137
1056
|
type: "object",
|
|
1138
1057
|
properties: {
|
|
1139
|
-
previewDeploymentSuffix: {
|
|
1140
|
-
type: "string",
|
|
1141
|
-
description: "If your team uses a custom Preview Deployment Suffix, please specify it here. See https://vercel.com/docs/deployments/preview-deployment-suffix. The default is `vercel.app`."
|
|
1142
|
-
},
|
|
1143
1058
|
teamSlug: {
|
|
1144
1059
|
type: "string",
|
|
1145
1060
|
description: "Team slug for the Vercel team"
|
|
@@ -1148,7 +1063,8 @@ var schema_v2_default = {
|
|
|
1148
1063
|
type: "boolean",
|
|
1149
1064
|
description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
|
|
1150
1065
|
}
|
|
1151
|
-
}
|
|
1066
|
+
},
|
|
1067
|
+
additionalProperties: false
|
|
1152
1068
|
},
|
|
1153
1069
|
LocalProxyOptions: {
|
|
1154
1070
|
type: "object",
|
|
@@ -1157,7 +1073,8 @@ var schema_v2_default = {
|
|
|
1157
1073
|
type: "number",
|
|
1158
1074
|
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
1159
1075
|
}
|
|
1160
|
-
}
|
|
1076
|
+
},
|
|
1077
|
+
additionalProperties: false
|
|
1161
1078
|
},
|
|
1162
1079
|
Application: {
|
|
1163
1080
|
anyOf: [
|
|
@@ -1182,7 +1099,8 @@ var schema_v2_default = {
|
|
|
1182
1099
|
$ref: "#/definitions/HostConfig"
|
|
1183
1100
|
}
|
|
1184
1101
|
},
|
|
1185
|
-
required: ["production"]
|
|
1102
|
+
required: ["production"],
|
|
1103
|
+
additionalProperties: false
|
|
1186
1104
|
},
|
|
1187
1105
|
Vercel: {
|
|
1188
1106
|
type: "object",
|
|
@@ -1192,7 +1110,8 @@ var schema_v2_default = {
|
|
|
1192
1110
|
description: "Vercel project ID"
|
|
1193
1111
|
}
|
|
1194
1112
|
},
|
|
1195
|
-
required: ["projectId"]
|
|
1113
|
+
required: ["projectId"],
|
|
1114
|
+
additionalProperties: false
|
|
1196
1115
|
},
|
|
1197
1116
|
Development: {
|
|
1198
1117
|
type: "object",
|
|
@@ -1208,10 +1127,12 @@ var schema_v2_default = {
|
|
|
1208
1127
|
type: "string",
|
|
1209
1128
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
1210
1129
|
}
|
|
1211
|
-
}
|
|
1130
|
+
},
|
|
1131
|
+
additionalProperties: false
|
|
1212
1132
|
},
|
|
1213
1133
|
LocalHostConfig: {
|
|
1214
1134
|
type: "object",
|
|
1135
|
+
additionalProperties: false,
|
|
1215
1136
|
properties: {
|
|
1216
1137
|
host: {
|
|
1217
1138
|
type: "string",
|
|
@@ -1245,7 +1166,8 @@ var schema_v2_default = {
|
|
|
1245
1166
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1246
1167
|
}
|
|
1247
1168
|
},
|
|
1248
|
-
required: ["host"]
|
|
1169
|
+
required: ["host"],
|
|
1170
|
+
additionalProperties: false
|
|
1249
1171
|
},
|
|
1250
1172
|
ChildApplication: {
|
|
1251
1173
|
type: "object",
|
|
@@ -1264,7 +1186,8 @@ var schema_v2_default = {
|
|
|
1264
1186
|
$ref: "#/definitions/HostConfig"
|
|
1265
1187
|
}
|
|
1266
1188
|
},
|
|
1267
|
-
required: ["routing"]
|
|
1189
|
+
required: ["routing"],
|
|
1190
|
+
additionalProperties: false
|
|
1268
1191
|
},
|
|
1269
1192
|
Routing: {
|
|
1270
1193
|
type: "array",
|
|
@@ -1290,7 +1213,8 @@ var schema_v2_default = {
|
|
|
1290
1213
|
}
|
|
1291
1214
|
}
|
|
1292
1215
|
},
|
|
1293
|
-
required: ["paths"]
|
|
1216
|
+
required: ["paths"],
|
|
1217
|
+
additionalProperties: false
|
|
1294
1218
|
},
|
|
1295
1219
|
ApplicationRouting: {
|
|
1296
1220
|
type: "object",
|
|
@@ -1323,22 +1247,23 @@ var schema_v2_default = {
|
|
|
1323
1247
|
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."
|
|
1324
1248
|
}
|
|
1325
1249
|
},
|
|
1326
|
-
required: ["partOf", "version"]
|
|
1250
|
+
required: ["partOf", "version"],
|
|
1251
|
+
additionalProperties: false
|
|
1327
1252
|
}
|
|
1328
1253
|
}
|
|
1329
1254
|
};
|
|
1330
1255
|
|
|
1331
|
-
// src/config
|
|
1332
|
-
var SCHEMA =
|
|
1256
|
+
// src/config/schema/utils/load.ts
|
|
1257
|
+
var SCHEMA = schema_default;
|
|
1333
1258
|
|
|
1334
|
-
// src/config
|
|
1259
|
+
// src/config/microfrontends/server/validation.ts
|
|
1335
1260
|
function validateSchema(configString) {
|
|
1336
|
-
const parsedConfig =
|
|
1261
|
+
const parsedConfig = parse3(configString);
|
|
1337
1262
|
const ajv = new Ajv();
|
|
1338
1263
|
const validate = ajv.compile(SCHEMA);
|
|
1339
1264
|
const isValid = validate(parsedConfig);
|
|
1340
1265
|
if (!isValid) {
|
|
1341
|
-
throw new
|
|
1266
|
+
throw new MicrofrontendError(
|
|
1342
1267
|
`Invalid config: ${ajv.errorsText(validate.errors)}`,
|
|
1343
1268
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
1344
1269
|
);
|
|
@@ -1346,7 +1271,7 @@ function validateSchema(configString) {
|
|
|
1346
1271
|
return parsedConfig;
|
|
1347
1272
|
}
|
|
1348
1273
|
|
|
1349
|
-
// src/config
|
|
1274
|
+
// src/config/microfrontends/server/index.ts
|
|
1350
1275
|
var MicrofrontendsServer = class extends Microfrontends {
|
|
1351
1276
|
/**
|
|
1352
1277
|
* Writes the configuration to a file.
|
|
@@ -1355,8 +1280,8 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1355
1280
|
pretty: true
|
|
1356
1281
|
}) {
|
|
1357
1282
|
const outputPath = getOutputFilePath();
|
|
1358
|
-
|
|
1359
|
-
|
|
1283
|
+
fs5.mkdirSync(dirname3(outputPath), { recursive: true });
|
|
1284
|
+
fs5.writeFileSync(
|
|
1360
1285
|
outputPath,
|
|
1361
1286
|
JSON.stringify(
|
|
1362
1287
|
this.config.toSchemaJson(),
|
|
@@ -1419,8 +1344,8 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1419
1344
|
return config;
|
|
1420
1345
|
}
|
|
1421
1346
|
/**
|
|
1422
|
-
* Looks up the configuration by inferring the package root and looking for a microfrontends
|
|
1423
|
-
* it will look for a package in the repository with a microfrontends
|
|
1347
|
+
* Looks up the configuration by inferring the package root and looking for a microfrontends config file. If a file is not found,
|
|
1348
|
+
* it will look for a package in the repository with a microfrontends file that contains the current application
|
|
1424
1349
|
* and use that configuration.
|
|
1425
1350
|
*
|
|
1426
1351
|
* This can return either a Child or Main configuration.
|
|
@@ -1442,16 +1367,16 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1442
1367
|
}
|
|
1443
1368
|
try {
|
|
1444
1369
|
const packageRoot = findPackageRoot(directory);
|
|
1445
|
-
const packageJsonPath =
|
|
1370
|
+
const packageJsonPath = join2(packageRoot, "package.json");
|
|
1446
1371
|
const packageJson = JSON.parse(
|
|
1447
|
-
|
|
1372
|
+
fs5.readFileSync(packageJsonPath, "utf-8")
|
|
1448
1373
|
);
|
|
1449
1374
|
if (!packageJson.name) {
|
|
1450
1375
|
throw new Error(`No name found in package.json at ${packageJsonPath}`);
|
|
1451
1376
|
}
|
|
1452
1377
|
const configMeta = meta ?? { fromApp: packageJson.name };
|
|
1453
|
-
const maybeConfig =
|
|
1454
|
-
if (
|
|
1378
|
+
const maybeConfig = findConfig({ dir: packageRoot });
|
|
1379
|
+
if (maybeConfig) {
|
|
1455
1380
|
return MicrofrontendsServer.fromFile({
|
|
1456
1381
|
filePath: maybeConfig,
|
|
1457
1382
|
cookies,
|
|
@@ -1466,12 +1391,15 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1466
1391
|
repositoryRoot,
|
|
1467
1392
|
applicationName: packageJson.name
|
|
1468
1393
|
});
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1394
|
+
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1395
|
+
if (maybeConfigFromDefault) {
|
|
1396
|
+
return MicrofrontendsServer.fromFile({
|
|
1397
|
+
filePath: maybeConfigFromDefault,
|
|
1398
|
+
cookies,
|
|
1399
|
+
meta: configMeta,
|
|
1400
|
+
options
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1475
1403
|
}
|
|
1476
1404
|
throw new Error("Unable to infer");
|
|
1477
1405
|
} catch (e) {
|
|
@@ -1491,7 +1419,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1491
1419
|
options
|
|
1492
1420
|
}) {
|
|
1493
1421
|
try {
|
|
1494
|
-
const configJson =
|
|
1422
|
+
const configJson = fs5.readFileSync(filePath, "utf-8");
|
|
1495
1423
|
const config = MicrofrontendsServer.validate(configJson);
|
|
1496
1424
|
if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
|
|
1497
1425
|
const repositoryRoot = findRepositoryRoot();
|
|
@@ -1507,9 +1435,15 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1507
1435
|
{ type: "config", subtype: "not_found" }
|
|
1508
1436
|
);
|
|
1509
1437
|
}
|
|
1510
|
-
const
|
|
1438
|
+
const maybeConfig = findConfig({ dir: packagePath });
|
|
1439
|
+
if (!maybeConfig) {
|
|
1440
|
+
throw new MicrofrontendError(
|
|
1441
|
+
`Could not find microfrontends configuration in ${packagePath}`,
|
|
1442
|
+
{ type: "config", subtype: "not_found" }
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1511
1445
|
return MicrofrontendsServer.fromMainConfigFile({
|
|
1512
|
-
filePath:
|
|
1446
|
+
filePath: maybeConfig,
|
|
1513
1447
|
overrides: cookies ? parseOverrides(cookies) : void 0
|
|
1514
1448
|
});
|
|
1515
1449
|
}
|
|
@@ -1533,7 +1467,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
1533
1467
|
overrides
|
|
1534
1468
|
}) {
|
|
1535
1469
|
try {
|
|
1536
|
-
const config =
|
|
1470
|
+
const config = fs5.readFileSync(filePath, "utf-8");
|
|
1537
1471
|
const validatedConfig = MicrofrontendsServer.validate(config);
|
|
1538
1472
|
if (!isMainConfig(validatedConfig)) {
|
|
1539
1473
|
throw new MicrofrontendError(
|