@vercel/microfrontends 2.2.1 → 2.2.2
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/CHANGELOG.md +19 -0
- package/cli/index.cjs +0 -1
- package/dist/bin/cli.cjs +483 -394
- package/dist/config.cjs +191 -169
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +3 -2
- package/dist/config.js +192 -170
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +583 -511
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +589 -517
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +605 -533
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +614 -542
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +601 -529
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +2 -2
- package/dist/microfrontends/server.js +607 -535
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends/utils.cjs +101 -50
- package/dist/microfrontends/utils.cjs.map +1 -1
- package/dist/microfrontends/utils.d.ts +4 -4
- package/dist/microfrontends/utils.js +102 -51
- package/dist/microfrontends/utils.js.map +1 -1
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.ts +8 -8
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +723 -647
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +720 -644
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +244 -222
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +245 -223
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +192 -170
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +1 -1
- package/dist/next/testing.js +193 -171
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +5 -5
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +9 -9
- package/dist/overrides.js +5 -5
- package/dist/overrides.js.map +1 -1
- package/dist/utils/mfe-port.cjs +620 -533
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.d.ts +9 -1
- package/dist/utils/mfe-port.js +632 -546
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +8 -24
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.js +8 -24
- package/dist/validation.js.map +1 -1
- package/package.json +4 -6
|
@@ -34,42 +34,31 @@ __export(vite_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(vite_exports);
|
|
36
36
|
|
|
37
|
-
// src/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
|
|
43
|
-
var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
|
|
44
|
-
|
|
45
|
-
// src/config/overrides/is-override-cookie.ts
|
|
46
|
-
function isOverrideCookie(cookie) {
|
|
47
|
-
return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
37
|
+
// src/bin/logger.ts
|
|
38
|
+
function debug(...args) {
|
|
39
|
+
if (process.env.MFE_DEBUG) {
|
|
40
|
+
console.log(...args);
|
|
41
|
+
}
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function getOverrideFromCookie(cookie) {
|
|
52
|
-
if (!isOverrideCookie(cookie) || !cookie.value)
|
|
53
|
-
return;
|
|
54
|
-
return {
|
|
55
|
-
application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ""),
|
|
56
|
-
host: cookie.value
|
|
57
|
-
};
|
|
43
|
+
function info(...args) {
|
|
44
|
+
console.log(...args);
|
|
58
45
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function parseOverrides(cookies) {
|
|
62
|
-
const overridesConfig = { applications: {} };
|
|
63
|
-
cookies.forEach((cookie) => {
|
|
64
|
-
const override = getOverrideFromCookie(cookie);
|
|
65
|
-
if (!override)
|
|
66
|
-
return;
|
|
67
|
-
overridesConfig.applications[override.application] = {
|
|
68
|
-
environment: { host: override.host }
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
return overridesConfig;
|
|
46
|
+
function warn(...args) {
|
|
47
|
+
console.warn(...args);
|
|
72
48
|
}
|
|
49
|
+
function error(...args) {
|
|
50
|
+
console.error(...args);
|
|
51
|
+
}
|
|
52
|
+
var logger = {
|
|
53
|
+
debug,
|
|
54
|
+
info,
|
|
55
|
+
warn,
|
|
56
|
+
error
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/config/microfrontends/server/index.ts
|
|
60
|
+
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
61
|
+
var import_node_path8 = require("path");
|
|
73
62
|
|
|
74
63
|
// src/config/errors.ts
|
|
75
64
|
var MicrofrontendError = class extends Error {
|
|
@@ -163,296 +152,47 @@ var MicrofrontendError = class extends Error {
|
|
|
163
152
|
}
|
|
164
153
|
};
|
|
165
154
|
|
|
166
|
-
// src/config/microfrontends-config/
|
|
167
|
-
function getConfigStringFromEnv() {
|
|
168
|
-
const config = process.env.MFE_CONFIG;
|
|
169
|
-
if (!config) {
|
|
170
|
-
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
171
|
-
type: "config",
|
|
172
|
-
subtype: "not_found_in_env"
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return config;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/config/schema/utils/is-default-app.ts
|
|
179
|
-
function isDefaultApp(a) {
|
|
180
|
-
return !("routing" in a);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/config/microfrontends/utils/find-repository-root.ts
|
|
184
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
185
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
186
|
-
var GIT_DIRECTORY = ".git";
|
|
187
|
-
function hasGitDirectory(dir) {
|
|
188
|
-
const gitPath = import_node_path.default.join(dir, GIT_DIRECTORY);
|
|
189
|
-
return import_node_fs.default.existsSync(gitPath) && import_node_fs.default.statSync(gitPath).isDirectory();
|
|
190
|
-
}
|
|
191
|
-
function hasPnpmWorkspaces(dir) {
|
|
192
|
-
return import_node_fs.default.existsSync(import_node_path.default.join(dir, "pnpm-workspace.yaml"));
|
|
193
|
-
}
|
|
194
|
-
function hasPackageJson(dir) {
|
|
195
|
-
return import_node_fs.default.existsSync(import_node_path.default.join(dir, "package.json"));
|
|
196
|
-
}
|
|
197
|
-
function findRepositoryRoot(startDir) {
|
|
198
|
-
if (process.env.NX_WORKSPACE_ROOT) {
|
|
199
|
-
return process.env.NX_WORKSPACE_ROOT;
|
|
200
|
-
}
|
|
201
|
-
let currentDir = startDir || process.cwd();
|
|
202
|
-
let lastPackageJsonDir = null;
|
|
203
|
-
while (currentDir !== import_node_path.default.parse(currentDir).root) {
|
|
204
|
-
if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
|
|
205
|
-
return currentDir;
|
|
206
|
-
}
|
|
207
|
-
if (hasPackageJson(currentDir)) {
|
|
208
|
-
lastPackageJsonDir = currentDir;
|
|
209
|
-
}
|
|
210
|
-
currentDir = import_node_path.default.dirname(currentDir);
|
|
211
|
-
}
|
|
212
|
-
if (lastPackageJsonDir) {
|
|
213
|
-
return lastPackageJsonDir;
|
|
214
|
-
}
|
|
215
|
-
throw new Error(
|
|
216
|
-
`Could not find the root of the repository for ${startDir}. Please ensure that the directory is part of a Git repository. If you suspect that this should work, please file an issue to the Vercel team.`
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
221
|
-
var import_node_path2 = require("path");
|
|
222
|
-
var import_node_fs2 = require("fs");
|
|
155
|
+
// src/config/microfrontends-config/isomorphic/index.ts
|
|
223
156
|
var import_jsonc_parser = require("jsonc-parser");
|
|
224
|
-
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
225
|
-
|
|
226
|
-
// src/bin/logger.ts
|
|
227
|
-
function debug(...args) {
|
|
228
|
-
if (process.env.MFE_DEBUG) {
|
|
229
|
-
console.log(...args);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function info(...args) {
|
|
233
|
-
console.log(...args);
|
|
234
|
-
}
|
|
235
|
-
function warn(...args) {
|
|
236
|
-
console.warn(...args);
|
|
237
|
-
}
|
|
238
|
-
function error(...args) {
|
|
239
|
-
console.error(...args);
|
|
240
|
-
}
|
|
241
|
-
var logger = {
|
|
242
|
-
debug,
|
|
243
|
-
info,
|
|
244
|
-
warn,
|
|
245
|
-
error
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
249
|
-
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
250
|
-
"microfrontends.json",
|
|
251
|
-
"microfrontends.jsonc"
|
|
252
|
-
];
|
|
253
|
-
function getPossibleConfigurationFilenames({
|
|
254
|
-
customConfigFilename
|
|
255
|
-
}) {
|
|
256
|
-
if (customConfigFilename) {
|
|
257
|
-
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
258
|
-
throw new Error(
|
|
259
|
-
`Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}. The file name must end with '.json' or '.jsonc'. It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
return Array.from(
|
|
263
|
-
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
267
|
-
}
|
|
268
157
|
|
|
269
|
-
// src/config/
|
|
270
|
-
var
|
|
271
|
-
|
|
272
|
-
repositoryRoot,
|
|
273
|
-
applicationContext,
|
|
274
|
-
customConfigFilename
|
|
275
|
-
}) {
|
|
276
|
-
const applicationName = applicationContext.name;
|
|
277
|
-
logger.debug(
|
|
278
|
-
"[MFE Config] Searching repository for configs containing application:",
|
|
279
|
-
applicationName
|
|
280
|
-
);
|
|
281
|
-
try {
|
|
282
|
-
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
283
|
-
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
284
|
-
{
|
|
285
|
-
cwd: repositoryRoot,
|
|
286
|
-
absolute: true,
|
|
287
|
-
onlyFiles: true,
|
|
288
|
-
followSymbolicLinks: false,
|
|
289
|
-
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
290
|
-
}
|
|
291
|
-
);
|
|
292
|
-
logger.debug(
|
|
293
|
-
"[MFE Config] Found",
|
|
294
|
-
microfrontendsJsonPaths.length,
|
|
295
|
-
"config file(s) in repository"
|
|
296
|
-
);
|
|
297
|
-
const matchingPaths = [];
|
|
298
|
-
for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
|
|
299
|
-
try {
|
|
300
|
-
const microfrontendsJsonContent = (0, import_node_fs2.readFileSync)(
|
|
301
|
-
microfrontendsJsonPath,
|
|
302
|
-
"utf-8"
|
|
303
|
-
);
|
|
304
|
-
const microfrontendsJson = (0, import_jsonc_parser.parse)(microfrontendsJsonContent);
|
|
305
|
-
if (microfrontendsJson.applications[applicationName]) {
|
|
306
|
-
logger.debug(
|
|
307
|
-
"[MFE Config] Found application in config:",
|
|
308
|
-
microfrontendsJsonPath
|
|
309
|
-
);
|
|
310
|
-
matchingPaths.push(microfrontendsJsonPath);
|
|
311
|
-
} else {
|
|
312
|
-
for (const [_, app] of Object.entries(
|
|
313
|
-
microfrontendsJson.applications
|
|
314
|
-
)) {
|
|
315
|
-
if (app.packageName === applicationName) {
|
|
316
|
-
logger.debug(
|
|
317
|
-
"[MFE Config] Found application via packageName in config:",
|
|
318
|
-
microfrontendsJsonPath
|
|
319
|
-
);
|
|
320
|
-
matchingPaths.push(microfrontendsJsonPath);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
} catch (error2) {
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
logger.debug(
|
|
328
|
-
"[MFE Config] Total matching config files:",
|
|
329
|
-
matchingPaths.length
|
|
330
|
-
);
|
|
331
|
-
if (matchingPaths.length > 1) {
|
|
332
|
-
throw new MicrofrontendError(
|
|
333
|
-
`Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
|
|
334
|
-
${matchingPaths.join("\n \u2022 ")}`,
|
|
335
|
-
{ type: "config", subtype: "inference_failed" }
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
if (matchingPaths.length === 0) {
|
|
339
|
-
let additionalErrorMessage = "";
|
|
340
|
-
if (microfrontendsJsonPaths.length > 0) {
|
|
341
|
-
if (!applicationContext.projectName) {
|
|
342
|
-
additionalErrorMessage = `
|
|
343
|
-
|
|
344
|
-
If the name in package.json (${applicationContext.packageJsonName}) differs from your Vercel Project name, set the \`packageName\` field for the application in \`microfrontends.json\` to ensure that the configuration can be found locally.`;
|
|
345
|
-
} else {
|
|
346
|
-
additionalErrorMessage = `
|
|
347
|
-
|
|
348
|
-
Names of applications in \`microfrontends.json\` must match the Vercel Project name (${applicationContext.projectName}).`;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
throw new MicrofrontendError(
|
|
352
|
-
`Could not find a \`microfrontends.json\` file in the repository that contains the "${applicationName}" application.${additionalErrorMessage}
|
|
353
|
-
|
|
354
|
-
If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable.
|
|
355
|
-
|
|
356
|
-
If your Vercel Microfrontends configuration has a custom name, ensure the VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable is set, you can pull the vercel project environment variables using the "vercel env pull" command.
|
|
158
|
+
// src/config/overrides/constants.ts
|
|
159
|
+
var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
|
|
160
|
+
var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
|
|
357
161
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
const [packageJsonPath] = matchingPaths;
|
|
363
|
-
return (0, import_node_path2.dirname)(packageJsonPath);
|
|
364
|
-
} catch (error2) {
|
|
365
|
-
if (error2 instanceof MicrofrontendError) {
|
|
366
|
-
throw error2;
|
|
367
|
-
}
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
function inferMicrofrontendsLocation(opts) {
|
|
372
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
373
|
-
if (configCache[cacheKey]) {
|
|
374
|
-
return configCache[cacheKey];
|
|
375
|
-
}
|
|
376
|
-
const result = findPackageWithMicrofrontendsConfig(opts);
|
|
377
|
-
if (!result) {
|
|
378
|
-
throw new MicrofrontendError(
|
|
379
|
-
`Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationContext.name}" starting in directory "${opts.repositoryRoot}".`,
|
|
380
|
-
{ type: "config", subtype: "inference_failed" }
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
configCache[cacheKey] = result;
|
|
384
|
-
return result;
|
|
162
|
+
// src/config/overrides/is-override-cookie.ts
|
|
163
|
+
function isOverrideCookie(cookie) {
|
|
164
|
+
return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));
|
|
385
165
|
}
|
|
386
166
|
|
|
387
|
-
// src/config/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return true;
|
|
396
|
-
}
|
|
397
|
-
if (import_node_fs3.default.existsSync(import_node_path3.default.join(repositoryRoot, "vlt-workspaces.json"))) {
|
|
398
|
-
return true;
|
|
399
|
-
}
|
|
400
|
-
if (process.env.NX_WORKSPACE_ROOT === import_node_path3.default.resolve(repositoryRoot)) {
|
|
401
|
-
return true;
|
|
402
|
-
}
|
|
403
|
-
const packageJsonPath = import_node_path3.default.join(repositoryRoot, "package.json");
|
|
404
|
-
if (!import_node_fs3.default.existsSync(packageJsonPath)) {
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
const packageJson = JSON.parse(
|
|
408
|
-
import_node_fs3.default.readFileSync(packageJsonPath, "utf-8")
|
|
409
|
-
);
|
|
410
|
-
return packageJson.workspaces !== void 0;
|
|
411
|
-
} catch (error2) {
|
|
412
|
-
logger.error("Error determining if repository is a monorepo", error2);
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
167
|
+
// src/config/overrides/get-override-from-cookie.ts
|
|
168
|
+
function getOverrideFromCookie(cookie) {
|
|
169
|
+
if (!isOverrideCookie(cookie) || !cookie.value)
|
|
170
|
+
return;
|
|
171
|
+
return {
|
|
172
|
+
application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ""),
|
|
173
|
+
host: cookie.value
|
|
174
|
+
};
|
|
415
175
|
}
|
|
416
176
|
|
|
417
|
-
// src/config/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
throw new Error(
|
|
431
|
-
`The root of the package that contains the \`package.json\` file for the \`${startDir}\` directory could not be found.`
|
|
432
|
-
);
|
|
177
|
+
// src/config/overrides/parse-overrides.ts
|
|
178
|
+
function parseOverrides(cookies) {
|
|
179
|
+
const overridesConfig = { applications: {} };
|
|
180
|
+
cookies.forEach((cookie) => {
|
|
181
|
+
const override = getOverrideFromCookie(cookie);
|
|
182
|
+
if (!override)
|
|
183
|
+
return;
|
|
184
|
+
overridesConfig.applications[override.application] = {
|
|
185
|
+
environment: { host: override.host }
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
return overridesConfig;
|
|
433
189
|
}
|
|
434
190
|
|
|
435
|
-
// src/config/
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
function findConfig({
|
|
439
|
-
dir,
|
|
440
|
-
customConfigFilename
|
|
441
|
-
}) {
|
|
442
|
-
for (const filename of getPossibleConfigurationFilenames({
|
|
443
|
-
customConfigFilename
|
|
444
|
-
})) {
|
|
445
|
-
const maybeConfig = (0, import_node_path5.join)(dir, filename);
|
|
446
|
-
if (import_node_fs5.default.existsSync(maybeConfig)) {
|
|
447
|
-
return maybeConfig;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return null;
|
|
191
|
+
// src/config/schema/utils/is-default-app.ts
|
|
192
|
+
function isDefaultApp(a) {
|
|
193
|
+
return !("routing" in a);
|
|
451
194
|
}
|
|
452
195
|
|
|
453
|
-
// src/config/microfrontends-config/isomorphic/index.ts
|
|
454
|
-
var import_jsonc_parser2 = require("jsonc-parser");
|
|
455
|
-
|
|
456
196
|
// src/config/microfrontends-config/client/index.ts
|
|
457
197
|
var import_path_to_regexp = require("path-to-regexp");
|
|
458
198
|
var regexpCache = /* @__PURE__ */ new Map();
|
|
@@ -511,46 +251,223 @@ var MicrofrontendConfigClient = class {
|
|
|
511
251
|
"Could not construct MicrofrontendConfigClient: configuration is empty or undefined. Did you set up your application with `withMicrofrontends`? Is the local proxy running and this application is being accessed via the proxy port? See https://vercel.com/docs/microfrontends/local-development#setting-up-microfrontends-proxy"
|
|
512
252
|
);
|
|
513
253
|
}
|
|
514
|
-
return new MicrofrontendConfigClient(JSON.parse(config));
|
|
254
|
+
return new MicrofrontendConfigClient(JSON.parse(config));
|
|
255
|
+
}
|
|
256
|
+
isEqual(other) {
|
|
257
|
+
return this === other || JSON.stringify(this.applications) === JSON.stringify(other.applications);
|
|
258
|
+
}
|
|
259
|
+
getApplicationNameForPath(path6) {
|
|
260
|
+
if (!path6.startsWith("/")) {
|
|
261
|
+
throw new Error(`Path must start with a /`);
|
|
262
|
+
}
|
|
263
|
+
if (this.pathCache[path6]) {
|
|
264
|
+
return this.pathCache[path6];
|
|
265
|
+
}
|
|
266
|
+
const pathname = new URL(path6, "https://example.com").pathname;
|
|
267
|
+
for (const [name, application] of Object.entries(this.applications)) {
|
|
268
|
+
if (application.routing) {
|
|
269
|
+
for (const group of application.routing) {
|
|
270
|
+
for (const childPath of group.paths) {
|
|
271
|
+
const regexp = getRegexp(childPath);
|
|
272
|
+
if (regexp.test(pathname)) {
|
|
273
|
+
this.pathCache[path6] = name;
|
|
274
|
+
return name;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const defaultApplication = Object.entries(this.applications).find(
|
|
281
|
+
([, application]) => application.default
|
|
282
|
+
);
|
|
283
|
+
if (!defaultApplication) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
this.pathCache[path6] = defaultApplication[0];
|
|
287
|
+
return defaultApplication[0];
|
|
288
|
+
}
|
|
289
|
+
serialize() {
|
|
290
|
+
return this.serialized;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// src/config/microfrontends-config/utils/get-config-from-env.ts
|
|
295
|
+
function getConfigStringFromEnv() {
|
|
296
|
+
const config = process.env.MFE_CONFIG;
|
|
297
|
+
if (!config) {
|
|
298
|
+
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
299
|
+
type: "config",
|
|
300
|
+
subtype: "not_found_in_env"
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return config;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/config/microfrontends-config/isomorphic/constants.ts
|
|
307
|
+
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
308
|
+
var MFE_APP_PORT_ENV = "MFE_APP_PORT";
|
|
309
|
+
var MFE_LOCAL_PROXY_PORT_ENV = "MFE_LOCAL_PROXY_PORT";
|
|
310
|
+
|
|
311
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-port.ts
|
|
312
|
+
function generatePortFromName({
|
|
313
|
+
name,
|
|
314
|
+
minPort = 3e3,
|
|
315
|
+
maxPort = 8e3
|
|
316
|
+
}) {
|
|
317
|
+
if (!name) {
|
|
318
|
+
throw new Error("Name is required to generate a port");
|
|
319
|
+
}
|
|
320
|
+
let hash = 0;
|
|
321
|
+
for (let i = 0; i < name.length; i++) {
|
|
322
|
+
hash = (hash << 5) - hash + name.charCodeAt(i);
|
|
323
|
+
hash |= 0;
|
|
324
|
+
}
|
|
325
|
+
hash = Math.abs(hash);
|
|
326
|
+
const range = maxPort - minPort;
|
|
327
|
+
const port = minPort + hash % range;
|
|
328
|
+
return port;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/config/microfrontends-config/isomorphic/host.ts
|
|
332
|
+
var Host = class {
|
|
333
|
+
constructor(hostConfig, options) {
|
|
334
|
+
if (typeof hostConfig === "string") {
|
|
335
|
+
({
|
|
336
|
+
protocol: this.protocol,
|
|
337
|
+
host: this.host,
|
|
338
|
+
port: this.port
|
|
339
|
+
} = Host.parseUrl(hostConfig));
|
|
340
|
+
} else {
|
|
341
|
+
const { protocol = "https", host, port } = hostConfig;
|
|
342
|
+
this.protocol = protocol;
|
|
343
|
+
this.host = host;
|
|
344
|
+
this.port = port;
|
|
345
|
+
}
|
|
346
|
+
this.local = options?.isLocal;
|
|
347
|
+
}
|
|
348
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
349
|
+
let hostToParse = url;
|
|
350
|
+
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
351
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
352
|
+
}
|
|
353
|
+
const parsed = new URL(hostToParse);
|
|
354
|
+
if (!parsed.hostname) {
|
|
355
|
+
throw new Error(Host.getMicrofrontendsError(url, "requires a host"));
|
|
356
|
+
}
|
|
357
|
+
if (parsed.hash) {
|
|
358
|
+
throw new Error(
|
|
359
|
+
Host.getMicrofrontendsError(url, "cannot have a fragment")
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
if (parsed.username || parsed.password) {
|
|
363
|
+
throw new Error(
|
|
364
|
+
Host.getMicrofrontendsError(
|
|
365
|
+
url,
|
|
366
|
+
"cannot have authentication credentials (username and/or password)"
|
|
367
|
+
)
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
if (parsed.pathname !== "/") {
|
|
371
|
+
throw new Error(Host.getMicrofrontendsError(url, "cannot have a path"));
|
|
372
|
+
}
|
|
373
|
+
if (parsed.search) {
|
|
374
|
+
throw new Error(
|
|
375
|
+
Host.getMicrofrontendsError(url, "cannot have query parameters")
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
const protocol = parsed.protocol.slice(0, -1);
|
|
379
|
+
return {
|
|
380
|
+
protocol,
|
|
381
|
+
host: parsed.hostname,
|
|
382
|
+
port: parsed.port ? Number.parseInt(parsed.port, 10) : void 0
|
|
383
|
+
};
|
|
515
384
|
}
|
|
516
|
-
|
|
517
|
-
return
|
|
385
|
+
static getMicrofrontendsError(url, message) {
|
|
386
|
+
return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;
|
|
518
387
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
388
|
+
isLocal() {
|
|
389
|
+
return this.local || this.host === "localhost" || this.host === "127.0.0.1";
|
|
390
|
+
}
|
|
391
|
+
toString() {
|
|
392
|
+
const url = this.toUrl();
|
|
393
|
+
return url.toString().replace(/\/$/, "");
|
|
394
|
+
}
|
|
395
|
+
toUrl() {
|
|
396
|
+
const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ""}`;
|
|
397
|
+
return new URL(url);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
var LocalHost = class extends Host {
|
|
401
|
+
constructor({
|
|
402
|
+
appName,
|
|
403
|
+
local
|
|
404
|
+
}) {
|
|
405
|
+
const portOverride = process.env[MFE_APP_PORT_ENV];
|
|
406
|
+
if (portOverride) {
|
|
407
|
+
const overridePort = Number.parseInt(portOverride, 10);
|
|
408
|
+
if (!Number.isNaN(overridePort) && overridePort > 0 && overridePort < 65536) {
|
|
409
|
+
super({
|
|
410
|
+
protocol: "http",
|
|
411
|
+
host: "localhost",
|
|
412
|
+
port: overridePort
|
|
413
|
+
});
|
|
414
|
+
return;
|
|
538
415
|
}
|
|
539
416
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (
|
|
544
|
-
|
|
417
|
+
let protocol;
|
|
418
|
+
let host;
|
|
419
|
+
let port;
|
|
420
|
+
if (typeof local === "number") {
|
|
421
|
+
port = local;
|
|
422
|
+
} else if (typeof local === "string") {
|
|
423
|
+
if (/^\d+$/.test(local)) {
|
|
424
|
+
port = Number.parseInt(local, 10);
|
|
425
|
+
} else {
|
|
426
|
+
const parsed = Host.parseUrl(local, "http");
|
|
427
|
+
protocol = parsed.protocol;
|
|
428
|
+
host = parsed.host;
|
|
429
|
+
port = parsed.port;
|
|
430
|
+
}
|
|
431
|
+
} else if (local) {
|
|
432
|
+
protocol = local.protocol;
|
|
433
|
+
host = local.host;
|
|
434
|
+
port = local.port;
|
|
545
435
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
436
|
+
super({
|
|
437
|
+
protocol: protocol ?? "http",
|
|
438
|
+
host: host ?? "localhost",
|
|
439
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
440
|
+
});
|
|
551
441
|
}
|
|
552
442
|
};
|
|
553
443
|
|
|
444
|
+
// src/config/microfrontends-config/isomorphic/utils/hash-application-name.ts
|
|
445
|
+
var import_md5 = __toESM(require("md5"), 1);
|
|
446
|
+
function hashApplicationName(name) {
|
|
447
|
+
if (!name) {
|
|
448
|
+
throw new Error("Application name is required to generate hash");
|
|
449
|
+
}
|
|
450
|
+
return (0, import_md5.default)(name).substring(0, 6).padStart(6, "0");
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
454
|
+
var PREFIX = "vc-ap";
|
|
455
|
+
function generateAssetPrefixFromName({
|
|
456
|
+
name
|
|
457
|
+
}) {
|
|
458
|
+
if (!name) {
|
|
459
|
+
throw new Error("Name is required to generate an asset prefix");
|
|
460
|
+
}
|
|
461
|
+
return `${PREFIX}-${hashApplicationName(name)}`;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
|
|
465
|
+
function generateAutomationBypassEnvVarName({
|
|
466
|
+
name
|
|
467
|
+
}) {
|
|
468
|
+
return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
469
|
+
}
|
|
470
|
+
|
|
554
471
|
// src/config/microfrontends-config/isomorphic/validation.ts
|
|
555
472
|
var import_path_to_regexp2 = require("path-to-regexp");
|
|
556
473
|
var LIST_FORMATTER = new Intl.ListFormat("en", {
|
|
@@ -732,154 +649,6 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
732
649
|
}
|
|
733
650
|
};
|
|
734
651
|
|
|
735
|
-
// src/config/microfrontends-config/isomorphic/utils/hash-application-name.ts
|
|
736
|
-
var import_md5 = __toESM(require("md5"), 1);
|
|
737
|
-
function hashApplicationName(name) {
|
|
738
|
-
if (!name) {
|
|
739
|
-
throw new Error("Application name is required to generate hash");
|
|
740
|
-
}
|
|
741
|
-
return (0, import_md5.default)(name).substring(0, 6).padStart(6, "0");
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
745
|
-
var PREFIX = "vc-ap";
|
|
746
|
-
function generateAssetPrefixFromName({
|
|
747
|
-
name
|
|
748
|
-
}) {
|
|
749
|
-
if (!name) {
|
|
750
|
-
throw new Error("Name is required to generate an asset prefix");
|
|
751
|
-
}
|
|
752
|
-
return `${PREFIX}-${hashApplicationName(name)}`;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// src/config/microfrontends-config/isomorphic/utils/generate-port.ts
|
|
756
|
-
function generatePortFromName({
|
|
757
|
-
name,
|
|
758
|
-
minPort = 3e3,
|
|
759
|
-
maxPort = 8e3
|
|
760
|
-
}) {
|
|
761
|
-
if (!name) {
|
|
762
|
-
throw new Error("Name is required to generate a port");
|
|
763
|
-
}
|
|
764
|
-
let hash = 0;
|
|
765
|
-
for (let i = 0; i < name.length; i++) {
|
|
766
|
-
hash = (hash << 5) - hash + name.charCodeAt(i);
|
|
767
|
-
hash |= 0;
|
|
768
|
-
}
|
|
769
|
-
hash = Math.abs(hash);
|
|
770
|
-
const range = maxPort - minPort;
|
|
771
|
-
const port = minPort + hash % range;
|
|
772
|
-
return port;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
// src/config/microfrontends-config/isomorphic/host.ts
|
|
776
|
-
var Host = class {
|
|
777
|
-
constructor(hostConfig, options) {
|
|
778
|
-
if (typeof hostConfig === "string") {
|
|
779
|
-
({
|
|
780
|
-
protocol: this.protocol,
|
|
781
|
-
host: this.host,
|
|
782
|
-
port: this.port
|
|
783
|
-
} = Host.parseUrl(hostConfig));
|
|
784
|
-
} else {
|
|
785
|
-
const { protocol = "https", host, port } = hostConfig;
|
|
786
|
-
this.protocol = protocol;
|
|
787
|
-
this.host = host;
|
|
788
|
-
this.port = port;
|
|
789
|
-
}
|
|
790
|
-
this.local = options?.isLocal;
|
|
791
|
-
}
|
|
792
|
-
static parseUrl(url, defaultProtocol = "https") {
|
|
793
|
-
let hostToParse = url;
|
|
794
|
-
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
795
|
-
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
796
|
-
}
|
|
797
|
-
const parsed = new URL(hostToParse);
|
|
798
|
-
if (!parsed.hostname) {
|
|
799
|
-
throw new Error(Host.getMicrofrontendsError(url, "requires a host"));
|
|
800
|
-
}
|
|
801
|
-
if (parsed.hash) {
|
|
802
|
-
throw new Error(
|
|
803
|
-
Host.getMicrofrontendsError(url, "cannot have a fragment")
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
if (parsed.username || parsed.password) {
|
|
807
|
-
throw new Error(
|
|
808
|
-
Host.getMicrofrontendsError(
|
|
809
|
-
url,
|
|
810
|
-
"cannot have authentication credentials (username and/or password)"
|
|
811
|
-
)
|
|
812
|
-
);
|
|
813
|
-
}
|
|
814
|
-
if (parsed.pathname !== "/") {
|
|
815
|
-
throw new Error(Host.getMicrofrontendsError(url, "cannot have a path"));
|
|
816
|
-
}
|
|
817
|
-
if (parsed.search) {
|
|
818
|
-
throw new Error(
|
|
819
|
-
Host.getMicrofrontendsError(url, "cannot have query parameters")
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
const protocol = parsed.protocol.slice(0, -1);
|
|
823
|
-
return {
|
|
824
|
-
protocol,
|
|
825
|
-
host: parsed.hostname,
|
|
826
|
-
port: parsed.port ? Number.parseInt(parsed.port) : void 0
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
static getMicrofrontendsError(url, message) {
|
|
830
|
-
return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;
|
|
831
|
-
}
|
|
832
|
-
isLocal() {
|
|
833
|
-
return this.local || this.host === "localhost" || this.host === "127.0.0.1";
|
|
834
|
-
}
|
|
835
|
-
toString() {
|
|
836
|
-
const url = this.toUrl();
|
|
837
|
-
return url.toString().replace(/\/$/, "");
|
|
838
|
-
}
|
|
839
|
-
toUrl() {
|
|
840
|
-
const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ""}`;
|
|
841
|
-
return new URL(url);
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
var LocalHost = class extends Host {
|
|
845
|
-
constructor({
|
|
846
|
-
appName,
|
|
847
|
-
local
|
|
848
|
-
}) {
|
|
849
|
-
let protocol;
|
|
850
|
-
let host;
|
|
851
|
-
let port;
|
|
852
|
-
if (typeof local === "number") {
|
|
853
|
-
port = local;
|
|
854
|
-
} else if (typeof local === "string") {
|
|
855
|
-
if (/^\d+$/.test(local)) {
|
|
856
|
-
port = Number.parseInt(local);
|
|
857
|
-
} else {
|
|
858
|
-
const parsed = Host.parseUrl(local, "http");
|
|
859
|
-
protocol = parsed.protocol;
|
|
860
|
-
host = parsed.host;
|
|
861
|
-
port = parsed.port;
|
|
862
|
-
}
|
|
863
|
-
} else if (local) {
|
|
864
|
-
protocol = local.protocol;
|
|
865
|
-
host = local.host;
|
|
866
|
-
port = local.port;
|
|
867
|
-
}
|
|
868
|
-
super({
|
|
869
|
-
protocol: protocol ?? "http",
|
|
870
|
-
host: host ?? "localhost",
|
|
871
|
-
port: port ?? generatePortFromName({ name: appName })
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
// src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
|
|
877
|
-
function generateAutomationBypassEnvVarName({
|
|
878
|
-
name
|
|
879
|
-
}) {
|
|
880
|
-
return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
652
|
// src/config/microfrontends-config/isomorphic/application.ts
|
|
884
653
|
var Application = class {
|
|
885
654
|
constructor(name, {
|
|
@@ -960,9 +729,6 @@ var ChildApplication = class extends Application {
|
|
|
960
729
|
}
|
|
961
730
|
};
|
|
962
731
|
|
|
963
|
-
// src/config/microfrontends-config/isomorphic/constants.ts
|
|
964
|
-
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
965
|
-
|
|
966
732
|
// src/config/microfrontends-config/isomorphic/index.ts
|
|
967
733
|
var MicrofrontendConfigIsomorphic = class {
|
|
968
734
|
constructor({
|
|
@@ -1006,7 +772,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
1006
772
|
};
|
|
1007
773
|
}
|
|
1008
774
|
static validate(config) {
|
|
1009
|
-
const c = typeof config === "string" ? (0,
|
|
775
|
+
const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
|
|
1010
776
|
validateConfigPaths(c.applications);
|
|
1011
777
|
validateConfigDefaultApplication(c.applications);
|
|
1012
778
|
return c;
|
|
@@ -1015,7 +781,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
1015
781
|
cookies
|
|
1016
782
|
}) {
|
|
1017
783
|
return new MicrofrontendConfigIsomorphic({
|
|
1018
|
-
config: (0,
|
|
784
|
+
config: (0, import_jsonc_parser.parse)(getConfigStringFromEnv()),
|
|
1019
785
|
overrides: parseOverrides(cookies ?? [])
|
|
1020
786
|
});
|
|
1021
787
|
}
|
|
@@ -1081,9 +847,17 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
1081
847
|
return this.defaultApplication;
|
|
1082
848
|
}
|
|
1083
849
|
/**
|
|
1084
|
-
* Returns the configured port for the local proxy
|
|
850
|
+
* Returns the configured port for the local proxy.
|
|
851
|
+
* Can be overridden via MFE_LOCAL_PROXY_PORT environment variable.
|
|
1085
852
|
*/
|
|
1086
853
|
getLocalProxyPort() {
|
|
854
|
+
const portOverride = process.env[MFE_LOCAL_PROXY_PORT_ENV];
|
|
855
|
+
if (portOverride) {
|
|
856
|
+
const port = Number.parseInt(portOverride, 10);
|
|
857
|
+
if (!Number.isNaN(port) && port > 0 && port < 65536) {
|
|
858
|
+
return port;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
1087
861
|
return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
1088
862
|
}
|
|
1089
863
|
toClientConfig(options) {
|
|
@@ -1121,36 +895,144 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
1121
895
|
}
|
|
1122
896
|
};
|
|
1123
897
|
|
|
898
|
+
// src/config/microfrontends/utils/find-config.ts
|
|
899
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
900
|
+
var import_node_path = require("path");
|
|
901
|
+
|
|
902
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
903
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
904
|
+
"microfrontends.json",
|
|
905
|
+
"microfrontends.jsonc"
|
|
906
|
+
];
|
|
907
|
+
function getPossibleConfigurationFilenames({
|
|
908
|
+
customConfigFilename
|
|
909
|
+
}) {
|
|
910
|
+
if (customConfigFilename) {
|
|
911
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
912
|
+
throw new Error(
|
|
913
|
+
`Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}. The file name must end with '.json' or '.jsonc'. It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
return Array.from(
|
|
917
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// src/config/microfrontends/utils/find-config.ts
|
|
924
|
+
function findConfig({
|
|
925
|
+
dir,
|
|
926
|
+
customConfigFilename
|
|
927
|
+
}) {
|
|
928
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
929
|
+
customConfigFilename
|
|
930
|
+
})) {
|
|
931
|
+
const maybeConfig = (0, import_node_path.join)(dir, filename);
|
|
932
|
+
if (import_node_fs.default.existsSync(maybeConfig)) {
|
|
933
|
+
return maybeConfig;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// src/config/microfrontends/utils/find-package-root.ts
|
|
940
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
941
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
942
|
+
var PACKAGE_JSON = "package.json";
|
|
943
|
+
function findPackageRoot(startDir) {
|
|
944
|
+
let currentDir = startDir || process.cwd();
|
|
945
|
+
while (currentDir !== import_node_path2.default.parse(currentDir).root) {
|
|
946
|
+
const pkgJsonPath = import_node_path2.default.join(currentDir, PACKAGE_JSON);
|
|
947
|
+
if (import_node_fs2.default.existsSync(pkgJsonPath)) {
|
|
948
|
+
return currentDir;
|
|
949
|
+
}
|
|
950
|
+
currentDir = import_node_path2.default.dirname(currentDir);
|
|
951
|
+
}
|
|
952
|
+
throw new Error(
|
|
953
|
+
`The root of the package that contains the \`package.json\` file for the \`${startDir}\` directory could not be found.`
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/config/microfrontends/utils/find-repository-root.ts
|
|
958
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
959
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
960
|
+
var GIT_DIRECTORY = ".git";
|
|
961
|
+
function hasGitDirectory(dir) {
|
|
962
|
+
const gitPath = import_node_path3.default.join(dir, GIT_DIRECTORY);
|
|
963
|
+
return import_node_fs3.default.existsSync(gitPath) && import_node_fs3.default.statSync(gitPath).isDirectory();
|
|
964
|
+
}
|
|
965
|
+
function hasPnpmWorkspaces(dir) {
|
|
966
|
+
return import_node_fs3.default.existsSync(import_node_path3.default.join(dir, "pnpm-workspace.yaml"));
|
|
967
|
+
}
|
|
968
|
+
function hasPackageJson(dir) {
|
|
969
|
+
return import_node_fs3.default.existsSync(import_node_path3.default.join(dir, "package.json"));
|
|
970
|
+
}
|
|
971
|
+
function findRepositoryRoot(startDir) {
|
|
972
|
+
if (process.env.NX_WORKSPACE_ROOT) {
|
|
973
|
+
return process.env.NX_WORKSPACE_ROOT;
|
|
974
|
+
}
|
|
975
|
+
let currentDir = startDir || process.cwd();
|
|
976
|
+
let lastPackageJsonDir = null;
|
|
977
|
+
while (currentDir !== import_node_path3.default.parse(currentDir).root) {
|
|
978
|
+
if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
|
|
979
|
+
return currentDir;
|
|
980
|
+
}
|
|
981
|
+
if (hasPackageJson(currentDir)) {
|
|
982
|
+
lastPackageJsonDir = currentDir;
|
|
983
|
+
}
|
|
984
|
+
currentDir = import_node_path3.default.dirname(currentDir);
|
|
985
|
+
}
|
|
986
|
+
if (lastPackageJsonDir) {
|
|
987
|
+
return lastPackageJsonDir;
|
|
988
|
+
}
|
|
989
|
+
throw new Error(
|
|
990
|
+
`Could not find the root of the repository for ${startDir}. Please ensure that the directory is part of a Git repository. If you suspect that this should work, please file an issue to the Vercel team.`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
|
|
1124
994
|
// src/config/microfrontends/utils/get-application-context.ts
|
|
1125
|
-
var
|
|
1126
|
-
var
|
|
995
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
996
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
1127
997
|
function getApplicationContext(opts) {
|
|
1128
998
|
if (opts?.appName) {
|
|
1129
|
-
logger.debug(
|
|
999
|
+
logger.debug(
|
|
1000
|
+
"[MFE Config] Application name from appName parameter:",
|
|
1001
|
+
opts.appName
|
|
1002
|
+
);
|
|
1130
1003
|
return { name: opts.appName };
|
|
1131
1004
|
}
|
|
1132
1005
|
if (process.env.VERCEL_PROJECT_NAME) {
|
|
1133
|
-
logger.debug(
|
|
1006
|
+
logger.debug(
|
|
1007
|
+
"[MFE Config] Application name from VERCEL_PROJECT_NAME:",
|
|
1008
|
+
process.env.VERCEL_PROJECT_NAME
|
|
1009
|
+
);
|
|
1134
1010
|
return {
|
|
1135
1011
|
name: process.env.VERCEL_PROJECT_NAME,
|
|
1136
1012
|
projectName: process.env.VERCEL_PROJECT_NAME
|
|
1137
1013
|
};
|
|
1138
1014
|
}
|
|
1139
1015
|
if (process.env.NX_TASK_TARGET_PROJECT) {
|
|
1140
|
-
logger.debug(
|
|
1016
|
+
logger.debug(
|
|
1017
|
+
"[MFE Config] Application name from NX_TASK_TARGET_PROJECT:",
|
|
1018
|
+
process.env.NX_TASK_TARGET_PROJECT
|
|
1019
|
+
);
|
|
1141
1020
|
return {
|
|
1142
1021
|
name: process.env.NX_TASK_TARGET_PROJECT,
|
|
1143
1022
|
packageJsonName: process.env.NX_TASK_TARGET_PROJECT
|
|
1144
1023
|
};
|
|
1145
1024
|
}
|
|
1146
1025
|
try {
|
|
1147
|
-
const vercelProjectJsonPath =
|
|
1148
|
-
|
|
1026
|
+
const vercelProjectJsonPath = import_node_fs4.default.readFileSync(
|
|
1027
|
+
import_node_path4.default.join(opts?.packageRoot || ".", ".vercel", "project.json"),
|
|
1149
1028
|
"utf-8"
|
|
1150
1029
|
);
|
|
1151
1030
|
const projectJson = JSON.parse(vercelProjectJsonPath);
|
|
1152
1031
|
if (projectJson.projectName) {
|
|
1153
|
-
logger.debug(
|
|
1032
|
+
logger.debug(
|
|
1033
|
+
"[MFE Config] Application name from .vercel/project.json:",
|
|
1034
|
+
projectJson.projectName
|
|
1035
|
+
);
|
|
1154
1036
|
return {
|
|
1155
1037
|
name: projectJson.projectName,
|
|
1156
1038
|
projectName: projectJson.projectName
|
|
@@ -1159,8 +1041,8 @@ function getApplicationContext(opts) {
|
|
|
1159
1041
|
} catch (_) {
|
|
1160
1042
|
}
|
|
1161
1043
|
try {
|
|
1162
|
-
const packageJsonString =
|
|
1163
|
-
|
|
1044
|
+
const packageJsonString = import_node_fs4.default.readFileSync(
|
|
1045
|
+
import_node_path4.default.join(opts?.packageRoot || ".", "package.json"),
|
|
1164
1046
|
"utf-8"
|
|
1165
1047
|
);
|
|
1166
1048
|
const packageJson = JSON.parse(packageJsonString);
|
|
@@ -1174,7 +1056,10 @@ function getApplicationContext(opts) {
|
|
|
1174
1056
|
}
|
|
1175
1057
|
);
|
|
1176
1058
|
}
|
|
1177
|
-
logger.debug(
|
|
1059
|
+
logger.debug(
|
|
1060
|
+
"[MFE Config] Application name from package.json:",
|
|
1061
|
+
packageJson.name
|
|
1062
|
+
);
|
|
1178
1063
|
return { name: packageJson.name, packageJsonName: packageJson.name };
|
|
1179
1064
|
} catch (err) {
|
|
1180
1065
|
throw MicrofrontendError.handle(err, {
|
|
@@ -1183,6 +1068,209 @@ function getApplicationContext(opts) {
|
|
|
1183
1068
|
}
|
|
1184
1069
|
}
|
|
1185
1070
|
|
|
1071
|
+
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
1072
|
+
var import_node_fs5 = require("fs");
|
|
1073
|
+
var import_node_path5 = require("path");
|
|
1074
|
+
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
1075
|
+
var import_jsonc_parser2 = require("jsonc-parser");
|
|
1076
|
+
var configCache = {};
|
|
1077
|
+
function findPackageWithMicrofrontendsConfig({
|
|
1078
|
+
repositoryRoot,
|
|
1079
|
+
applicationContext,
|
|
1080
|
+
customConfigFilename
|
|
1081
|
+
}) {
|
|
1082
|
+
const applicationName = applicationContext.name;
|
|
1083
|
+
logger.debug(
|
|
1084
|
+
"[MFE Config] Searching repository for configs containing application:",
|
|
1085
|
+
applicationName
|
|
1086
|
+
);
|
|
1087
|
+
try {
|
|
1088
|
+
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
1089
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
1090
|
+
{
|
|
1091
|
+
cwd: repositoryRoot,
|
|
1092
|
+
absolute: true,
|
|
1093
|
+
onlyFiles: true,
|
|
1094
|
+
followSymbolicLinks: false,
|
|
1095
|
+
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1098
|
+
logger.debug(
|
|
1099
|
+
"[MFE Config] Found",
|
|
1100
|
+
microfrontendsJsonPaths.length,
|
|
1101
|
+
"config file(s) in repository"
|
|
1102
|
+
);
|
|
1103
|
+
const matchingPaths = [];
|
|
1104
|
+
for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
|
|
1105
|
+
if (doesApplicationExistInConfig(microfrontendsJsonPath, applicationName)) {
|
|
1106
|
+
matchingPaths.push(microfrontendsJsonPath);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
logger.debug(
|
|
1110
|
+
"[MFE Config] Total matching config files:",
|
|
1111
|
+
matchingPaths.length
|
|
1112
|
+
);
|
|
1113
|
+
if (matchingPaths.length > 1) {
|
|
1114
|
+
throw new MicrofrontendError(
|
|
1115
|
+
`Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
|
|
1116
|
+
${matchingPaths.join("\n \u2022 ")}`,
|
|
1117
|
+
{ type: "config", subtype: "inference_failed" }
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
if (matchingPaths.length === 0) {
|
|
1121
|
+
if (repositoryRoot && doesMisplacedConfigExist(
|
|
1122
|
+
repositoryRoot,
|
|
1123
|
+
applicationName,
|
|
1124
|
+
customConfigFilename
|
|
1125
|
+
)) {
|
|
1126
|
+
logger.debug(
|
|
1127
|
+
"[MFE Config] Found misplaced config in wrong .vercel directory in repository"
|
|
1128
|
+
);
|
|
1129
|
+
const misplacedConfigPath = (0, import_node_path5.join)(
|
|
1130
|
+
repositoryRoot,
|
|
1131
|
+
".vercel",
|
|
1132
|
+
customConfigFilename || "microfrontends.json"
|
|
1133
|
+
);
|
|
1134
|
+
throw new MicrofrontendError(
|
|
1135
|
+
`Unable to automatically infer the location of the \`microfrontends.json\` file.
|
|
1136
|
+
|
|
1137
|
+
A microfrontends config was found in the \`.vercel\` directory at the repository root: ${misplacedConfigPath}
|
|
1138
|
+
However, in a monorepo, the config file should be placed in the \`.vercel\` directory in your application directory instead.
|
|
1139
|
+
|
|
1140
|
+
To fix this:
|
|
1141
|
+
1. If using \`vercel link\`, run it with \`vercel link --repo\` to handle monorepos, or run \`vercel microfrontends pull --cwd=<application-directory>\` to make sure it pulls the \`microfrontends.json\` file to the correct location
|
|
1142
|
+
2. If manually defined, move the config file to the \`.vercel\` directory in your application
|
|
1143
|
+
3. Alternatively, set the VC_MICROFRONTENDS_CONFIG environment variable to the correct path
|
|
1144
|
+
|
|
1145
|
+
For more information, see: https://vercel.com/docs/cli/project-linking`,
|
|
1146
|
+
{ type: "config", subtype: "inference_failed" }
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
let additionalErrorMessage = "";
|
|
1150
|
+
if (microfrontendsJsonPaths.length > 0) {
|
|
1151
|
+
if (!applicationContext.projectName) {
|
|
1152
|
+
additionalErrorMessage = `
|
|
1153
|
+
|
|
1154
|
+
If the name in package.json (${applicationContext.packageJsonName}) differs from your Vercel Project name, set the \`packageName\` field for the application in \`microfrontends.json\` to ensure that the configuration can be found locally.`;
|
|
1155
|
+
} else {
|
|
1156
|
+
additionalErrorMessage = `
|
|
1157
|
+
|
|
1158
|
+
Names of applications in \`microfrontends.json\` must match the Vercel Project name (${applicationContext.projectName}).`;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
throw new MicrofrontendError(
|
|
1162
|
+
`Could not find a \`microfrontends.json\` file in the repository that contains the "${applicationName}" application.${additionalErrorMessage}
|
|
1163
|
+
|
|
1164
|
+
If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the "vercel microfrontends pull" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable.
|
|
1165
|
+
|
|
1166
|
+
If your Vercel Microfrontends configuration has a custom name, ensure the VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable is set, you can pull the vercel project environment variables using the "vercel env pull" command.
|
|
1167
|
+
|
|
1168
|
+
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
1169
|
+
{ type: "config", subtype: "inference_failed" }
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
const [packageJsonPath] = matchingPaths;
|
|
1173
|
+
return (0, import_node_path5.dirname)(packageJsonPath);
|
|
1174
|
+
} catch (error2) {
|
|
1175
|
+
if (error2 instanceof MicrofrontendError) {
|
|
1176
|
+
throw error2;
|
|
1177
|
+
}
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
function inferMicrofrontendsLocation(opts) {
|
|
1182
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
1183
|
+
if (configCache[cacheKey]) {
|
|
1184
|
+
return configCache[cacheKey];
|
|
1185
|
+
}
|
|
1186
|
+
const result = findPackageWithMicrofrontendsConfig(opts);
|
|
1187
|
+
if (!result) {
|
|
1188
|
+
throw new MicrofrontendError(
|
|
1189
|
+
`Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationContext.name}" starting in directory "${opts.repositoryRoot}".`,
|
|
1190
|
+
{ type: "config", subtype: "inference_failed" }
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
configCache[cacheKey] = result;
|
|
1194
|
+
return result;
|
|
1195
|
+
}
|
|
1196
|
+
function existsSync(path6) {
|
|
1197
|
+
try {
|
|
1198
|
+
(0, import_node_fs5.statSync)(path6);
|
|
1199
|
+
return true;
|
|
1200
|
+
} catch (_) {
|
|
1201
|
+
return false;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
function doesMisplacedConfigExist(repositoryRoot, applicationName, customConfigFilename) {
|
|
1205
|
+
logger.debug(
|
|
1206
|
+
"[MFE Config] Looking for misplaced config in wrong .vercel directory"
|
|
1207
|
+
);
|
|
1208
|
+
const misplacedConfigPath = (0, import_node_path5.join)(
|
|
1209
|
+
repositoryRoot,
|
|
1210
|
+
".vercel",
|
|
1211
|
+
customConfigFilename || "microfrontends.json"
|
|
1212
|
+
);
|
|
1213
|
+
return existsSync(misplacedConfigPath) && doesApplicationExistInConfig(misplacedConfigPath, applicationName);
|
|
1214
|
+
}
|
|
1215
|
+
function doesApplicationExistInConfig(microfrontendsJsonPath, applicationName) {
|
|
1216
|
+
try {
|
|
1217
|
+
const microfrontendsJsonContent = (0, import_node_fs5.readFileSync)(
|
|
1218
|
+
microfrontendsJsonPath,
|
|
1219
|
+
"utf-8"
|
|
1220
|
+
);
|
|
1221
|
+
const microfrontendsJson = (0, import_jsonc_parser2.parse)(microfrontendsJsonContent);
|
|
1222
|
+
if (microfrontendsJson.applications[applicationName]) {
|
|
1223
|
+
logger.debug(
|
|
1224
|
+
"[MFE Config] Found application in config:",
|
|
1225
|
+
microfrontendsJsonPath
|
|
1226
|
+
);
|
|
1227
|
+
return true;
|
|
1228
|
+
}
|
|
1229
|
+
for (const [_, app] of Object.entries(microfrontendsJson.applications)) {
|
|
1230
|
+
if (app.packageName === applicationName) {
|
|
1231
|
+
logger.debug(
|
|
1232
|
+
"[MFE Config] Found application via packageName in config:",
|
|
1233
|
+
microfrontendsJsonPath
|
|
1234
|
+
);
|
|
1235
|
+
return true;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
} catch (error2) {
|
|
1239
|
+
logger.debug("[MFE Config] Error checking application in config:", error2);
|
|
1240
|
+
}
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// src/config/microfrontends/utils/is-monorepo.ts
|
|
1245
|
+
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
1246
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
1247
|
+
function isMonorepo({
|
|
1248
|
+
repositoryRoot
|
|
1249
|
+
}) {
|
|
1250
|
+
try {
|
|
1251
|
+
if (import_node_fs6.default.existsSync(import_node_path6.default.join(repositoryRoot, "pnpm-workspace.yaml"))) {
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
if (import_node_fs6.default.existsSync(import_node_path6.default.join(repositoryRoot, "vlt-workspaces.json"))) {
|
|
1255
|
+
return true;
|
|
1256
|
+
}
|
|
1257
|
+
if (process.env.NX_WORKSPACE_ROOT === import_node_path6.default.resolve(repositoryRoot)) {
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
const packageJsonPath = import_node_path6.default.join(repositoryRoot, "package.json");
|
|
1261
|
+
if (!import_node_fs6.default.existsSync(packageJsonPath)) {
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
const packageJson = JSON.parse(
|
|
1265
|
+
import_node_fs6.default.readFileSync(packageJsonPath, "utf-8")
|
|
1266
|
+
);
|
|
1267
|
+
return packageJson.workspaces !== void 0;
|
|
1268
|
+
} catch (error2) {
|
|
1269
|
+
logger.error("Error determining if repository is a monorepo", error2);
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1186
1274
|
// src/config/microfrontends/server/utils/get-output-file-path.ts
|
|
1187
1275
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
1188
1276
|
|
|
@@ -1196,8 +1284,8 @@ function getOutputFilePath() {
|
|
|
1196
1284
|
}
|
|
1197
1285
|
|
|
1198
1286
|
// src/config/microfrontends/server/validation.ts
|
|
1199
|
-
var import_jsonc_parser3 = require("jsonc-parser");
|
|
1200
1287
|
var import_ajv = require("ajv");
|
|
1288
|
+
var import_jsonc_parser3 = require("jsonc-parser");
|
|
1201
1289
|
|
|
1202
1290
|
// schema/schema.json
|
|
1203
1291
|
var schema_default = {
|
|
@@ -1225,9 +1313,7 @@ var schema_default = {
|
|
|
1225
1313
|
description: "Optional configuration options for the microfrontend."
|
|
1226
1314
|
}
|
|
1227
1315
|
},
|
|
1228
|
-
required: [
|
|
1229
|
-
"applications"
|
|
1230
|
-
],
|
|
1316
|
+
required: ["applications"],
|
|
1231
1317
|
additionalProperties: false,
|
|
1232
1318
|
description: "The microfrontends configuration schema. See https://vercel.com/docs/microfrontends/configuration."
|
|
1233
1319
|
},
|
|
@@ -1264,19 +1350,14 @@ var schema_default = {
|
|
|
1264
1350
|
description: "Development configuration for the default application."
|
|
1265
1351
|
}
|
|
1266
1352
|
},
|
|
1267
|
-
required: [
|
|
1268
|
-
"development"
|
|
1269
|
-
],
|
|
1353
|
+
required: ["development"],
|
|
1270
1354
|
additionalProperties: false
|
|
1271
1355
|
},
|
|
1272
1356
|
DefaultDevelopment: {
|
|
1273
1357
|
type: "object",
|
|
1274
1358
|
properties: {
|
|
1275
1359
|
local: {
|
|
1276
|
-
type: [
|
|
1277
|
-
"number",
|
|
1278
|
-
"string"
|
|
1279
|
-
],
|
|
1360
|
+
type: ["number", "string"],
|
|
1280
1361
|
description: "A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\n\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\n\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\n\nSee https://vercel.com/docs/microfrontends/local-development."
|
|
1281
1362
|
},
|
|
1282
1363
|
task: {
|
|
@@ -1288,9 +1369,7 @@ var schema_default = {
|
|
|
1288
1369
|
description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\n\nSee https://vercel.com/docs/microfrontends/local-development."
|
|
1289
1370
|
}
|
|
1290
1371
|
},
|
|
1291
|
-
required: [
|
|
1292
|
-
"fallback"
|
|
1293
|
-
],
|
|
1372
|
+
required: ["fallback"],
|
|
1294
1373
|
additionalProperties: false
|
|
1295
1374
|
},
|
|
1296
1375
|
ChildApplication: {
|
|
@@ -1313,19 +1392,14 @@ var schema_default = {
|
|
|
1313
1392
|
description: "The name of the asset prefix to use instead of the auto-generated name.\n\nThe asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain.\n\nAn auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided.\n\nWhen this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field.\n\nThe default value is the auto-generated asset prefix of the form `vc-ap-<hash>`.\n\nSee https://vercel.com/docs/microfrontends/path-routing#asset-prefix."
|
|
1314
1393
|
}
|
|
1315
1394
|
},
|
|
1316
|
-
required: [
|
|
1317
|
-
"routing"
|
|
1318
|
-
],
|
|
1395
|
+
required: ["routing"],
|
|
1319
1396
|
additionalProperties: false
|
|
1320
1397
|
},
|
|
1321
1398
|
ChildDevelopment: {
|
|
1322
1399
|
type: "object",
|
|
1323
1400
|
properties: {
|
|
1324
1401
|
local: {
|
|
1325
|
-
type: [
|
|
1326
|
-
"number",
|
|
1327
|
-
"string"
|
|
1328
|
-
],
|
|
1402
|
+
type: ["number", "string"],
|
|
1329
1403
|
description: "A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\n\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\n\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\n\nSee https://vercel.com/docs/microfrontends/local-development."
|
|
1330
1404
|
},
|
|
1331
1405
|
task: {
|
|
@@ -1365,9 +1439,7 @@ var schema_default = {
|
|
|
1365
1439
|
description: "A list of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions."
|
|
1366
1440
|
}
|
|
1367
1441
|
},
|
|
1368
|
-
required: [
|
|
1369
|
-
"paths"
|
|
1370
|
-
],
|
|
1442
|
+
required: ["paths"],
|
|
1371
1443
|
additionalProperties: false,
|
|
1372
1444
|
description: "A group of paths that is routed to this application."
|
|
1373
1445
|
},
|