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