@vercel/microfrontends 0.14.0 → 0.16.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/dist/bin/cli.cjs +392 -1620
- package/dist/config.cjs +478 -1001
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -25
- package/dist/config.js +474 -980
- package/dist/config.js.map +1 -1
- package/dist/{v2/microfrontends → microfrontends}/server.cjs +91 -150
- package/dist/microfrontends/server.cjs.map +1 -0
- package/dist/{v2/microfrontends → microfrontends}/server.d.ts +4 -4
- package/dist/{v2/microfrontends → microfrontends}/server.js +91 -150
- package/dist/microfrontends/server.js.map +1 -0
- package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +49 -28
- package/dist/microfrontends.cjs.map +1 -0
- package/dist/{v2/microfrontends.d.ts → microfrontends.d.ts} +4 -4
- package/dist/{v2/microfrontends.js → microfrontends.js} +48 -27
- 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 +1344 -1024
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +1343 -1023
- 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 +13 -2
- package/dist/next/endpoints.js +77 -18
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +765 -395
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +10 -5
- package/dist/next/middleware.js +765 -395
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +615 -1031
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +14 -12
- package/dist/next/testing.js +609 -1015
- 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/{v2/routing.cjs → routing.cjs} +3 -3
- package/dist/routing.cjs.map +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/utils/mfe-port.cjs +237 -1338
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +230 -1331
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +31 -361
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +3 -146
- package/dist/validation.js +30 -359
- package/dist/validation.js.map +1 -1
- package/package.json +29 -92
- 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 -709
- package/dist/v2/config.cjs.map +0 -1
- package/dist/v2/config.d.ts +0 -4
- package/dist/v2/config.js +0 -684
- 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 -2178
- 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 -2143
- 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 -26
- package/dist/v2/next/endpoints.js +0 -116
- package/dist/v2/next/endpoints.js.map +0 -1
- package/dist/v2/next/middleware.cjs +0 -1099
- package/dist/v2/next/middleware.cjs.map +0 -1
- package/dist/v2/next/middleware.d.ts +0 -34
- package/dist/v2/next/middleware.js +0 -1071
- package/dist/v2/next/middleware.js.map +0 -1
- package/dist/v2/next/testing.cjs +0 -992
- package/dist/v2/next/testing.cjs.map +0 -1
- package/dist/v2/next/testing.d.ts +0 -55
- package/dist/v2/next/testing.js +0 -961
- package/dist/v2/next/testing.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/routing.cjs.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 -266
- /package/dist/{v2/routing.d.ts → routing.d.ts} +0 -0
- /package/dist/{v2/routing.js → routing.js} +0 -0
- /package/dist/{v2/routing.js.map → routing.js.map} +0 -0
- /package/dist/{v2/schema.js → schema.js} +0 -0
- /package/dist/{v2/schema.js.map → schema.js.map} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// src/config
|
|
1
|
+
// src/config/microfrontends/server/index.ts
|
|
2
2
|
import fs5 from "node:fs";
|
|
3
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) => {
|
|
@@ -244,13 +244,9 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
244
244
|
}
|
|
245
245
|
for (const pathMatch of app.routing) {
|
|
246
246
|
for (const path5 of pathMatch.paths) {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
errors.push(
|
|
251
|
-
`Path ${path5} may only have a :wildcard in the last path component`
|
|
252
|
-
);
|
|
253
|
-
}
|
|
247
|
+
const maybeError = validatePathExpression(path5);
|
|
248
|
+
if (maybeError) {
|
|
249
|
+
errors.push(maybeError);
|
|
254
250
|
}
|
|
255
251
|
const existing = pathsByApplicationId.get(path5);
|
|
256
252
|
if (existing) {
|
|
@@ -300,6 +296,31 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
300
296
|
});
|
|
301
297
|
}
|
|
302
298
|
};
|
|
299
|
+
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
300
|
+
function validatePathExpression(path5) {
|
|
301
|
+
const tokens = parsePathRegexp(path5);
|
|
302
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
303
|
+
const token = tokens[i];
|
|
304
|
+
if (token === void 0) {
|
|
305
|
+
return `token ${i} in ${path5} is undefined, this shouldn't happen`;
|
|
306
|
+
}
|
|
307
|
+
if (typeof token !== "string") {
|
|
308
|
+
if (token.pattern !== PATH_DEFAULT_PATTERN) {
|
|
309
|
+
return `Path ${path5} cannot use a regular expression wildcard`;
|
|
310
|
+
}
|
|
311
|
+
if (token.prefix !== "/") {
|
|
312
|
+
return `Wildcard :${token.name} must be immediately after a / in ${path5}`;
|
|
313
|
+
}
|
|
314
|
+
if (token.suffix) {
|
|
315
|
+
return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;
|
|
316
|
+
}
|
|
317
|
+
if (token.modifier && i !== tokens.length - 1) {
|
|
318
|
+
return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path5}. Modifiers are only allowed in the last path component`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return void 0;
|
|
323
|
+
}
|
|
303
324
|
var validateAppPaths = (name, app) => {
|
|
304
325
|
for (const group of app.routing) {
|
|
305
326
|
for (const p of group.paths) {
|
|
@@ -348,7 +369,7 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
348
369
|
}
|
|
349
370
|
};
|
|
350
371
|
|
|
351
|
-
// src/config
|
|
372
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
352
373
|
var PREFIX = "vc-ap";
|
|
353
374
|
function generateAssetPrefixFromName({
|
|
354
375
|
name
|
|
@@ -359,7 +380,7 @@ function generateAssetPrefixFromName({
|
|
|
359
380
|
return `${PREFIX}-${name}`;
|
|
360
381
|
}
|
|
361
382
|
|
|
362
|
-
// src/config
|
|
383
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-port.ts
|
|
363
384
|
function generatePortFromName({
|
|
364
385
|
name,
|
|
365
386
|
minPort = 3e3,
|
|
@@ -379,7 +400,7 @@ function generatePortFromName({
|
|
|
379
400
|
return port;
|
|
380
401
|
}
|
|
381
402
|
|
|
382
|
-
// src/config
|
|
403
|
+
// src/config/microfrontends-config/isomorphic/host.ts
|
|
383
404
|
var Host = class {
|
|
384
405
|
constructor(hostConfig, options) {
|
|
385
406
|
const { protocol = "https", host, port } = hostConfig;
|
|
@@ -428,7 +449,7 @@ var LocalHost = class extends Host {
|
|
|
428
449
|
}
|
|
429
450
|
};
|
|
430
451
|
|
|
431
|
-
// src/config
|
|
452
|
+
// src/config/microfrontends-config/isomorphic/application.ts
|
|
432
453
|
var Application = class {
|
|
433
454
|
constructor(name, {
|
|
434
455
|
app,
|
|
@@ -498,10 +519,10 @@ var ChildApplication = class extends Application {
|
|
|
498
519
|
}
|
|
499
520
|
};
|
|
500
521
|
|
|
501
|
-
// src/config
|
|
522
|
+
// src/config/microfrontends-config/isomorphic/constants.ts
|
|
502
523
|
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
503
524
|
|
|
504
|
-
// src/config
|
|
525
|
+
// src/config/microfrontends-config/isomorphic/index.ts
|
|
505
526
|
var MicrofrontendConfigIsomorphic = class {
|
|
506
527
|
constructor({
|
|
507
528
|
config,
|
|
@@ -683,7 +704,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
683
704
|
}
|
|
684
705
|
};
|
|
685
706
|
|
|
686
|
-
// src/config
|
|
707
|
+
// src/config/microfrontends-config/isomorphic/child.ts
|
|
687
708
|
var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
688
709
|
constructor({
|
|
689
710
|
config,
|
|
@@ -696,7 +717,7 @@ var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
696
717
|
}
|
|
697
718
|
};
|
|
698
719
|
|
|
699
|
-
// src/config
|
|
720
|
+
// src/config/microfrontends-config/isomorphic/main.ts
|
|
700
721
|
var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
701
722
|
constructor({
|
|
702
723
|
config,
|
|
@@ -735,7 +756,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
|
735
756
|
}
|
|
736
757
|
};
|
|
737
758
|
|
|
738
|
-
// src/config
|
|
759
|
+
// src/config/microfrontends/isomorphic/index.ts
|
|
739
760
|
var Microfrontends = class {
|
|
740
761
|
constructor({
|
|
741
762
|
config,
|
|
@@ -763,7 +784,7 @@ var Microfrontends = class {
|
|
|
763
784
|
}
|
|
764
785
|
};
|
|
765
786
|
|
|
766
|
-
// src/config
|
|
787
|
+
// src/config/microfrontends/utils/find-repository-root.ts
|
|
767
788
|
import fs from "node:fs";
|
|
768
789
|
import path from "node:path";
|
|
769
790
|
var GIT_DIRECTORY = ".git";
|
|
@@ -781,7 +802,7 @@ function findRepositoryRoot(startDir) {
|
|
|
781
802
|
);
|
|
782
803
|
}
|
|
783
804
|
|
|
784
|
-
// src/config
|
|
805
|
+
// src/config/microfrontends/utils/find-package-path.ts
|
|
785
806
|
import { dirname } from "node:path";
|
|
786
807
|
import { readFileSync } from "node:fs";
|
|
787
808
|
import fg from "fast-glob";
|
|
@@ -837,19 +858,19 @@ function findPackagePath(opts) {
|
|
|
837
858
|
return result;
|
|
838
859
|
}
|
|
839
860
|
|
|
840
|
-
// src/config
|
|
861
|
+
// src/config/microfrontends/utils/find-default-package.ts
|
|
841
862
|
import { dirname as dirname2 } from "node:path";
|
|
842
863
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
843
864
|
import { parse as parse2 } from "jsonc-parser";
|
|
844
865
|
import fg2 from "fast-glob";
|
|
845
866
|
|
|
846
|
-
// src/config
|
|
867
|
+
// src/config/constants.ts
|
|
847
868
|
var CONFIGURATION_FILENAMES = [
|
|
848
869
|
"microfrontends.jsonc",
|
|
849
870
|
"microfrontends.json"
|
|
850
871
|
];
|
|
851
872
|
|
|
852
|
-
// src/config
|
|
873
|
+
// src/config/microfrontends/utils/find-default-package.ts
|
|
853
874
|
var configCache2 = {};
|
|
854
875
|
function findDefaultMicrofrontendsPackages({
|
|
855
876
|
repositoryRoot,
|
|
@@ -909,7 +930,7 @@ function findDefaultMicrofrontendsPackage(opts) {
|
|
|
909
930
|
return result;
|
|
910
931
|
}
|
|
911
932
|
|
|
912
|
-
// src/config
|
|
933
|
+
// src/config/microfrontends/utils/is-monorepo.ts
|
|
913
934
|
import fs2 from "node:fs";
|
|
914
935
|
import path2 from "node:path";
|
|
915
936
|
function isMonorepo({
|
|
@@ -936,7 +957,7 @@ function isMonorepo({
|
|
|
936
957
|
}
|
|
937
958
|
}
|
|
938
959
|
|
|
939
|
-
// src/config
|
|
960
|
+
// src/config/microfrontends/utils/find-package-root.ts
|
|
940
961
|
import fs3 from "node:fs";
|
|
941
962
|
import path3 from "node:path";
|
|
942
963
|
var PACKAGE_JSON = "package.json";
|
|
@@ -954,7 +975,7 @@ function findPackageRoot(startDir) {
|
|
|
954
975
|
);
|
|
955
976
|
}
|
|
956
977
|
|
|
957
|
-
// src/config
|
|
978
|
+
// src/config/microfrontends/utils/find-config.ts
|
|
958
979
|
import fs4 from "node:fs";
|
|
959
980
|
import { join } from "node:path";
|
|
960
981
|
function findConfig({ dir }) {
|
|
@@ -967,10 +988,10 @@ function findConfig({ dir }) {
|
|
|
967
988
|
return null;
|
|
968
989
|
}
|
|
969
990
|
|
|
970
|
-
// src/config
|
|
991
|
+
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
971
992
|
import path4 from "node:path";
|
|
972
993
|
|
|
973
|
-
// src/config
|
|
994
|
+
// src/config/microfrontends/server/constants.ts
|
|
974
995
|
var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
|
|
975
996
|
var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
|
|
976
997
|
|
|
@@ -979,7 +1000,7 @@ function isVercel() {
|
|
|
979
1000
|
return process.env.VERCEL === "1";
|
|
980
1001
|
}
|
|
981
1002
|
|
|
982
|
-
// src/config
|
|
1003
|
+
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
983
1004
|
function getOutputFilePath() {
|
|
984
1005
|
if (isVercel()) {
|
|
985
1006
|
return path4.join(
|
|
@@ -991,104 +1012,12 @@ function getOutputFilePath() {
|
|
|
991
1012
|
return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
|
|
992
1013
|
}
|
|
993
1014
|
|
|
994
|
-
// src/config
|
|
1015
|
+
// src/config/microfrontends/server/validation.ts
|
|
995
1016
|
import { parse as parse3 } from "jsonc-parser";
|
|
996
1017
|
import { Ajv } from "ajv";
|
|
997
1018
|
|
|
998
|
-
//
|
|
999
|
-
var
|
|
1000
|
-
constructor(message, opts) {
|
|
1001
|
-
super(message);
|
|
1002
|
-
this.name = "MicrofrontendsError";
|
|
1003
|
-
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
|
|
1004
|
-
this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
|
|
1005
|
-
this.subtype = opts == null ? void 0 : opts.subtype;
|
|
1006
|
-
Error.captureStackTrace(this, MicrofrontendError2);
|
|
1007
|
-
}
|
|
1008
|
-
isKnown() {
|
|
1009
|
-
return this.type !== "unknown";
|
|
1010
|
-
}
|
|
1011
|
-
isUnknown() {
|
|
1012
|
-
return !this.isKnown();
|
|
1013
|
-
}
|
|
1014
|
-
/**
|
|
1015
|
-
* Converts an error to a MicrofrontendsError.
|
|
1016
|
-
* @param original - The original error to convert.
|
|
1017
|
-
* @returns The converted MicrofrontendsError.
|
|
1018
|
-
*/
|
|
1019
|
-
static convert(original, opts) {
|
|
1020
|
-
if (opts == null ? void 0 : opts.fileName) {
|
|
1021
|
-
const err = MicrofrontendError2.convertFSError(original, opts.fileName);
|
|
1022
|
-
if (err) {
|
|
1023
|
-
return err;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
if (original.message.includes(
|
|
1027
|
-
"Code generation from strings disallowed for this context"
|
|
1028
|
-
)) {
|
|
1029
|
-
return new MicrofrontendError2(original.message, {
|
|
1030
|
-
type: "config",
|
|
1031
|
-
subtype: "unsupported_validation_env",
|
|
1032
|
-
source: "ajv"
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
return new MicrofrontendError2(original.message);
|
|
1036
|
-
}
|
|
1037
|
-
static convertFSError(original, fileName) {
|
|
1038
|
-
if (original instanceof Error && "code" in original) {
|
|
1039
|
-
if (original.code === "ENOENT") {
|
|
1040
|
-
return new MicrofrontendError2(`Could not find "${fileName}"`, {
|
|
1041
|
-
type: "config",
|
|
1042
|
-
subtype: "unable_to_read_file",
|
|
1043
|
-
source: "fs"
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
if (original.code === "EACCES") {
|
|
1047
|
-
return new MicrofrontendError2(
|
|
1048
|
-
`Permission denied while accessing "${fileName}"`,
|
|
1049
|
-
{
|
|
1050
|
-
type: "config",
|
|
1051
|
-
subtype: "invalid_permissions",
|
|
1052
|
-
source: "fs"
|
|
1053
|
-
}
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
if (original instanceof SyntaxError) {
|
|
1058
|
-
return new MicrofrontendError2(
|
|
1059
|
-
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
1060
|
-
{
|
|
1061
|
-
type: "config",
|
|
1062
|
-
subtype: "invalid_syntax",
|
|
1063
|
-
source: "fs"
|
|
1064
|
-
}
|
|
1065
|
-
);
|
|
1066
|
-
}
|
|
1067
|
-
return null;
|
|
1068
|
-
}
|
|
1069
|
-
/**
|
|
1070
|
-
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
1071
|
-
* @param err - The error to handle.
|
|
1072
|
-
* @returns A MicrofrontendsError instance.
|
|
1073
|
-
*/
|
|
1074
|
-
static handle(err, opts) {
|
|
1075
|
-
if (err instanceof MicrofrontendError2) {
|
|
1076
|
-
return err;
|
|
1077
|
-
}
|
|
1078
|
-
if (err instanceof Error) {
|
|
1079
|
-
return MicrofrontendError2.convert(err, opts);
|
|
1080
|
-
}
|
|
1081
|
-
if (typeof err === "object" && err !== null) {
|
|
1082
|
-
if ("message" in err && typeof err.message === "string") {
|
|
1083
|
-
return MicrofrontendError2.convert(new Error(err.message), opts);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
return new MicrofrontendError2("An unknown error occurred");
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
// schema/schema-v2.json
|
|
1091
|
-
var schema_v2_default = {
|
|
1019
|
+
// schema/schema.json
|
|
1020
|
+
var schema_default = {
|
|
1092
1021
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
1093
1022
|
$ref: "#/definitions/Config",
|
|
1094
1023
|
definitions: {
|
|
@@ -1127,7 +1056,8 @@ var schema_v2_default = {
|
|
|
1127
1056
|
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"
|
|
1128
1057
|
}
|
|
1129
1058
|
},
|
|
1130
|
-
required: ["applications", "version"]
|
|
1059
|
+
required: ["applications", "version"],
|
|
1060
|
+
additionalProperties: false
|
|
1131
1061
|
},
|
|
1132
1062
|
Options: {
|
|
1133
1063
|
type: "object",
|
|
@@ -1140,7 +1070,8 @@ var schema_v2_default = {
|
|
|
1140
1070
|
$ref: "#/definitions/LocalProxyOptions",
|
|
1141
1071
|
description: "Options for local proxy."
|
|
1142
1072
|
}
|
|
1143
|
-
}
|
|
1073
|
+
},
|
|
1074
|
+
additionalProperties: false
|
|
1144
1075
|
},
|
|
1145
1076
|
VercelOptions: {
|
|
1146
1077
|
type: "object",
|
|
@@ -1153,7 +1084,8 @@ var schema_v2_default = {
|
|
|
1153
1084
|
type: "boolean",
|
|
1154
1085
|
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."
|
|
1155
1086
|
}
|
|
1156
|
-
}
|
|
1087
|
+
},
|
|
1088
|
+
additionalProperties: false
|
|
1157
1089
|
},
|
|
1158
1090
|
LocalProxyOptions: {
|
|
1159
1091
|
type: "object",
|
|
@@ -1162,7 +1094,8 @@ var schema_v2_default = {
|
|
|
1162
1094
|
type: "number",
|
|
1163
1095
|
description: "The port number used by the local proxy server.\n\nThe default is `3024`."
|
|
1164
1096
|
}
|
|
1165
|
-
}
|
|
1097
|
+
},
|
|
1098
|
+
additionalProperties: false
|
|
1166
1099
|
},
|
|
1167
1100
|
Application: {
|
|
1168
1101
|
anyOf: [
|
|
@@ -1187,7 +1120,8 @@ var schema_v2_default = {
|
|
|
1187
1120
|
$ref: "#/definitions/HostConfig"
|
|
1188
1121
|
}
|
|
1189
1122
|
},
|
|
1190
|
-
required: ["production"]
|
|
1123
|
+
required: ["production"],
|
|
1124
|
+
additionalProperties: false
|
|
1191
1125
|
},
|
|
1192
1126
|
Vercel: {
|
|
1193
1127
|
type: "object",
|
|
@@ -1197,7 +1131,8 @@ var schema_v2_default = {
|
|
|
1197
1131
|
description: "Vercel project ID"
|
|
1198
1132
|
}
|
|
1199
1133
|
},
|
|
1200
|
-
required: ["projectId"]
|
|
1134
|
+
required: ["projectId"],
|
|
1135
|
+
additionalProperties: false
|
|
1201
1136
|
},
|
|
1202
1137
|
Development: {
|
|
1203
1138
|
type: "object",
|
|
@@ -1213,10 +1148,12 @@ var schema_v2_default = {
|
|
|
1213
1148
|
type: "string",
|
|
1214
1149
|
description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
|
|
1215
1150
|
}
|
|
1216
|
-
}
|
|
1151
|
+
},
|
|
1152
|
+
additionalProperties: false
|
|
1217
1153
|
},
|
|
1218
1154
|
LocalHostConfig: {
|
|
1219
1155
|
type: "object",
|
|
1156
|
+
additionalProperties: false,
|
|
1220
1157
|
properties: {
|
|
1221
1158
|
host: {
|
|
1222
1159
|
type: "string",
|
|
@@ -1250,7 +1187,8 @@ var schema_v2_default = {
|
|
|
1250
1187
|
description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
|
|
1251
1188
|
}
|
|
1252
1189
|
},
|
|
1253
|
-
required: ["host"]
|
|
1190
|
+
required: ["host"],
|
|
1191
|
+
additionalProperties: false
|
|
1254
1192
|
},
|
|
1255
1193
|
ChildApplication: {
|
|
1256
1194
|
type: "object",
|
|
@@ -1269,7 +1207,8 @@ var schema_v2_default = {
|
|
|
1269
1207
|
$ref: "#/definitions/HostConfig"
|
|
1270
1208
|
}
|
|
1271
1209
|
},
|
|
1272
|
-
required: ["routing"]
|
|
1210
|
+
required: ["routing"],
|
|
1211
|
+
additionalProperties: false
|
|
1273
1212
|
},
|
|
1274
1213
|
Routing: {
|
|
1275
1214
|
type: "array",
|
|
@@ -1295,7 +1234,8 @@ var schema_v2_default = {
|
|
|
1295
1234
|
}
|
|
1296
1235
|
}
|
|
1297
1236
|
},
|
|
1298
|
-
required: ["paths"]
|
|
1237
|
+
required: ["paths"],
|
|
1238
|
+
additionalProperties: false
|
|
1299
1239
|
},
|
|
1300
1240
|
ApplicationRouting: {
|
|
1301
1241
|
type: "object",
|
|
@@ -1328,22 +1268,23 @@ var schema_v2_default = {
|
|
|
1328
1268
|
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."
|
|
1329
1269
|
}
|
|
1330
1270
|
},
|
|
1331
|
-
required: ["partOf", "version"]
|
|
1271
|
+
required: ["partOf", "version"],
|
|
1272
|
+
additionalProperties: false
|
|
1332
1273
|
}
|
|
1333
1274
|
}
|
|
1334
1275
|
};
|
|
1335
1276
|
|
|
1336
|
-
// src/config
|
|
1337
|
-
var SCHEMA =
|
|
1277
|
+
// src/config/schema/utils/load.ts
|
|
1278
|
+
var SCHEMA = schema_default;
|
|
1338
1279
|
|
|
1339
|
-
// src/config
|
|
1280
|
+
// src/config/microfrontends/server/validation.ts
|
|
1340
1281
|
function validateSchema(configString) {
|
|
1341
1282
|
const parsedConfig = parse3(configString);
|
|
1342
1283
|
const ajv = new Ajv();
|
|
1343
1284
|
const validate = ajv.compile(SCHEMA);
|
|
1344
1285
|
const isValid = validate(parsedConfig);
|
|
1345
1286
|
if (!isValid) {
|
|
1346
|
-
throw new
|
|
1287
|
+
throw new MicrofrontendError(
|
|
1347
1288
|
`Invalid config: ${ajv.errorsText(validate.errors)}`,
|
|
1348
1289
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
1349
1290
|
);
|
|
@@ -1351,7 +1292,7 @@ function validateSchema(configString) {
|
|
|
1351
1292
|
return parsedConfig;
|
|
1352
1293
|
}
|
|
1353
1294
|
|
|
1354
|
-
// src/config
|
|
1295
|
+
// src/config/microfrontends/server/index.ts
|
|
1355
1296
|
var MicrofrontendsServer = class extends Microfrontends {
|
|
1356
1297
|
/**
|
|
1357
1298
|
* Writes the configuration to a file.
|