@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.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/config/index.ts
|
|
31
31
|
var config_exports = {};
|
|
32
32
|
__export(config_exports, {
|
|
33
|
-
|
|
33
|
+
MicrofrontendConfig: () => MicrofrontendConfig,
|
|
34
34
|
getClientConfigFromEnv: () => getClientConfigFromEnv,
|
|
35
35
|
getConfigForClient: () => getConfigForClient,
|
|
36
36
|
getWellKnownClientData: () => getWellKnownClientData,
|
|
@@ -102,7 +102,7 @@ async function getWellKnownClientData(flagValues = {}) {
|
|
|
102
102
|
var isCommonApplicationConfig = (app) => !app.default && typeof app.routing === "object";
|
|
103
103
|
var isDefaultApplicationConfig = (app) => app.default && typeof app.routing === "undefined";
|
|
104
104
|
|
|
105
|
-
// src/config/
|
|
105
|
+
// src/config/microfrontend-config.ts
|
|
106
106
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
107
107
|
|
|
108
108
|
// src/config-v2/microfrontends/server/utils/get-output-file-path.ts
|
|
@@ -130,14 +130,14 @@ function getOutputFilePath() {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// src/config/errors.ts
|
|
133
|
-
var
|
|
133
|
+
var MicrofrontendError = class extends Error {
|
|
134
134
|
constructor(message, opts) {
|
|
135
135
|
super(message);
|
|
136
|
-
this.name = "
|
|
137
|
-
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/
|
|
136
|
+
this.name = "MicrofrontendsError";
|
|
137
|
+
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
|
|
138
138
|
this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
|
|
139
139
|
this.subtype = opts == null ? void 0 : opts.subtype;
|
|
140
|
-
Error.captureStackTrace(this,
|
|
140
|
+
Error.captureStackTrace(this, MicrofrontendError);
|
|
141
141
|
}
|
|
142
142
|
isKnown() {
|
|
143
143
|
return this.type !== "unknown";
|
|
@@ -146,13 +146,13 @@ var MicroFrontendError = class extends Error {
|
|
|
146
146
|
return !this.isKnown();
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* Converts an error to a
|
|
149
|
+
* Converts an error to a MicrofrontendsError.
|
|
150
150
|
* @param original - The original error to convert.
|
|
151
|
-
* @returns The converted
|
|
151
|
+
* @returns The converted MicrofrontendsError.
|
|
152
152
|
*/
|
|
153
153
|
static convert(original, opts) {
|
|
154
154
|
if (opts == null ? void 0 : opts.fileName) {
|
|
155
|
-
const err =
|
|
155
|
+
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
156
156
|
if (err) {
|
|
157
157
|
return err;
|
|
158
158
|
}
|
|
@@ -160,25 +160,25 @@ var MicroFrontendError = class extends Error {
|
|
|
160
160
|
if (original.message.includes(
|
|
161
161
|
"Code generation from strings disallowed for this context"
|
|
162
162
|
)) {
|
|
163
|
-
return new
|
|
163
|
+
return new MicrofrontendError(original.message, {
|
|
164
164
|
type: "config",
|
|
165
165
|
subtype: "unsupported_validation_env",
|
|
166
166
|
source: "ajv"
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
return new
|
|
169
|
+
return new MicrofrontendError(original.message);
|
|
170
170
|
}
|
|
171
171
|
static convertFSError(original, fileName) {
|
|
172
172
|
if (original instanceof Error && "code" in original) {
|
|
173
173
|
if (original.code === "ENOENT") {
|
|
174
|
-
return new
|
|
174
|
+
return new MicrofrontendError(`Could not find "${fileName}"`, {
|
|
175
175
|
type: "config",
|
|
176
176
|
subtype: "unable_to_read_file",
|
|
177
177
|
source: "fs"
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
if (original.code === "EACCES") {
|
|
181
|
-
return new
|
|
181
|
+
return new MicrofrontendError(
|
|
182
182
|
`Permission denied while accessing "${fileName}"`,
|
|
183
183
|
{
|
|
184
184
|
type: "config",
|
|
@@ -189,7 +189,7 @@ var MicroFrontendError = class extends Error {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
if (original instanceof SyntaxError) {
|
|
192
|
-
return new
|
|
192
|
+
return new MicrofrontendError(
|
|
193
193
|
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
194
194
|
{
|
|
195
195
|
type: "config",
|
|
@@ -201,23 +201,23 @@ var MicroFrontendError = class extends Error {
|
|
|
201
201
|
return null;
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
|
-
* Handles an unknown error and returns a
|
|
204
|
+
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
205
205
|
* @param err - The error to handle.
|
|
206
|
-
* @returns A
|
|
206
|
+
* @returns A MicrofrontendsError instance.
|
|
207
207
|
*/
|
|
208
208
|
static handle(err, opts) {
|
|
209
|
-
if (err instanceof
|
|
209
|
+
if (err instanceof MicrofrontendError) {
|
|
210
210
|
return err;
|
|
211
211
|
}
|
|
212
212
|
if (err instanceof Error) {
|
|
213
|
-
return
|
|
213
|
+
return MicrofrontendError.convert(err, opts);
|
|
214
214
|
}
|
|
215
215
|
if (typeof err === "object" && err !== null) {
|
|
216
216
|
if ("message" in err && typeof err.message === "string") {
|
|
217
|
-
return
|
|
217
|
+
return MicrofrontendError.convert(new Error(err.message), opts);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
return new
|
|
220
|
+
return new MicrofrontendError("An unknown error occurred");
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
|
|
@@ -300,27 +300,27 @@ var _Overrides = class {
|
|
|
300
300
|
});
|
|
301
301
|
return overridesConfig;
|
|
302
302
|
}
|
|
303
|
-
static validOverrideDomainsForZone(
|
|
303
|
+
static validOverrideDomainsForZone(microfrontendConfig, zone) {
|
|
304
304
|
var _a, _b, _c, _d, _e;
|
|
305
|
-
const projectName = (_a =
|
|
305
|
+
const projectName = (_a = microfrontendConfig.getZone(zone).vercel) == null ? void 0 : _a.projectName;
|
|
306
306
|
if (!projectName) {
|
|
307
|
-
return [
|
|
307
|
+
return [microfrontendConfig.getZone(zone).production.host];
|
|
308
308
|
}
|
|
309
309
|
const parsedProjectName = makeUrlSafe(projectName);
|
|
310
|
-
const previewDeploymentSuffix = (_c = (_b =
|
|
311
|
-
const teamSlug = (_e = (_d =
|
|
310
|
+
const previewDeploymentSuffix = (_c = (_b = microfrontendConfig.options) == null ? void 0 : _b.vercel) == null ? void 0 : _c.previewDeploymentSuffix;
|
|
311
|
+
const teamSlug = (_e = (_d = microfrontendConfig.options) == null ? void 0 : _d.vercel) == null ? void 0 : _e.teamSlug;
|
|
312
312
|
if (!teamSlug && !previewDeploymentSuffix) {
|
|
313
|
-
return [
|
|
313
|
+
return [microfrontendConfig.getZone(zone).production.host];
|
|
314
314
|
}
|
|
315
315
|
const suffix = previewDeploymentSuffix ? `.${previewDeploymentSuffix}` : `-${teamSlug}.vercel.app`;
|
|
316
316
|
return [
|
|
317
317
|
`${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,
|
|
318
|
-
|
|
318
|
+
microfrontendConfig.getZone(zone).production.host
|
|
319
319
|
];
|
|
320
320
|
}
|
|
321
|
-
static validateOverrideDomain(
|
|
321
|
+
static validateOverrideDomain(microfrontendConfig, zone, domain) {
|
|
322
322
|
return new RegExp(
|
|
323
|
-
`^${_Overrides.validOverrideDomainsForZone(
|
|
323
|
+
`^${_Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(
|
|
324
324
|
"|"
|
|
325
325
|
)}$`
|
|
326
326
|
).test(domain);
|
|
@@ -402,7 +402,7 @@ var Application = class {
|
|
|
402
402
|
static validate(name, app) {
|
|
403
403
|
var _a, _b, _c, _d, _e;
|
|
404
404
|
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("/"))) {
|
|
405
|
-
throw new
|
|
405
|
+
throw new MicrofrontendError(
|
|
406
406
|
`Invalid assetPrefix for application "${name}". Must not start or end with a slash.`,
|
|
407
407
|
{ type: "zone", subtype: "invalid_asset_prefix" }
|
|
408
408
|
);
|
|
@@ -413,13 +413,13 @@ var Application = class {
|
|
|
413
413
|
continue;
|
|
414
414
|
}
|
|
415
415
|
if (p.endsWith("/")) {
|
|
416
|
-
throw new
|
|
416
|
+
throw new MicrofrontendError(
|
|
417
417
|
`Invalid path for application "${name}". ${p} must not end with a slash.`,
|
|
418
418
|
{ type: "zone", subtype: "invalid_path" }
|
|
419
419
|
);
|
|
420
420
|
}
|
|
421
421
|
if (!p.startsWith("/")) {
|
|
422
|
-
throw new
|
|
422
|
+
throw new MicrofrontendError(
|
|
423
423
|
`Invalid path for application "${name}". ${p} must start with a slash.`,
|
|
424
424
|
{ type: "zone", subtype: "invalid_path" }
|
|
425
425
|
);
|
|
@@ -453,10 +453,10 @@ var Application = class {
|
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
455
|
|
|
456
|
-
// src/config/common/
|
|
456
|
+
// src/config/common/microfrontend-config.ts
|
|
457
457
|
var SUPPORTED_VERSIONS = ["1"];
|
|
458
458
|
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
459
|
-
var
|
|
459
|
+
var MicrofrontendConfigCommon = class {
|
|
460
460
|
constructor({
|
|
461
461
|
config,
|
|
462
462
|
overrides
|
|
@@ -464,7 +464,7 @@ var MicroFrontendConfigCommon = class {
|
|
|
464
464
|
this.zones = {};
|
|
465
465
|
var _a, _b, _c;
|
|
466
466
|
if (!SUPPORTED_VERSIONS.includes(config.version)) {
|
|
467
|
-
throw new
|
|
467
|
+
throw new MicrofrontendError(
|
|
468
468
|
`Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
|
|
469
469
|
", "
|
|
470
470
|
)}`,
|
|
@@ -492,7 +492,7 @@ var MicroFrontendConfigCommon = class {
|
|
|
492
492
|
static getConfigFromEnv() {
|
|
493
493
|
const config = process.env.MFE_CONFIG;
|
|
494
494
|
if (!config) {
|
|
495
|
-
throw new
|
|
495
|
+
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
496
496
|
type: "config",
|
|
497
497
|
subtype: "not_found_in_env"
|
|
498
498
|
});
|
|
@@ -511,8 +511,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
511
511
|
getZone(name) {
|
|
512
512
|
const zone = this.zones[name];
|
|
513
513
|
if (!zone) {
|
|
514
|
-
throw new
|
|
515
|
-
`Could not find
|
|
514
|
+
throw new MicrofrontendError(
|
|
515
|
+
`Could not find microfrontends configuration for application "${name}"`,
|
|
516
516
|
{
|
|
517
517
|
type: "zone",
|
|
518
518
|
subtype: "not_found"
|
|
@@ -532,8 +532,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
532
532
|
getDefaultZone() {
|
|
533
533
|
const zone = Object.values(this.zones).find((z) => z.default);
|
|
534
534
|
if (!zone) {
|
|
535
|
-
throw new
|
|
536
|
-
`Could not find default zone in
|
|
535
|
+
throw new MicrofrontendError(
|
|
536
|
+
`Could not find default zone in microfrontends configuration`,
|
|
537
537
|
{
|
|
538
538
|
type: "zone",
|
|
539
539
|
subtype: "not_found"
|
|
@@ -585,8 +585,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
585
585
|
};
|
|
586
586
|
}
|
|
587
587
|
write(_) {
|
|
588
|
-
throw new
|
|
589
|
-
`Writing to file to disk requires using an instance of "
|
|
588
|
+
throw new MicrofrontendError(
|
|
589
|
+
`Writing to file to disk requires using an instance of "MicrofrontendConfig".`,
|
|
590
590
|
{ type: "config", subtype: "unsupported_operation" }
|
|
591
591
|
);
|
|
592
592
|
}
|
|
@@ -765,10 +765,6 @@ var schema_default = {
|
|
|
765
765
|
flag: {
|
|
766
766
|
type: "string",
|
|
767
767
|
description: "flag name that can be used to enable/disable all paths in the group"
|
|
768
|
-
},
|
|
769
|
-
routeToDefaultApplication: {
|
|
770
|
-
type: "boolean",
|
|
771
|
-
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."
|
|
772
768
|
}
|
|
773
769
|
}
|
|
774
770
|
},
|
|
@@ -947,7 +943,7 @@ var validateSchema = (configString) => {
|
|
|
947
943
|
const validate = ajv.compile(SCHEMA);
|
|
948
944
|
const isValid = validate(parsedConfig);
|
|
949
945
|
if (!isValid) {
|
|
950
|
-
throw new
|
|
946
|
+
throw new MicrofrontendError(
|
|
951
947
|
`Invalid config: ${ajv.errorsText(validate.errors)}`,
|
|
952
948
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
953
949
|
);
|
|
@@ -957,7 +953,7 @@ var validateSchema = (configString) => {
|
|
|
957
953
|
var SUPPORTED_VERSIONS2 = ["1"];
|
|
958
954
|
var validateVersion = (version) => {
|
|
959
955
|
if (!SUPPORTED_VERSIONS2.includes(version)) {
|
|
960
|
-
throw new
|
|
956
|
+
throw new MicrofrontendError(
|
|
961
957
|
`Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS2.join(
|
|
962
958
|
", "
|
|
963
959
|
)}`,
|
|
@@ -990,7 +986,7 @@ function validateMainPath(applicationConfigsById) {
|
|
|
990
986
|
return !matcher.test(defaultRoute);
|
|
991
987
|
});
|
|
992
988
|
if (!isValid) {
|
|
993
|
-
throw new
|
|
989
|
+
throw new MicrofrontendError(
|
|
994
990
|
`default route "${defaultRoute}" cannot be used for "${id}" because it is matched by "${otherId}"`,
|
|
995
991
|
{ type: "config", subtype: "invalid_main_path" }
|
|
996
992
|
);
|
|
@@ -1003,7 +999,7 @@ function validateMainPath(applicationConfigsById) {
|
|
|
1003
999
|
return matcher.test(defaultRoute);
|
|
1004
1000
|
});
|
|
1005
1001
|
if (!isValid) {
|
|
1006
|
-
throw new
|
|
1002
|
+
throw new MicrofrontendError(
|
|
1007
1003
|
`default route "${defaultRoute}" is not included by the routing config for application "${id}"`,
|
|
1008
1004
|
{ type: "config", subtype: "invalid_main_path" }
|
|
1009
1005
|
);
|
|
@@ -1066,7 +1062,7 @@ var validatePaths = (applicationConfigsById) => {
|
|
|
1066
1062
|
);
|
|
1067
1063
|
});
|
|
1068
1064
|
if (errors.length) {
|
|
1069
|
-
throw new
|
|
1065
|
+
throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
|
|
1070
1066
|
type: "config",
|
|
1071
1067
|
subtype: "conflicting_paths"
|
|
1072
1068
|
});
|
|
@@ -1100,13 +1096,13 @@ function validatePathExpression(path3) {
|
|
|
1100
1096
|
var validateDefaults = (applicationConfigsById) => {
|
|
1101
1097
|
const defaultApplicationIds = Object.entries(applicationConfigsById).reduce((acc, [id, app]) => app.default ? [...acc, id] : acc, []);
|
|
1102
1098
|
if (defaultApplicationIds.length === 0) {
|
|
1103
|
-
throw new
|
|
1099
|
+
throw new MicrofrontendError(
|
|
1104
1100
|
`No default application found. At least one application must be marked as default.`,
|
|
1105
1101
|
{ type: "config", subtype: "no_default_application" }
|
|
1106
1102
|
);
|
|
1107
1103
|
}
|
|
1108
1104
|
if (defaultApplicationIds.length > 1) {
|
|
1109
|
-
throw new
|
|
1105
|
+
throw new MicrofrontendError(
|
|
1110
1106
|
`Only one default application is allowed. Found ${defaultApplicationIds.join(", ")}.`,
|
|
1111
1107
|
{ type: "config", subtype: "multiple_default_applications" }
|
|
1112
1108
|
);
|
|
@@ -1118,7 +1114,7 @@ var validateOptions = (options) => {
|
|
|
1118
1114
|
if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
|
|
1119
1115
|
options.vercel.previewDeploymentSuffix
|
|
1120
1116
|
)) {
|
|
1121
|
-
throw new
|
|
1117
|
+
throw new MicrofrontendError(
|
|
1122
1118
|
`Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
|
|
1123
1119
|
{ type: "config", subtype: "invalid_preview_deployment_suffix" }
|
|
1124
1120
|
);
|
|
@@ -1129,11 +1125,10 @@ var validateOptions = (options) => {
|
|
|
1129
1125
|
// src/config/utils/convert.ts
|
|
1130
1126
|
function convertV1RoutingToV2Routing(routing) {
|
|
1131
1127
|
return routing.matches.map((group) => {
|
|
1132
|
-
var _a
|
|
1128
|
+
var _a;
|
|
1133
1129
|
return {
|
|
1134
1130
|
group: group.group,
|
|
1135
1131
|
flag: (_a = group.options) == null ? void 0 : _a.flag,
|
|
1136
|
-
routeToDefaultApplication: (_b = group.options) == null ? void 0 : _b.routeToDefaultApplication,
|
|
1137
1132
|
paths: group.paths
|
|
1138
1133
|
};
|
|
1139
1134
|
});
|
|
@@ -1173,9 +1168,15 @@ function convertV1ConfigToV2Config(config, fromApp) {
|
|
|
1173
1168
|
)
|
|
1174
1169
|
};
|
|
1175
1170
|
}
|
|
1171
|
+
const defaultApplication = Object.entries(config.applications).find(
|
|
1172
|
+
([, application]) => application.default
|
|
1173
|
+
);
|
|
1174
|
+
if (!defaultApplication) {
|
|
1175
|
+
throw new Error("No default application found in the config");
|
|
1176
|
+
}
|
|
1176
1177
|
return {
|
|
1177
1178
|
...common,
|
|
1178
|
-
partOf:
|
|
1179
|
+
partOf: defaultApplication[0]
|
|
1179
1180
|
};
|
|
1180
1181
|
}
|
|
1181
1182
|
|
|
@@ -1190,8 +1191,8 @@ function writeFile(outputPath, config, prettify) {
|
|
|
1190
1191
|
);
|
|
1191
1192
|
}
|
|
1192
1193
|
|
|
1193
|
-
// src/config/
|
|
1194
|
-
var
|
|
1194
|
+
// src/config/microfrontend-config.ts
|
|
1195
|
+
var MicrofrontendConfig = class extends MicrofrontendConfigCommon {
|
|
1195
1196
|
static validate(configString) {
|
|
1196
1197
|
const config = validateSchema(configString);
|
|
1197
1198
|
validateVersion(config.version);
|
|
@@ -1204,9 +1205,9 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1204
1205
|
static fromEnv({
|
|
1205
1206
|
cookies
|
|
1206
1207
|
}) {
|
|
1207
|
-
return new
|
|
1208
|
-
config:
|
|
1209
|
-
|
|
1208
|
+
return new MicrofrontendConfigCommon({
|
|
1209
|
+
config: MicrofrontendConfig.validate(
|
|
1210
|
+
MicrofrontendConfigCommon.getConfigFromEnv()
|
|
1210
1211
|
),
|
|
1211
1212
|
overrides: Overrides.parseOverrides(cookies)
|
|
1212
1213
|
});
|
|
@@ -1216,11 +1217,11 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1216
1217
|
}) {
|
|
1217
1218
|
try {
|
|
1218
1219
|
const config = import_node_fs2.default.readFileSync(filePath, "utf-8");
|
|
1219
|
-
return new
|
|
1220
|
-
config:
|
|
1220
|
+
return new MicrofrontendConfig({
|
|
1221
|
+
config: MicrofrontendConfig.validate(config)
|
|
1221
1222
|
});
|
|
1222
1223
|
} catch (e) {
|
|
1223
|
-
throw
|
|
1224
|
+
throw MicrofrontendError.handle(e, {
|
|
1224
1225
|
fileName: filePath
|
|
1225
1226
|
});
|
|
1226
1227
|
}
|
|
@@ -1244,7 +1245,7 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1244
1245
|
};
|
|
1245
1246
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1246
1247
|
0 && (module.exports = {
|
|
1247
|
-
|
|
1248
|
+
MicrofrontendConfig,
|
|
1248
1249
|
getClientConfigFromEnv,
|
|
1249
1250
|
getConfigForClient,
|
|
1250
1251
|
getWellKnownClientData,
|