@vercel/microfrontends 0.9.0 → 0.10.1
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 +7 -7
- package/dist/bin/cli.cjs +1604 -221
- package/dist/config/client.d.ts +1 -1
- package/dist/config/edge.cjs +47 -47
- package/dist/config/edge.cjs.map +1 -1
- package/dist/config/edge.d.ts +6 -6
- package/dist/config/edge.js +46 -46
- package/dist/config/edge.js.map +1 -1
- package/dist/config.cjs +67 -66
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +66 -65
- package/dist/config.js.map +1 -1
- package/dist/{index-eff254d8.d.ts → index-acb44057.d.ts} +12 -23
- package/dist/{micro-frontend-config-42886104.d.ts → microfrontend-config-983a5139.d.ts} +13 -13
- 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 +86 -87
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +3 -3
- package/dist/next/config.js +85 -86
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +60 -62
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +11 -11
- package/dist/next/middleware.js +58 -60
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +80 -79
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +10 -10
- package/dist/next/testing.js +80 -79
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +9 -9
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +2 -2
- package/dist/overrides.js +9 -9
- package/dist/overrides.js.map +1 -1
- package/dist/{schema-83a75e61.d.ts → schema-2922d49e.d.ts} +1 -7
- package/dist/{types-4fd1c7c6.d.ts → types-7b1cd9f7.d.ts} +1 -7
- package/dist/types-c3d15d04.d.ts +15 -0
- package/dist/v2/config.cjs +39 -39
- package/dist/v2/config.cjs.map +1 -1
- package/dist/v2/config.d.ts +3 -2
- package/dist/v2/config.js +38 -38
- package/dist/v2/config.js.map +1 -1
- package/dist/v2/microfrontends/server.cjs +223 -96
- package/dist/v2/microfrontends/server.cjs.map +1 -1
- package/dist/v2/microfrontends/server.d.ts +11 -3
- package/dist/v2/microfrontends/server.js +223 -96
- package/dist/v2/microfrontends/server.js.map +1 -1
- package/dist/v2/microfrontends.cjs +44 -44
- package/dist/v2/microfrontends.cjs.map +1 -1
- package/dist/v2/microfrontends.d.ts +6 -5
- package/dist/v2/microfrontends.js +44 -44
- package/dist/v2/microfrontends.js.map +1 -1
- package/dist/v2/next/client.cjs +1 -1
- package/dist/v2/next/client.cjs.map +1 -1
- package/dist/v2/next/client.js +1 -1
- package/dist/v2/next/client.js.map +1 -1
- package/dist/v2/next/config.cjs +247 -122
- package/dist/v2/next/config.cjs.map +1 -1
- package/dist/v2/next/config.d.ts +4 -4
- package/dist/v2/next/config.js +246 -121
- package/dist/v2/next/config.js.map +1 -1
- package/dist/v2/next/endpoints.cjs +5 -5
- package/dist/v2/next/endpoints.cjs.map +1 -1
- package/dist/v2/next/endpoints.js +5 -5
- package/dist/v2/next/endpoints.js.map +1 -1
- package/dist/v2/next/middleware.cjs +55 -55
- package/dist/v2/next/middleware.cjs.map +1 -1
- package/dist/v2/next/middleware.d.ts +8 -8
- package/dist/v2/next/middleware.js +53 -53
- package/dist/v2/next/middleware.js.map +1 -1
- package/dist/v2/overrides.cjs +75 -0
- package/dist/v2/overrides.cjs.map +1 -0
- package/dist/v2/overrides.d.ts +24 -0
- package/dist/v2/overrides.js +45 -0
- package/dist/v2/overrides.js.map +1 -0
- package/dist/v2/schema.cjs.map +1 -1
- package/dist/v2/schema.d.ts +1 -1
- package/dist/validation.cjs +20 -28
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +2 -8
- package/dist/validation.js +20 -28
- package/dist/validation.js.map +1 -1
- package/package.json +15 -7
- package/schema/schema-v2.json +0 -4
- package/schema/schema.json +0 -4
package/dist/config.js
CHANGED
|
@@ -61,7 +61,7 @@ async function getWellKnownClientData(flagValues = {}) {
|
|
|
61
61
|
var isCommonApplicationConfig = (app) => !app.default && typeof app.routing === "object";
|
|
62
62
|
var isDefaultApplicationConfig = (app) => app.default && typeof app.routing === "undefined";
|
|
63
63
|
|
|
64
|
-
// src/config/
|
|
64
|
+
// src/config/microfrontend-config.ts
|
|
65
65
|
import fs2 from "node:fs";
|
|
66
66
|
|
|
67
67
|
// src/config-v2/microfrontends/server/utils/get-output-file-path.ts
|
|
@@ -89,14 +89,14 @@ function getOutputFilePath() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// src/config/errors.ts
|
|
92
|
-
var
|
|
92
|
+
var MicrofrontendError = class extends Error {
|
|
93
93
|
constructor(message, opts) {
|
|
94
94
|
super(message);
|
|
95
|
-
this.name = "
|
|
96
|
-
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/
|
|
95
|
+
this.name = "MicrofrontendsError";
|
|
96
|
+
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
|
|
97
97
|
this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
|
|
98
98
|
this.subtype = opts == null ? void 0 : opts.subtype;
|
|
99
|
-
Error.captureStackTrace(this,
|
|
99
|
+
Error.captureStackTrace(this, MicrofrontendError);
|
|
100
100
|
}
|
|
101
101
|
isKnown() {
|
|
102
102
|
return this.type !== "unknown";
|
|
@@ -105,13 +105,13 @@ var MicroFrontendError = class extends Error {
|
|
|
105
105
|
return !this.isKnown();
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* Converts an error to a
|
|
108
|
+
* Converts an error to a MicrofrontendsError.
|
|
109
109
|
* @param original - The original error to convert.
|
|
110
|
-
* @returns The converted
|
|
110
|
+
* @returns The converted MicrofrontendsError.
|
|
111
111
|
*/
|
|
112
112
|
static convert(original, opts) {
|
|
113
113
|
if (opts == null ? void 0 : opts.fileName) {
|
|
114
|
-
const err =
|
|
114
|
+
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
115
115
|
if (err) {
|
|
116
116
|
return err;
|
|
117
117
|
}
|
|
@@ -119,25 +119,25 @@ var MicroFrontendError = class extends Error {
|
|
|
119
119
|
if (original.message.includes(
|
|
120
120
|
"Code generation from strings disallowed for this context"
|
|
121
121
|
)) {
|
|
122
|
-
return new
|
|
122
|
+
return new MicrofrontendError(original.message, {
|
|
123
123
|
type: "config",
|
|
124
124
|
subtype: "unsupported_validation_env",
|
|
125
125
|
source: "ajv"
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
return new
|
|
128
|
+
return new MicrofrontendError(original.message);
|
|
129
129
|
}
|
|
130
130
|
static convertFSError(original, fileName) {
|
|
131
131
|
if (original instanceof Error && "code" in original) {
|
|
132
132
|
if (original.code === "ENOENT") {
|
|
133
|
-
return new
|
|
133
|
+
return new MicrofrontendError(`Could not find "${fileName}"`, {
|
|
134
134
|
type: "config",
|
|
135
135
|
subtype: "unable_to_read_file",
|
|
136
136
|
source: "fs"
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
if (original.code === "EACCES") {
|
|
140
|
-
return new
|
|
140
|
+
return new MicrofrontendError(
|
|
141
141
|
`Permission denied while accessing "${fileName}"`,
|
|
142
142
|
{
|
|
143
143
|
type: "config",
|
|
@@ -148,7 +148,7 @@ var MicroFrontendError = class extends Error {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
if (original instanceof SyntaxError) {
|
|
151
|
-
return new
|
|
151
|
+
return new MicrofrontendError(
|
|
152
152
|
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
153
153
|
{
|
|
154
154
|
type: "config",
|
|
@@ -160,23 +160,23 @@ var MicroFrontendError = class extends Error {
|
|
|
160
160
|
return null;
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
|
-
* Handles an unknown error and returns a
|
|
163
|
+
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
164
164
|
* @param err - The error to handle.
|
|
165
|
-
* @returns A
|
|
165
|
+
* @returns A MicrofrontendsError instance.
|
|
166
166
|
*/
|
|
167
167
|
static handle(err, opts) {
|
|
168
|
-
if (err instanceof
|
|
168
|
+
if (err instanceof MicrofrontendError) {
|
|
169
169
|
return err;
|
|
170
170
|
}
|
|
171
171
|
if (err instanceof Error) {
|
|
172
|
-
return
|
|
172
|
+
return MicrofrontendError.convert(err, opts);
|
|
173
173
|
}
|
|
174
174
|
if (typeof err === "object" && err !== null) {
|
|
175
175
|
if ("message" in err && typeof err.message === "string") {
|
|
176
|
-
return
|
|
176
|
+
return MicrofrontendError.convert(new Error(err.message), opts);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
return new
|
|
179
|
+
return new MicrofrontendError("An unknown error occurred");
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
|
|
@@ -259,27 +259,27 @@ var _Overrides = class {
|
|
|
259
259
|
});
|
|
260
260
|
return overridesConfig;
|
|
261
261
|
}
|
|
262
|
-
static validOverrideDomainsForZone(
|
|
262
|
+
static validOverrideDomainsForZone(microfrontendConfig, zone) {
|
|
263
263
|
var _a, _b, _c, _d, _e;
|
|
264
|
-
const projectName = (_a =
|
|
264
|
+
const projectName = (_a = microfrontendConfig.getZone(zone).vercel) == null ? void 0 : _a.projectName;
|
|
265
265
|
if (!projectName) {
|
|
266
|
-
return [
|
|
266
|
+
return [microfrontendConfig.getZone(zone).production.host];
|
|
267
267
|
}
|
|
268
268
|
const parsedProjectName = makeUrlSafe(projectName);
|
|
269
|
-
const previewDeploymentSuffix = (_c = (_b =
|
|
270
|
-
const teamSlug = (_e = (_d =
|
|
269
|
+
const previewDeploymentSuffix = (_c = (_b = microfrontendConfig.options) == null ? void 0 : _b.vercel) == null ? void 0 : _c.previewDeploymentSuffix;
|
|
270
|
+
const teamSlug = (_e = (_d = microfrontendConfig.options) == null ? void 0 : _d.vercel) == null ? void 0 : _e.teamSlug;
|
|
271
271
|
if (!teamSlug && !previewDeploymentSuffix) {
|
|
272
|
-
return [
|
|
272
|
+
return [microfrontendConfig.getZone(zone).production.host];
|
|
273
273
|
}
|
|
274
274
|
const suffix = previewDeploymentSuffix ? `.${previewDeploymentSuffix}` : `-${teamSlug}.vercel.app`;
|
|
275
275
|
return [
|
|
276
276
|
`${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,
|
|
277
|
-
|
|
277
|
+
microfrontendConfig.getZone(zone).production.host
|
|
278
278
|
];
|
|
279
279
|
}
|
|
280
|
-
static validateOverrideDomain(
|
|
280
|
+
static validateOverrideDomain(microfrontendConfig, zone, domain) {
|
|
281
281
|
return new RegExp(
|
|
282
|
-
`^${_Overrides.validOverrideDomainsForZone(
|
|
282
|
+
`^${_Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(
|
|
283
283
|
"|"
|
|
284
284
|
)}$`
|
|
285
285
|
).test(domain);
|
|
@@ -361,7 +361,7 @@ var Application = class {
|
|
|
361
361
|
static validate(name, app) {
|
|
362
362
|
var _a, _b, _c, _d, _e;
|
|
363
363
|
if (((_b = (_a = app.routing) == null ? void 0 : _a.assetPrefix) == null ? void 0 : _b.startsWith("/")) || ((_d = (_c = app.routing) == null ? void 0 : _c.assetPrefix) == null ? void 0 : _d.endsWith("/"))) {
|
|
364
|
-
throw new
|
|
364
|
+
throw new MicrofrontendError(
|
|
365
365
|
`Invalid assetPrefix for application "${name}". Must not start or end with a slash.`,
|
|
366
366
|
{ type: "zone", subtype: "invalid_asset_prefix" }
|
|
367
367
|
);
|
|
@@ -372,13 +372,13 @@ var Application = class {
|
|
|
372
372
|
continue;
|
|
373
373
|
}
|
|
374
374
|
if (p.endsWith("/")) {
|
|
375
|
-
throw new
|
|
375
|
+
throw new MicrofrontendError(
|
|
376
376
|
`Invalid path for application "${name}". ${p} must not end with a slash.`,
|
|
377
377
|
{ type: "zone", subtype: "invalid_path" }
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
380
|
if (!p.startsWith("/")) {
|
|
381
|
-
throw new
|
|
381
|
+
throw new MicrofrontendError(
|
|
382
382
|
`Invalid path for application "${name}". ${p} must start with a slash.`,
|
|
383
383
|
{ type: "zone", subtype: "invalid_path" }
|
|
384
384
|
);
|
|
@@ -412,10 +412,10 @@ var Application = class {
|
|
|
412
412
|
}
|
|
413
413
|
};
|
|
414
414
|
|
|
415
|
-
// src/config/common/
|
|
415
|
+
// src/config/common/microfrontend-config.ts
|
|
416
416
|
var SUPPORTED_VERSIONS = ["1"];
|
|
417
417
|
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
418
|
-
var
|
|
418
|
+
var MicrofrontendConfigCommon = class {
|
|
419
419
|
constructor({
|
|
420
420
|
config,
|
|
421
421
|
overrides
|
|
@@ -423,7 +423,7 @@ var MicroFrontendConfigCommon = class {
|
|
|
423
423
|
this.zones = {};
|
|
424
424
|
var _a, _b, _c;
|
|
425
425
|
if (!SUPPORTED_VERSIONS.includes(config.version)) {
|
|
426
|
-
throw new
|
|
426
|
+
throw new MicrofrontendError(
|
|
427
427
|
`Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
|
|
428
428
|
", "
|
|
429
429
|
)}`,
|
|
@@ -451,7 +451,7 @@ var MicroFrontendConfigCommon = class {
|
|
|
451
451
|
static getConfigFromEnv() {
|
|
452
452
|
const config = process.env.MFE_CONFIG;
|
|
453
453
|
if (!config) {
|
|
454
|
-
throw new
|
|
454
|
+
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
455
455
|
type: "config",
|
|
456
456
|
subtype: "not_found_in_env"
|
|
457
457
|
});
|
|
@@ -470,8 +470,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
470
470
|
getZone(name) {
|
|
471
471
|
const zone = this.zones[name];
|
|
472
472
|
if (!zone) {
|
|
473
|
-
throw new
|
|
474
|
-
`Could not find
|
|
473
|
+
throw new MicrofrontendError(
|
|
474
|
+
`Could not find microfrontends configuration for application "${name}"`,
|
|
475
475
|
{
|
|
476
476
|
type: "zone",
|
|
477
477
|
subtype: "not_found"
|
|
@@ -491,8 +491,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
491
491
|
getDefaultZone() {
|
|
492
492
|
const zone = Object.values(this.zones).find((z) => z.default);
|
|
493
493
|
if (!zone) {
|
|
494
|
-
throw new
|
|
495
|
-
`Could not find default zone in
|
|
494
|
+
throw new MicrofrontendError(
|
|
495
|
+
`Could not find default zone in microfrontends configuration`,
|
|
496
496
|
{
|
|
497
497
|
type: "zone",
|
|
498
498
|
subtype: "not_found"
|
|
@@ -544,8 +544,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
write(_) {
|
|
547
|
-
throw new
|
|
548
|
-
`Writing to file to disk requires using an instance of "
|
|
547
|
+
throw new MicrofrontendError(
|
|
548
|
+
`Writing to file to disk requires using an instance of "MicrofrontendConfig".`,
|
|
549
549
|
{ type: "config", subtype: "unsupported_operation" }
|
|
550
550
|
);
|
|
551
551
|
}
|
|
@@ -724,10 +724,6 @@ var schema_default = {
|
|
|
724
724
|
flag: {
|
|
725
725
|
type: "string",
|
|
726
726
|
description: "flag name that can be used to enable/disable all paths in the group"
|
|
727
|
-
},
|
|
728
|
-
routeToDefaultApplication: {
|
|
729
|
-
type: "boolean",
|
|
730
|
-
description: "True to route the request to the default application for this micro-frontends set-up. This must be `true` when using `flag` or when you want to use custom logic to make the routing decision for this group of paths."
|
|
731
727
|
}
|
|
732
728
|
}
|
|
733
729
|
},
|
|
@@ -906,7 +902,7 @@ var validateSchema = (configString) => {
|
|
|
906
902
|
const validate = ajv.compile(SCHEMA);
|
|
907
903
|
const isValid = validate(parsedConfig);
|
|
908
904
|
if (!isValid) {
|
|
909
|
-
throw new
|
|
905
|
+
throw new MicrofrontendError(
|
|
910
906
|
`Invalid config: ${ajv.errorsText(validate.errors)}`,
|
|
911
907
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
912
908
|
);
|
|
@@ -916,7 +912,7 @@ var validateSchema = (configString) => {
|
|
|
916
912
|
var SUPPORTED_VERSIONS2 = ["1"];
|
|
917
913
|
var validateVersion = (version) => {
|
|
918
914
|
if (!SUPPORTED_VERSIONS2.includes(version)) {
|
|
919
|
-
throw new
|
|
915
|
+
throw new MicrofrontendError(
|
|
920
916
|
`Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS2.join(
|
|
921
917
|
", "
|
|
922
918
|
)}`,
|
|
@@ -949,7 +945,7 @@ function validateMainPath(applicationConfigsById) {
|
|
|
949
945
|
return !matcher.test(defaultRoute);
|
|
950
946
|
});
|
|
951
947
|
if (!isValid) {
|
|
952
|
-
throw new
|
|
948
|
+
throw new MicrofrontendError(
|
|
953
949
|
`default route "${defaultRoute}" cannot be used for "${id}" because it is matched by "${otherId}"`,
|
|
954
950
|
{ type: "config", subtype: "invalid_main_path" }
|
|
955
951
|
);
|
|
@@ -962,7 +958,7 @@ function validateMainPath(applicationConfigsById) {
|
|
|
962
958
|
return matcher.test(defaultRoute);
|
|
963
959
|
});
|
|
964
960
|
if (!isValid) {
|
|
965
|
-
throw new
|
|
961
|
+
throw new MicrofrontendError(
|
|
966
962
|
`default route "${defaultRoute}" is not included by the routing config for application "${id}"`,
|
|
967
963
|
{ type: "config", subtype: "invalid_main_path" }
|
|
968
964
|
);
|
|
@@ -1025,7 +1021,7 @@ var validatePaths = (applicationConfigsById) => {
|
|
|
1025
1021
|
);
|
|
1026
1022
|
});
|
|
1027
1023
|
if (errors.length) {
|
|
1028
|
-
throw new
|
|
1024
|
+
throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
|
|
1029
1025
|
type: "config",
|
|
1030
1026
|
subtype: "conflicting_paths"
|
|
1031
1027
|
});
|
|
@@ -1059,13 +1055,13 @@ function validatePathExpression(path3) {
|
|
|
1059
1055
|
var validateDefaults = (applicationConfigsById) => {
|
|
1060
1056
|
const defaultApplicationIds = Object.entries(applicationConfigsById).reduce((acc, [id, app]) => app.default ? [...acc, id] : acc, []);
|
|
1061
1057
|
if (defaultApplicationIds.length === 0) {
|
|
1062
|
-
throw new
|
|
1058
|
+
throw new MicrofrontendError(
|
|
1063
1059
|
`No default application found. At least one application must be marked as default.`,
|
|
1064
1060
|
{ type: "config", subtype: "no_default_application" }
|
|
1065
1061
|
);
|
|
1066
1062
|
}
|
|
1067
1063
|
if (defaultApplicationIds.length > 1) {
|
|
1068
|
-
throw new
|
|
1064
|
+
throw new MicrofrontendError(
|
|
1069
1065
|
`Only one default application is allowed. Found ${defaultApplicationIds.join(", ")}.`,
|
|
1070
1066
|
{ type: "config", subtype: "multiple_default_applications" }
|
|
1071
1067
|
);
|
|
@@ -1077,7 +1073,7 @@ var validateOptions = (options) => {
|
|
|
1077
1073
|
if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
|
|
1078
1074
|
options.vercel.previewDeploymentSuffix
|
|
1079
1075
|
)) {
|
|
1080
|
-
throw new
|
|
1076
|
+
throw new MicrofrontendError(
|
|
1081
1077
|
`Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
|
|
1082
1078
|
{ type: "config", subtype: "invalid_preview_deployment_suffix" }
|
|
1083
1079
|
);
|
|
@@ -1088,11 +1084,10 @@ var validateOptions = (options) => {
|
|
|
1088
1084
|
// src/config/utils/convert.ts
|
|
1089
1085
|
function convertV1RoutingToV2Routing(routing) {
|
|
1090
1086
|
return routing.matches.map((group) => {
|
|
1091
|
-
var _a
|
|
1087
|
+
var _a;
|
|
1092
1088
|
return {
|
|
1093
1089
|
group: group.group,
|
|
1094
1090
|
flag: (_a = group.options) == null ? void 0 : _a.flag,
|
|
1095
|
-
routeToDefaultApplication: (_b = group.options) == null ? void 0 : _b.routeToDefaultApplication,
|
|
1096
1091
|
paths: group.paths
|
|
1097
1092
|
};
|
|
1098
1093
|
});
|
|
@@ -1132,9 +1127,15 @@ function convertV1ConfigToV2Config(config, fromApp) {
|
|
|
1132
1127
|
)
|
|
1133
1128
|
};
|
|
1134
1129
|
}
|
|
1130
|
+
const defaultApplication = Object.entries(config.applications).find(
|
|
1131
|
+
([, application]) => application.default
|
|
1132
|
+
);
|
|
1133
|
+
if (!defaultApplication) {
|
|
1134
|
+
throw new Error("No default application found in the config");
|
|
1135
|
+
}
|
|
1135
1136
|
return {
|
|
1136
1137
|
...common,
|
|
1137
|
-
partOf:
|
|
1138
|
+
partOf: defaultApplication[0]
|
|
1138
1139
|
};
|
|
1139
1140
|
}
|
|
1140
1141
|
|
|
@@ -1149,8 +1150,8 @@ function writeFile(outputPath, config, prettify) {
|
|
|
1149
1150
|
);
|
|
1150
1151
|
}
|
|
1151
1152
|
|
|
1152
|
-
// src/config/
|
|
1153
|
-
var
|
|
1153
|
+
// src/config/microfrontend-config.ts
|
|
1154
|
+
var MicrofrontendConfig = class extends MicrofrontendConfigCommon {
|
|
1154
1155
|
static validate(configString) {
|
|
1155
1156
|
const config = validateSchema(configString);
|
|
1156
1157
|
validateVersion(config.version);
|
|
@@ -1163,9 +1164,9 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1163
1164
|
static fromEnv({
|
|
1164
1165
|
cookies
|
|
1165
1166
|
}) {
|
|
1166
|
-
return new
|
|
1167
|
-
config:
|
|
1168
|
-
|
|
1167
|
+
return new MicrofrontendConfigCommon({
|
|
1168
|
+
config: MicrofrontendConfig.validate(
|
|
1169
|
+
MicrofrontendConfigCommon.getConfigFromEnv()
|
|
1169
1170
|
),
|
|
1170
1171
|
overrides: Overrides.parseOverrides(cookies)
|
|
1171
1172
|
});
|
|
@@ -1175,11 +1176,11 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1175
1176
|
}) {
|
|
1176
1177
|
try {
|
|
1177
1178
|
const config = fs2.readFileSync(filePath, "utf-8");
|
|
1178
|
-
return new
|
|
1179
|
-
config:
|
|
1179
|
+
return new MicrofrontendConfig({
|
|
1180
|
+
config: MicrofrontendConfig.validate(config)
|
|
1180
1181
|
});
|
|
1181
1182
|
} catch (e) {
|
|
1182
|
-
throw
|
|
1183
|
+
throw MicrofrontendError.handle(e, {
|
|
1183
1184
|
fileName: filePath
|
|
1184
1185
|
});
|
|
1185
1186
|
}
|
|
@@ -1202,7 +1203,7 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1202
1203
|
}
|
|
1203
1204
|
};
|
|
1204
1205
|
export {
|
|
1205
|
-
|
|
1206
|
+
MicrofrontendConfig,
|
|
1206
1207
|
getClientConfigFromEnv,
|
|
1207
1208
|
getConfigForClient,
|
|
1208
1209
|
getWellKnownClientData,
|