@vercel/microfrontends 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +1 -5
- package/dist/bin/cli.cjs +47 -17
- package/dist/experimental/sveltekit.cjs +46 -16
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +46 -16
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +46 -16
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +46 -16
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +46 -16
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.js +46 -16
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends/utils.cjs +32 -7
- package/dist/microfrontends/utils.cjs.map +1 -1
- package/dist/microfrontends/utils.d.ts +8 -2
- package/dist/microfrontends/utils.js +31 -7
- package/dist/microfrontends/utils.js.map +1 -1
- package/dist/next/config.cjs +57 -16
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +57 -16
- package/dist/next/config.js.map +1 -1
- package/dist/utils/mfe-port.cjs +46 -16
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +46 -16
- package/dist/utils/mfe-port.js.map +1 -1
- package/package.json +1 -1
|
@@ -223,22 +223,38 @@ var import_node_fs2 = require("fs");
|
|
|
223
223
|
var import_jsonc_parser = require("jsonc-parser");
|
|
224
224
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
225
225
|
|
|
226
|
-
// src/config/
|
|
227
|
-
var
|
|
226
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
227
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
228
228
|
"microfrontends.jsonc",
|
|
229
229
|
"microfrontends.json"
|
|
230
230
|
];
|
|
231
|
+
function getPossibleConfigurationFilenames({
|
|
232
|
+
customConfigFilename
|
|
233
|
+
}) {
|
|
234
|
+
if (customConfigFilename) {
|
|
235
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
return Array.from(
|
|
241
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
245
|
+
}
|
|
231
246
|
|
|
232
247
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
233
248
|
var configCache = {};
|
|
234
249
|
function findPackageWithMicrofrontendsConfig({
|
|
235
250
|
repositoryRoot,
|
|
236
|
-
applicationContext
|
|
251
|
+
applicationContext,
|
|
252
|
+
customConfigFilename
|
|
237
253
|
}) {
|
|
238
254
|
const applicationName = applicationContext.name;
|
|
239
255
|
try {
|
|
240
256
|
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
241
|
-
`**/{${
|
|
257
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
242
258
|
{
|
|
243
259
|
cwd: repositoryRoot,
|
|
244
260
|
absolute: true,
|
|
@@ -294,6 +310,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
294
310
|
|
|
295
311
|
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.
|
|
296
312
|
|
|
313
|
+
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.
|
|
314
|
+
|
|
297
315
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
298
316
|
{ type: "config", subtype: "inference_failed" }
|
|
299
317
|
);
|
|
@@ -308,7 +326,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
308
326
|
}
|
|
309
327
|
}
|
|
310
328
|
function inferMicrofrontendsLocation(opts) {
|
|
311
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
329
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
312
330
|
if (configCache[cacheKey]) {
|
|
313
331
|
return configCache[cacheKey];
|
|
314
332
|
}
|
|
@@ -374,8 +392,13 @@ function findPackageRoot(startDir) {
|
|
|
374
392
|
// src/config/microfrontends/utils/find-config.ts
|
|
375
393
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
376
394
|
var import_node_path5 = require("path");
|
|
377
|
-
function findConfig({
|
|
378
|
-
|
|
395
|
+
function findConfig({
|
|
396
|
+
dir,
|
|
397
|
+
customConfigFilename
|
|
398
|
+
}) {
|
|
399
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
400
|
+
customConfigFilename
|
|
401
|
+
})) {
|
|
379
402
|
const maybeConfig = (0, import_node_path5.join)(dir, filename);
|
|
380
403
|
if (import_node_fs5.default.existsSync(maybeConfig)) {
|
|
381
404
|
return maybeConfig;
|
|
@@ -1478,7 +1501,11 @@ var MicrofrontendsServer = class {
|
|
|
1478
1501
|
appName,
|
|
1479
1502
|
packageRoot
|
|
1480
1503
|
});
|
|
1481
|
-
const
|
|
1504
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1505
|
+
const maybeConfig = findConfig({
|
|
1506
|
+
dir: packageRoot,
|
|
1507
|
+
customConfigFilename
|
|
1508
|
+
});
|
|
1482
1509
|
if (maybeConfig) {
|
|
1483
1510
|
return MicrofrontendsServer.fromFile({
|
|
1484
1511
|
filePath: maybeConfig,
|
|
@@ -1487,11 +1514,9 @@ var MicrofrontendsServer = class {
|
|
|
1487
1514
|
}
|
|
1488
1515
|
const repositoryRoot = findRepositoryRoot();
|
|
1489
1516
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1494
|
-
);
|
|
1517
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1518
|
+
if (typeof configFromEnv === "string") {
|
|
1519
|
+
const maybeConfigFromEnv = (0, import_node_path8.resolve)(packageRoot, configFromEnv);
|
|
1495
1520
|
if (maybeConfigFromEnv) {
|
|
1496
1521
|
return MicrofrontendsServer.fromFile({
|
|
1497
1522
|
filePath: maybeConfigFromEnv,
|
|
@@ -1500,7 +1525,8 @@ var MicrofrontendsServer = class {
|
|
|
1500
1525
|
}
|
|
1501
1526
|
} else {
|
|
1502
1527
|
const maybeConfigFromVercel = findConfig({
|
|
1503
|
-
dir: (0, import_node_path8.join)(packageRoot, ".vercel")
|
|
1528
|
+
dir: (0, import_node_path8.join)(packageRoot, ".vercel"),
|
|
1529
|
+
customConfigFilename
|
|
1504
1530
|
});
|
|
1505
1531
|
if (maybeConfigFromVercel) {
|
|
1506
1532
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1511,9 +1537,13 @@ var MicrofrontendsServer = class {
|
|
|
1511
1537
|
if (isMonorepo2) {
|
|
1512
1538
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1513
1539
|
repositoryRoot,
|
|
1514
|
-
applicationContext
|
|
1540
|
+
applicationContext,
|
|
1541
|
+
customConfigFilename
|
|
1542
|
+
});
|
|
1543
|
+
const maybeConfigFromDefault = findConfig({
|
|
1544
|
+
dir: defaultPackage,
|
|
1545
|
+
customConfigFilename
|
|
1515
1546
|
});
|
|
1516
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1517
1547
|
if (maybeConfigFromDefault) {
|
|
1518
1548
|
return MicrofrontendsServer.fromFile({
|
|
1519
1549
|
filePath: maybeConfigFromDefault,
|