@vercel/microfrontends 1.1.1-canary.2 → 1.1.1-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.cjs +303 -512
- package/dist/config.cjs +43 -71
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +153 -4
- package/dist/config.js +43 -71
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +296 -489
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +286 -479
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +326 -511
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +312 -497
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +295 -485
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +14 -20
- package/dist/microfrontends/server.js +285 -475
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/next/config.cjs +297 -498
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +287 -488
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.cjs +2 -0
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.d.ts +13 -3
- package/dist/next/endpoints.js +1 -0
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +58 -171
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +2 -4
- package/dist/next/middleware.js +58 -171
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +44 -73
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +44 -73
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.cjs +2 -9
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +3 -4
- package/dist/schema.js +1 -7
- package/dist/schema.js.map +1 -1
- package/dist/{types-6ee19ccc.d.ts → types-54064641.d.ts} +2 -13
- package/dist/{types-73527280.d.ts → types-a4add5ab.d.ts} +1 -1
- package/dist/{types-74e3336c.d.ts → types-f1260e44.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +300 -492
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +286 -478
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +49 -37
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +49 -37
- package/dist/validation.js.map +1 -1
- package/package.json +2 -9
- package/schema/schema.json +0 -33
- package/dist/index-7e69650e.d.ts +0 -165
- package/dist/microfrontends.cjs +0 -962
- package/dist/microfrontends.cjs.map +0 -1
- package/dist/microfrontends.d.ts +0 -45
- package/dist/microfrontends.js +0 -935
- package/dist/microfrontends.js.map +0 -1
package/dist/microfrontends.cjs
DELETED
|
@@ -1,962 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/config/microfrontends/isomorphic/index.ts
|
|
21
|
-
var isomorphic_exports = {};
|
|
22
|
-
__export(isomorphic_exports, {
|
|
23
|
-
Microfrontends: () => Microfrontends
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(isomorphic_exports);
|
|
26
|
-
|
|
27
|
-
// src/config/microfrontends-config/isomorphic/index.ts
|
|
28
|
-
var import_jsonc_parser = require("jsonc-parser");
|
|
29
|
-
|
|
30
|
-
// src/config/errors.ts
|
|
31
|
-
var MicrofrontendError = class extends Error {
|
|
32
|
-
constructor(message, opts) {
|
|
33
|
-
super(message, { cause: opts?.cause });
|
|
34
|
-
this.name = "MicrofrontendsError";
|
|
35
|
-
this.source = opts?.source ?? "@vercel/microfrontends";
|
|
36
|
-
this.type = opts?.type ?? "unknown";
|
|
37
|
-
this.subtype = opts?.subtype;
|
|
38
|
-
Error.captureStackTrace(this, MicrofrontendError);
|
|
39
|
-
}
|
|
40
|
-
isKnown() {
|
|
41
|
-
return this.type !== "unknown";
|
|
42
|
-
}
|
|
43
|
-
isUnknown() {
|
|
44
|
-
return !this.isKnown();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Converts an error to a MicrofrontendsError.
|
|
48
|
-
* @param original - The original error to convert.
|
|
49
|
-
* @returns The converted MicrofrontendsError.
|
|
50
|
-
*/
|
|
51
|
-
static convert(original, opts) {
|
|
52
|
-
if (opts?.fileName) {
|
|
53
|
-
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
54
|
-
if (err) {
|
|
55
|
-
return err;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (original.message.includes(
|
|
59
|
-
"Code generation from strings disallowed for this context"
|
|
60
|
-
)) {
|
|
61
|
-
return new MicrofrontendError(original.message, {
|
|
62
|
-
type: "config",
|
|
63
|
-
subtype: "unsupported_validation_env",
|
|
64
|
-
source: "ajv"
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return new MicrofrontendError(original.message);
|
|
68
|
-
}
|
|
69
|
-
static convertFSError(original, fileName) {
|
|
70
|
-
if (original instanceof Error && "code" in original) {
|
|
71
|
-
if (original.code === "ENOENT") {
|
|
72
|
-
return new MicrofrontendError(`Could not find "${fileName}"`, {
|
|
73
|
-
type: "config",
|
|
74
|
-
subtype: "unable_to_read_file",
|
|
75
|
-
source: "fs"
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (original.code === "EACCES") {
|
|
79
|
-
return new MicrofrontendError(
|
|
80
|
-
`Permission denied while accessing "${fileName}"`,
|
|
81
|
-
{
|
|
82
|
-
type: "config",
|
|
83
|
-
subtype: "invalid_permissions",
|
|
84
|
-
source: "fs"
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (original instanceof SyntaxError) {
|
|
90
|
-
return new MicrofrontendError(
|
|
91
|
-
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
92
|
-
{
|
|
93
|
-
type: "config",
|
|
94
|
-
subtype: "invalid_syntax",
|
|
95
|
-
source: "fs"
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
103
|
-
* @param err - The error to handle.
|
|
104
|
-
* @returns A MicrofrontendsError instance.
|
|
105
|
-
*/
|
|
106
|
-
static handle(err, opts) {
|
|
107
|
-
if (err instanceof MicrofrontendError) {
|
|
108
|
-
return err;
|
|
109
|
-
}
|
|
110
|
-
if (err instanceof Error) {
|
|
111
|
-
return MicrofrontendError.convert(err, opts);
|
|
112
|
-
}
|
|
113
|
-
if (typeof err === "object" && err !== null) {
|
|
114
|
-
if ("message" in err && typeof err.message === "string") {
|
|
115
|
-
return MicrofrontendError.convert(new Error(err.message), opts);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return new MicrofrontendError("An unknown error occurred");
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// src/config/microfrontends-config/utils/get-config-from-env.ts
|
|
123
|
-
function getConfigStringFromEnv() {
|
|
124
|
-
const config = process.env.MFE_CONFIG;
|
|
125
|
-
if (!config) {
|
|
126
|
-
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
127
|
-
type: "config",
|
|
128
|
-
subtype: "not_found_in_env"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return config;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/config/schema/utils/is-main-config.ts
|
|
135
|
-
function isMainConfig(c) {
|
|
136
|
-
return !("partOf" in c);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/config/schema/utils/is-default-app.ts
|
|
140
|
-
function isDefaultApp(a) {
|
|
141
|
-
return !("routing" in a);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// src/config/microfrontends-config/client/index.ts
|
|
145
|
-
var import_path_to_regexp = require("path-to-regexp");
|
|
146
|
-
var MicrofrontendConfigClient = class {
|
|
147
|
-
constructor(config, opts) {
|
|
148
|
-
this.pathCache = {};
|
|
149
|
-
this.serialized = config;
|
|
150
|
-
if (opts?.removeFlaggedPaths) {
|
|
151
|
-
for (const app of Object.values(config.applications)) {
|
|
152
|
-
if (app.routing) {
|
|
153
|
-
app.routing = app.routing.filter((match) => !match.flag);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
this.applications = config.applications;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Create a new `MicrofrontendConfigClient` from a JSON string.
|
|
161
|
-
* Config must be passed in to remain framework agnostic
|
|
162
|
-
*/
|
|
163
|
-
static fromEnv(config, opts) {
|
|
164
|
-
if (!config) {
|
|
165
|
-
throw new Error("No microfrontends configuration found");
|
|
166
|
-
}
|
|
167
|
-
return new MicrofrontendConfigClient(
|
|
168
|
-
JSON.parse(config),
|
|
169
|
-
opts
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
isEqual(other) {
|
|
173
|
-
return JSON.stringify(this.applications) === JSON.stringify(other.applications);
|
|
174
|
-
}
|
|
175
|
-
getApplicationNameForPath(path) {
|
|
176
|
-
if (!path.startsWith("/")) {
|
|
177
|
-
throw new Error(`Path must start with a /`);
|
|
178
|
-
}
|
|
179
|
-
if (this.pathCache[path]) {
|
|
180
|
-
return this.pathCache[path];
|
|
181
|
-
}
|
|
182
|
-
const pathname = new URL(path, "https://example.com").pathname;
|
|
183
|
-
for (const [name, application] of Object.entries(this.applications)) {
|
|
184
|
-
if (application.routing) {
|
|
185
|
-
for (const group of application.routing) {
|
|
186
|
-
for (const childPath of group.paths) {
|
|
187
|
-
const regexp = (0, import_path_to_regexp.pathToRegexp)(childPath);
|
|
188
|
-
if (regexp.test(pathname)) {
|
|
189
|
-
this.pathCache[path] = name;
|
|
190
|
-
return name;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const defaultApplication = Object.entries(this.applications).find(
|
|
197
|
-
([, application]) => application.default
|
|
198
|
-
);
|
|
199
|
-
if (!defaultApplication) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
this.pathCache[path] = defaultApplication[0];
|
|
203
|
-
return defaultApplication[0];
|
|
204
|
-
}
|
|
205
|
-
serialize() {
|
|
206
|
-
return this.serialized;
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
// src/config/overrides/constants.ts
|
|
211
|
-
var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
|
|
212
|
-
var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
|
|
213
|
-
|
|
214
|
-
// src/config/overrides/is-override-cookie.ts
|
|
215
|
-
function isOverrideCookie(cookie) {
|
|
216
|
-
return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// src/config/overrides/get-override-from-cookie.ts
|
|
220
|
-
function getOverrideFromCookie(cookie) {
|
|
221
|
-
if (!isOverrideCookie(cookie) || !cookie.value)
|
|
222
|
-
return;
|
|
223
|
-
return {
|
|
224
|
-
application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ""),
|
|
225
|
-
host: cookie.value
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// src/config/overrides/parse-overrides.ts
|
|
230
|
-
function parseOverrides(cookies) {
|
|
231
|
-
const overridesConfig = { applications: {} };
|
|
232
|
-
cookies.forEach((cookie) => {
|
|
233
|
-
const override = getOverrideFromCookie(cookie);
|
|
234
|
-
if (!override)
|
|
235
|
-
return;
|
|
236
|
-
overridesConfig.applications[override.application] = {
|
|
237
|
-
environment: { host: override.host }
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
return overridesConfig;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// src/config/microfrontends-config/isomorphic/validation.ts
|
|
244
|
-
var import_path_to_regexp2 = require("path-to-regexp");
|
|
245
|
-
var validateConfigPaths = (applicationConfigsById) => {
|
|
246
|
-
if (!applicationConfigsById) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const pathsByApplicationId = /* @__PURE__ */ new Map();
|
|
250
|
-
const errors = [];
|
|
251
|
-
for (const [id, app] of Object.entries(applicationConfigsById)) {
|
|
252
|
-
if (isDefaultApp(app)) {
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
const childApp = app;
|
|
256
|
-
for (const pathMatch of childApp.routing) {
|
|
257
|
-
for (const path of pathMatch.paths) {
|
|
258
|
-
const maybeError = validatePathExpression(path);
|
|
259
|
-
if (maybeError) {
|
|
260
|
-
errors.push(maybeError);
|
|
261
|
-
} else {
|
|
262
|
-
const existing = pathsByApplicationId.get(path);
|
|
263
|
-
if (existing) {
|
|
264
|
-
existing.applications.push(id);
|
|
265
|
-
} else {
|
|
266
|
-
pathsByApplicationId.set(path, {
|
|
267
|
-
applications: [id],
|
|
268
|
-
matcher: (0, import_path_to_regexp2.pathToRegexp)(path),
|
|
269
|
-
applicationId: id
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
const entries = Array.from(pathsByApplicationId.entries());
|
|
277
|
-
for (const [path, { applications: ids, matcher, applicationId }] of entries) {
|
|
278
|
-
if (ids.length > 1) {
|
|
279
|
-
errors.push(
|
|
280
|
-
`Duplicate path "${path}" for applications "${ids.join(", ")}"`
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
for (const [
|
|
284
|
-
matchPath,
|
|
285
|
-
{ applications: matchIds, applicationId: matchApplicationId }
|
|
286
|
-
] of entries) {
|
|
287
|
-
if (path === matchPath) {
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
if (applicationId === matchApplicationId) {
|
|
291
|
-
continue;
|
|
292
|
-
}
|
|
293
|
-
if (matcher.test(matchPath)) {
|
|
294
|
-
const source = `"${path}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
|
|
295
|
-
const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
|
|
296
|
-
errors.push(
|
|
297
|
-
`Overlapping path detected between ${source} and ${destination}`
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
if (errors.length) {
|
|
303
|
-
throw new MicrofrontendError(
|
|
304
|
-
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
305
|
-
{
|
|
306
|
-
type: "config",
|
|
307
|
-
subtype: "conflicting_paths"
|
|
308
|
-
}
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
313
|
-
function validatePathExpression(path) {
|
|
314
|
-
try {
|
|
315
|
-
const tokens = (0, import_path_to_regexp2.parse)(path);
|
|
316
|
-
if (/(?<!\\)\{/.test(path)) {
|
|
317
|
-
return `Optional paths are not supported: ${path}`;
|
|
318
|
-
}
|
|
319
|
-
if (/(?<!\\|\()\?/.test(path)) {
|
|
320
|
-
return `Optional paths are not supported: ${path}`;
|
|
321
|
-
}
|
|
322
|
-
if (/\/[^/]*(?<!\\):[^/]*(?<!\\):[^/]*/.test(path)) {
|
|
323
|
-
return `Only one wildcard is allowed per path segment: ${path}`;
|
|
324
|
-
}
|
|
325
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
326
|
-
const token = tokens[i];
|
|
327
|
-
if (token === void 0) {
|
|
328
|
-
return `token ${i} in ${path} is undefined, this shouldn't happen`;
|
|
329
|
-
}
|
|
330
|
-
if (typeof token !== "string") {
|
|
331
|
-
if (!token.name) {
|
|
332
|
-
return `Only named wildcards are allowed: ${path} (hint: add ":path" to the wildcard)`;
|
|
333
|
-
}
|
|
334
|
-
if (token.pattern !== PATH_DEFAULT_PATTERN && // Allows (a|b|c) and ((?!a|b|c).*) regex
|
|
335
|
-
// Only limited regex is supported for now, due to performance considerations
|
|
336
|
-
!/^(?<allowed>[\w]+(?:\|[^|()]+)+)$|^\(\?!(?<disallowed>[\w]+(?:\|[^|()]+)+)\)\.\*$/.test(
|
|
337
|
-
token.pattern
|
|
338
|
-
)) {
|
|
339
|
-
return `Path ${path} cannot use unsupported regular expression wildcard`;
|
|
340
|
-
}
|
|
341
|
-
if (token.modifier && i !== tokens.length - 1) {
|
|
342
|
-
return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path}. Modifiers are only allowed in the last path component`;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
} catch (e) {
|
|
347
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
348
|
-
return `Path ${path} could not be parsed into regexp: ${message}`;
|
|
349
|
-
}
|
|
350
|
-
return void 0;
|
|
351
|
-
}
|
|
352
|
-
var validateAppPaths = (name, app) => {
|
|
353
|
-
for (const group of app.routing) {
|
|
354
|
-
for (const p of group.paths) {
|
|
355
|
-
if (p === "/") {
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
if (p.endsWith("/")) {
|
|
359
|
-
throw new MicrofrontendError(
|
|
360
|
-
`Invalid path for application "${name}". ${p} must not end with a slash.`,
|
|
361
|
-
{ type: "application", subtype: "invalid_path" }
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
if (!p.startsWith("/")) {
|
|
365
|
-
throw new MicrofrontendError(
|
|
366
|
-
`Invalid path for application "${name}". ${p} must start with a slash.`,
|
|
367
|
-
{ type: "application", subtype: "invalid_path" }
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
374
|
-
if (!applicationConfigsById) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
const applicationsWithRouting = Object.entries(applicationConfigsById).filter(
|
|
378
|
-
([, app]) => !isDefaultApp(app)
|
|
379
|
-
);
|
|
380
|
-
const applicationsWithRoutingNames = applicationsWithRouting.map(
|
|
381
|
-
([key]) => key
|
|
382
|
-
);
|
|
383
|
-
const numApplications = Object.keys(applicationConfigsById).length;
|
|
384
|
-
const numApplicationsWithRouting = applicationsWithRoutingNames.length;
|
|
385
|
-
const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
|
|
386
|
-
if (numApplicationsWithoutRouting === 0) {
|
|
387
|
-
throw new MicrofrontendError(
|
|
388
|
-
"No default application found. At least one application needs to be the default by omitting routing.",
|
|
389
|
-
{ type: "config", subtype: "no_default_application" }
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
if (numApplicationsWithoutRouting > 1) {
|
|
393
|
-
throw new MicrofrontendError(
|
|
394
|
-
`Only one application can omit "routing". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,
|
|
395
|
-
{ type: "config", subtype: "multiple_default_applications" }
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
var validateDeprecatedFields = (config) => {
|
|
400
|
-
const errors = [];
|
|
401
|
-
if (config.options?.vercel) {
|
|
402
|
-
errors.push(
|
|
403
|
-
`Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
if (config.options?.localProxy) {
|
|
407
|
-
errors.push(
|
|
408
|
-
`Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
for (const [applicationId, application] of Object.entries(
|
|
412
|
-
config.applications
|
|
413
|
-
)) {
|
|
414
|
-
if (application.vercel) {
|
|
415
|
-
errors.push(
|
|
416
|
-
`Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
if (application.production) {
|
|
420
|
-
errors.push(
|
|
421
|
-
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
if (application.development?.localPort) {
|
|
425
|
-
errors.push(
|
|
426
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
430
|
-
const fallback = application.development.fallback;
|
|
431
|
-
let asString = fallback.host;
|
|
432
|
-
if (fallback.protocol) {
|
|
433
|
-
asString = `${fallback.protocol}://${asString}`;
|
|
434
|
-
}
|
|
435
|
-
if (fallback.port) {
|
|
436
|
-
asString = `${asString}:${fallback.port}`;
|
|
437
|
-
}
|
|
438
|
-
errors.push(
|
|
439
|
-
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
443
|
-
const local = application.development.local;
|
|
444
|
-
let asString;
|
|
445
|
-
if (local.port && !local.protocol && !local.host) {
|
|
446
|
-
asString = String(local.port);
|
|
447
|
-
} else {
|
|
448
|
-
asString = local.host ?? "localhost";
|
|
449
|
-
if (local.protocol) {
|
|
450
|
-
asString = `${local.protocol}://${asString}`;
|
|
451
|
-
}
|
|
452
|
-
if (local.port) {
|
|
453
|
-
asString = `${asString}:${local.port}`;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
errors.push(
|
|
457
|
-
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
if (errors.length) {
|
|
462
|
-
throw new MicrofrontendError(
|
|
463
|
-
`Microfrontends configuration file errors:
|
|
464
|
-
- ${errors.join("\n- ")}`,
|
|
465
|
-
{
|
|
466
|
-
type: "config",
|
|
467
|
-
subtype: "depcrecated_field"
|
|
468
|
-
}
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
474
|
-
var PREFIX = "vc-ap";
|
|
475
|
-
function generateAssetPrefixFromName({
|
|
476
|
-
name
|
|
477
|
-
}) {
|
|
478
|
-
if (!name) {
|
|
479
|
-
throw new Error("Name is required to generate an asset prefix");
|
|
480
|
-
}
|
|
481
|
-
return `${PREFIX}-${name}`;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// src/config/microfrontends-config/isomorphic/utils/generate-port.ts
|
|
485
|
-
function generatePortFromName({
|
|
486
|
-
name,
|
|
487
|
-
minPort = 3e3,
|
|
488
|
-
maxPort = 8e3
|
|
489
|
-
}) {
|
|
490
|
-
if (!name) {
|
|
491
|
-
throw new Error("Name is required to generate a port");
|
|
492
|
-
}
|
|
493
|
-
let hash = 0;
|
|
494
|
-
for (let i = 0; i < name.length; i++) {
|
|
495
|
-
hash = (hash << 5) - hash + name.charCodeAt(i);
|
|
496
|
-
hash |= 0;
|
|
497
|
-
}
|
|
498
|
-
hash = Math.abs(hash);
|
|
499
|
-
const range = maxPort - minPort;
|
|
500
|
-
const port = minPort + hash % range;
|
|
501
|
-
return port;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// src/config/microfrontends-config/isomorphic/host.ts
|
|
505
|
-
var Host = class {
|
|
506
|
-
constructor(hostConfig, options) {
|
|
507
|
-
if (typeof hostConfig === "string") {
|
|
508
|
-
({
|
|
509
|
-
protocol: this.protocol,
|
|
510
|
-
host: this.host,
|
|
511
|
-
port: this.port
|
|
512
|
-
} = Host.parseUrl(hostConfig));
|
|
513
|
-
} else {
|
|
514
|
-
const { protocol = "https", host, port } = hostConfig;
|
|
515
|
-
this.protocol = protocol;
|
|
516
|
-
this.host = host;
|
|
517
|
-
this.port = port;
|
|
518
|
-
}
|
|
519
|
-
this.local = options?.isLocal;
|
|
520
|
-
}
|
|
521
|
-
static parseUrl(url, defaultProtocol = "https") {
|
|
522
|
-
let hostToParse = url;
|
|
523
|
-
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
524
|
-
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
525
|
-
}
|
|
526
|
-
const parsed = new URL(hostToParse);
|
|
527
|
-
if (!parsed.hostname) {
|
|
528
|
-
throw new Error(Host.getMicrofrontendsError(url, "requires a host"));
|
|
529
|
-
}
|
|
530
|
-
if (parsed.hash) {
|
|
531
|
-
throw new Error(
|
|
532
|
-
Host.getMicrofrontendsError(url, "cannot have a fragment")
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
if (parsed.username || parsed.password) {
|
|
536
|
-
throw new Error(
|
|
537
|
-
Host.getMicrofrontendsError(
|
|
538
|
-
url,
|
|
539
|
-
"cannot have authentication credentials (username and/or password)"
|
|
540
|
-
)
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
if (parsed.pathname !== "/") {
|
|
544
|
-
throw new Error(Host.getMicrofrontendsError(url, "cannot have a path"));
|
|
545
|
-
}
|
|
546
|
-
if (parsed.search) {
|
|
547
|
-
throw new Error(
|
|
548
|
-
Host.getMicrofrontendsError(url, "cannot have query parameters")
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
|
-
const protocol = parsed.protocol.slice(0, -1);
|
|
552
|
-
return {
|
|
553
|
-
protocol,
|
|
554
|
-
host: parsed.hostname,
|
|
555
|
-
port: parsed.port ? Number.parseInt(parsed.port) : void 0
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
static getMicrofrontendsError(url, message) {
|
|
559
|
-
return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;
|
|
560
|
-
}
|
|
561
|
-
isLocal() {
|
|
562
|
-
return this.local || this.host === "localhost" || this.host === "127.0.0.1";
|
|
563
|
-
}
|
|
564
|
-
toString() {
|
|
565
|
-
const url = this.toUrl();
|
|
566
|
-
return url.toString().replace(/\/$/, "");
|
|
567
|
-
}
|
|
568
|
-
toUrl() {
|
|
569
|
-
const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ""}`;
|
|
570
|
-
return new URL(url);
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
var LocalHost = class extends Host {
|
|
574
|
-
constructor({
|
|
575
|
-
appName,
|
|
576
|
-
localPort,
|
|
577
|
-
local
|
|
578
|
-
}) {
|
|
579
|
-
if (localPort && local) {
|
|
580
|
-
throw new Error(
|
|
581
|
-
`Microfrontends configuration error: '${appName}' has both the 'development.local' and 'development.localPort' fields set. Please remove the 'development.localPort' field and ensure the 'development.local' field has the correct port.`
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
let protocol;
|
|
585
|
-
let host;
|
|
586
|
-
let port;
|
|
587
|
-
if (localPort) {
|
|
588
|
-
port = localPort;
|
|
589
|
-
} else if (typeof local === "number") {
|
|
590
|
-
port = local;
|
|
591
|
-
} else if (typeof local === "string") {
|
|
592
|
-
if (/^\d+$/.test(local)) {
|
|
593
|
-
port = Number.parseInt(local);
|
|
594
|
-
} else {
|
|
595
|
-
const parsed = Host.parseUrl(local, "http");
|
|
596
|
-
protocol = parsed.protocol;
|
|
597
|
-
host = parsed.host;
|
|
598
|
-
port = parsed.port;
|
|
599
|
-
}
|
|
600
|
-
} else if (local) {
|
|
601
|
-
protocol = local.protocol;
|
|
602
|
-
host = local.host;
|
|
603
|
-
port = local.port;
|
|
604
|
-
}
|
|
605
|
-
super({
|
|
606
|
-
protocol: protocol ?? "http",
|
|
607
|
-
host: host ?? "localhost",
|
|
608
|
-
port: port ?? generatePortFromName({ name: appName })
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
// src/config/microfrontends-config/isomorphic/application.ts
|
|
614
|
-
var Application = class {
|
|
615
|
-
constructor(name, {
|
|
616
|
-
app,
|
|
617
|
-
overrides,
|
|
618
|
-
isDefault
|
|
619
|
-
}) {
|
|
620
|
-
this.name = name;
|
|
621
|
-
this.development = {
|
|
622
|
-
local: new LocalHost({
|
|
623
|
-
appName: name,
|
|
624
|
-
localPort: app.development?.localPort,
|
|
625
|
-
local: app.development?.local
|
|
626
|
-
}),
|
|
627
|
-
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
628
|
-
};
|
|
629
|
-
if (app.development?.fallback) {
|
|
630
|
-
this.fallback = new Host(app.development.fallback);
|
|
631
|
-
} else if (app.production) {
|
|
632
|
-
this.fallback = new Host(app.production);
|
|
633
|
-
}
|
|
634
|
-
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
635
|
-
this.packageName = app.packageName;
|
|
636
|
-
this.overrides = overrides?.environment ? {
|
|
637
|
-
environment: new Host(overrides.environment)
|
|
638
|
-
} : void 0;
|
|
639
|
-
this.default = isDefault ?? false;
|
|
640
|
-
this.serialized = app;
|
|
641
|
-
}
|
|
642
|
-
isDefault() {
|
|
643
|
-
return this.default;
|
|
644
|
-
}
|
|
645
|
-
getAssetPrefix() {
|
|
646
|
-
return generateAssetPrefixFromName({ name: this.name });
|
|
647
|
-
}
|
|
648
|
-
serialize() {
|
|
649
|
-
return this.serialized;
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
var DefaultApplication = class extends Application {
|
|
653
|
-
constructor(name, {
|
|
654
|
-
app,
|
|
655
|
-
overrides
|
|
656
|
-
}) {
|
|
657
|
-
super(name, {
|
|
658
|
-
app,
|
|
659
|
-
overrides,
|
|
660
|
-
isDefault: true
|
|
661
|
-
});
|
|
662
|
-
this.default = true;
|
|
663
|
-
const fallbackHost = app.development?.fallback ?? app.production;
|
|
664
|
-
if (fallbackHost === void 0) {
|
|
665
|
-
throw new Error(
|
|
666
|
-
"`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
this.fallback = new Host(fallbackHost);
|
|
670
|
-
if (app.production) {
|
|
671
|
-
this.production = new Host(app.production);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
getAssetPrefix() {
|
|
675
|
-
return "";
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
var ChildApplication = class extends Application {
|
|
679
|
-
constructor(name, {
|
|
680
|
-
app,
|
|
681
|
-
overrides
|
|
682
|
-
}) {
|
|
683
|
-
ChildApplication.validate(name, app);
|
|
684
|
-
super(name, {
|
|
685
|
-
app,
|
|
686
|
-
overrides,
|
|
687
|
-
isDefault: false
|
|
688
|
-
});
|
|
689
|
-
this.default = false;
|
|
690
|
-
this.routing = app.routing;
|
|
691
|
-
}
|
|
692
|
-
static validate(name, app) {
|
|
693
|
-
validateAppPaths(name, app);
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
// src/config/microfrontends-config/isomorphic/constants.ts
|
|
698
|
-
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
699
|
-
|
|
700
|
-
// src/config/microfrontends-config/isomorphic/index.ts
|
|
701
|
-
var MicrofrontendConfigIsomorphic = class {
|
|
702
|
-
constructor({
|
|
703
|
-
config,
|
|
704
|
-
overrides,
|
|
705
|
-
meta,
|
|
706
|
-
opts
|
|
707
|
-
}) {
|
|
708
|
-
this.childApplications = {};
|
|
709
|
-
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
710
|
-
const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
|
|
711
|
-
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
712
|
-
this.isMainConfig = isMainConfig(config);
|
|
713
|
-
if (isMainConfig(config)) {
|
|
714
|
-
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
715
|
-
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
716
|
-
if (isDefaultApp(appConfig)) {
|
|
717
|
-
this.defaultApplication = new DefaultApplication(appId, {
|
|
718
|
-
app: appConfig,
|
|
719
|
-
overrides: appOverrides
|
|
720
|
-
});
|
|
721
|
-
} else {
|
|
722
|
-
this.childApplications[appId] = new ChildApplication(appId, {
|
|
723
|
-
app: appConfig,
|
|
724
|
-
overrides: appOverrides
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
} else {
|
|
729
|
-
this.partOf = config.partOf;
|
|
730
|
-
const appOverrides = !disableOverrides ? this.overrides?.applications[meta.fromApp] : void 0;
|
|
731
|
-
this.childApplications[meta.fromApp] = new ChildApplication(
|
|
732
|
-
meta.fromApp,
|
|
733
|
-
{
|
|
734
|
-
// we don't know routing because we're not in the main config
|
|
735
|
-
app: { routing: [] },
|
|
736
|
-
overrides: appOverrides
|
|
737
|
-
}
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
if (isMainConfig(config) && !this.defaultApplication) {
|
|
741
|
-
throw new MicrofrontendError(
|
|
742
|
-
"Could not find default application in microfrontends configuration",
|
|
743
|
-
{
|
|
744
|
-
type: "application",
|
|
745
|
-
subtype: "not_found"
|
|
746
|
-
}
|
|
747
|
-
);
|
|
748
|
-
}
|
|
749
|
-
this.config = config;
|
|
750
|
-
this.options = config.options;
|
|
751
|
-
this.serialized = {
|
|
752
|
-
config,
|
|
753
|
-
overrides,
|
|
754
|
-
meta
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
static validate(config, opts) {
|
|
758
|
-
const skipValidation = opts?.skipValidation ?? [];
|
|
759
|
-
const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
|
|
760
|
-
if (isMainConfig(c)) {
|
|
761
|
-
validateConfigPaths(c.applications);
|
|
762
|
-
validateConfigDefaultApplication(c.applications);
|
|
763
|
-
if (!skipValidation.includes("deprecatedFields")) {
|
|
764
|
-
validateDeprecatedFields(c);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
return c;
|
|
768
|
-
}
|
|
769
|
-
static fromEnv({
|
|
770
|
-
meta,
|
|
771
|
-
cookies
|
|
772
|
-
}) {
|
|
773
|
-
return new MicrofrontendConfigIsomorphic({
|
|
774
|
-
config: (0, import_jsonc_parser.parse)(getConfigStringFromEnv()),
|
|
775
|
-
overrides: parseOverrides(cookies ?? []),
|
|
776
|
-
meta
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
isOverridesDisabled() {
|
|
780
|
-
return this.options?.vercel?.disableOverrides ?? false;
|
|
781
|
-
}
|
|
782
|
-
getConfig() {
|
|
783
|
-
return this.config;
|
|
784
|
-
}
|
|
785
|
-
getApplicationsByType() {
|
|
786
|
-
return {
|
|
787
|
-
defaultApplication: this.defaultApplication,
|
|
788
|
-
applications: Object.values(this.childApplications)
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
getChildApplications() {
|
|
792
|
-
return Object.values(this.childApplications);
|
|
793
|
-
}
|
|
794
|
-
getAllApplications() {
|
|
795
|
-
return [
|
|
796
|
-
this.defaultApplication,
|
|
797
|
-
...Object.values(this.childApplications)
|
|
798
|
-
].filter(Boolean);
|
|
799
|
-
}
|
|
800
|
-
getApplication(name) {
|
|
801
|
-
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
802
|
-
return this.defaultApplication;
|
|
803
|
-
}
|
|
804
|
-
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
805
|
-
(child) => child.packageName === name
|
|
806
|
-
);
|
|
807
|
-
if (!app) {
|
|
808
|
-
throw new MicrofrontendError(
|
|
809
|
-
`Could not find microfrontends configuration for application "${name}"`,
|
|
810
|
-
{
|
|
811
|
-
type: "application",
|
|
812
|
-
subtype: "not_found"
|
|
813
|
-
}
|
|
814
|
-
);
|
|
815
|
-
}
|
|
816
|
-
return app;
|
|
817
|
-
}
|
|
818
|
-
getApplicationByProjectId(projectId) {
|
|
819
|
-
if (this.defaultApplication?.projectId === projectId) {
|
|
820
|
-
return this.defaultApplication;
|
|
821
|
-
}
|
|
822
|
-
return Object.values(this.childApplications).find(
|
|
823
|
-
(app) => app.projectId === projectId
|
|
824
|
-
);
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Returns the default application. This can throw if the default application
|
|
828
|
-
* is undefined ( )
|
|
829
|
-
*/
|
|
830
|
-
getDefaultApplication() {
|
|
831
|
-
if (!this.defaultApplication) {
|
|
832
|
-
throw new MicrofrontendError(
|
|
833
|
-
"Could not find default application in microfrontends configuration",
|
|
834
|
-
{
|
|
835
|
-
type: "application",
|
|
836
|
-
subtype: "not_found"
|
|
837
|
-
}
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
return this.defaultApplication;
|
|
841
|
-
}
|
|
842
|
-
/**
|
|
843
|
-
* Returns the configured port for the local proxy
|
|
844
|
-
*/
|
|
845
|
-
getLocalProxyPort() {
|
|
846
|
-
return this.config.options?.localProxyPort ?? this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Serializes the class back to the Schema type.
|
|
850
|
-
*
|
|
851
|
-
* NOTE: This is used when writing the config to disk and must always match the input Schema
|
|
852
|
-
*/
|
|
853
|
-
toSchemaJson() {
|
|
854
|
-
return this.serialized.config;
|
|
855
|
-
}
|
|
856
|
-
toClientConfig() {
|
|
857
|
-
const applications = Object.fromEntries(
|
|
858
|
-
Object.entries(this.childApplications).map(([name, application]) => [
|
|
859
|
-
name,
|
|
860
|
-
{
|
|
861
|
-
default: false,
|
|
862
|
-
routing: application.routing
|
|
863
|
-
}
|
|
864
|
-
])
|
|
865
|
-
);
|
|
866
|
-
if (this.defaultApplication) {
|
|
867
|
-
applications[this.defaultApplication.name] = {
|
|
868
|
-
default: true
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
return new MicrofrontendConfigClient({
|
|
872
|
-
applications
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
serialize() {
|
|
876
|
-
return this.serialized;
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
|
|
880
|
-
// src/config/microfrontends-config/isomorphic/child.ts
|
|
881
|
-
var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
882
|
-
constructor({
|
|
883
|
-
config,
|
|
884
|
-
overrides,
|
|
885
|
-
meta
|
|
886
|
-
}) {
|
|
887
|
-
super({ config, overrides, meta });
|
|
888
|
-
this.isMainConfig = false;
|
|
889
|
-
this.partOf = config.partOf;
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
// src/config/microfrontends-config/isomorphic/main.ts
|
|
894
|
-
var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
895
|
-
constructor({
|
|
896
|
-
config,
|
|
897
|
-
overrides,
|
|
898
|
-
meta
|
|
899
|
-
}) {
|
|
900
|
-
super({ config, overrides, meta });
|
|
901
|
-
this.isMainConfig = true;
|
|
902
|
-
const disableOverrides = config.options?.disableOverrides ?? config.options?.vercel?.disableOverrides ?? false;
|
|
903
|
-
let defaultApplication;
|
|
904
|
-
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
905
|
-
const appOverrides = !disableOverrides ? this.overrides?.applications[appId] : void 0;
|
|
906
|
-
if (isDefaultApp(appConfig)) {
|
|
907
|
-
defaultApplication = new DefaultApplication(appId, {
|
|
908
|
-
app: appConfig,
|
|
909
|
-
overrides: appOverrides
|
|
910
|
-
});
|
|
911
|
-
} else {
|
|
912
|
-
this.childApplications[appId] = new ChildApplication(appId, {
|
|
913
|
-
app: appConfig,
|
|
914
|
-
overrides: appOverrides
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
if (!defaultApplication) {
|
|
919
|
-
throw new MicrofrontendError(
|
|
920
|
-
"Could not find default application in microfrontends configuration",
|
|
921
|
-
{
|
|
922
|
-
type: "application",
|
|
923
|
-
subtype: "not_found"
|
|
924
|
-
}
|
|
925
|
-
);
|
|
926
|
-
}
|
|
927
|
-
this.defaultApplication = defaultApplication;
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
// src/config/microfrontends/isomorphic/index.ts
|
|
932
|
-
var Microfrontends = class {
|
|
933
|
-
constructor({
|
|
934
|
-
config,
|
|
935
|
-
overrides,
|
|
936
|
-
meta
|
|
937
|
-
}) {
|
|
938
|
-
if (isMainConfig(config)) {
|
|
939
|
-
this.config = new MicrofrontendMainConfig({ config, overrides, meta });
|
|
940
|
-
} else {
|
|
941
|
-
this.config = new MicrofrontendChildConfig({ config, overrides, meta });
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
isChildConfig() {
|
|
945
|
-
return this.config instanceof MicrofrontendChildConfig;
|
|
946
|
-
}
|
|
947
|
-
static fromEnv({
|
|
948
|
-
cookies,
|
|
949
|
-
meta
|
|
950
|
-
}) {
|
|
951
|
-
const config = MicrofrontendConfigIsomorphic.fromEnv({
|
|
952
|
-
cookies,
|
|
953
|
-
meta
|
|
954
|
-
});
|
|
955
|
-
return new Microfrontends(config.serialize());
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
959
|
-
0 && (module.exports = {
|
|
960
|
-
Microfrontends
|
|
961
|
-
});
|
|
962
|
-
//# sourceMappingURL=microfrontends.cjs.map
|