@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
|
@@ -222,22 +222,38 @@ var import_node_fs2 = require("fs");
|
|
|
222
222
|
var import_jsonc_parser = require("jsonc-parser");
|
|
223
223
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
224
224
|
|
|
225
|
-
// src/config/
|
|
226
|
-
var
|
|
225
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
226
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
227
227
|
"microfrontends.jsonc",
|
|
228
228
|
"microfrontends.json"
|
|
229
229
|
];
|
|
230
|
+
function getPossibleConfigurationFilenames({
|
|
231
|
+
customConfigFilename
|
|
232
|
+
}) {
|
|
233
|
+
if (customConfigFilename) {
|
|
234
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return Array.from(
|
|
240
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
244
|
+
}
|
|
230
245
|
|
|
231
246
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
232
247
|
var configCache = {};
|
|
233
248
|
function findPackageWithMicrofrontendsConfig({
|
|
234
249
|
repositoryRoot,
|
|
235
|
-
applicationContext
|
|
250
|
+
applicationContext,
|
|
251
|
+
customConfigFilename
|
|
236
252
|
}) {
|
|
237
253
|
const applicationName = applicationContext.name;
|
|
238
254
|
try {
|
|
239
255
|
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
240
|
-
`**/{${
|
|
256
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
241
257
|
{
|
|
242
258
|
cwd: repositoryRoot,
|
|
243
259
|
absolute: true,
|
|
@@ -293,6 +309,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
293
309
|
|
|
294
310
|
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.
|
|
295
311
|
|
|
312
|
+
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.
|
|
313
|
+
|
|
296
314
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
297
315
|
{ type: "config", subtype: "inference_failed" }
|
|
298
316
|
);
|
|
@@ -307,7 +325,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
307
325
|
}
|
|
308
326
|
}
|
|
309
327
|
function inferMicrofrontendsLocation(opts) {
|
|
310
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
328
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
311
329
|
if (configCache[cacheKey]) {
|
|
312
330
|
return configCache[cacheKey];
|
|
313
331
|
}
|
|
@@ -373,8 +391,13 @@ function findPackageRoot(startDir) {
|
|
|
373
391
|
// src/config/microfrontends/utils/find-config.ts
|
|
374
392
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
375
393
|
var import_node_path5 = require("path");
|
|
376
|
-
function findConfig({
|
|
377
|
-
|
|
394
|
+
function findConfig({
|
|
395
|
+
dir,
|
|
396
|
+
customConfigFilename
|
|
397
|
+
}) {
|
|
398
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
399
|
+
customConfigFilename
|
|
400
|
+
})) {
|
|
378
401
|
const maybeConfig = (0, import_node_path5.join)(dir, filename);
|
|
379
402
|
if (import_node_fs5.default.existsSync(maybeConfig)) {
|
|
380
403
|
return maybeConfig;
|
|
@@ -1477,7 +1500,11 @@ var MicrofrontendsServer = class {
|
|
|
1477
1500
|
appName,
|
|
1478
1501
|
packageRoot
|
|
1479
1502
|
});
|
|
1480
|
-
const
|
|
1503
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1504
|
+
const maybeConfig = findConfig({
|
|
1505
|
+
dir: packageRoot,
|
|
1506
|
+
customConfigFilename
|
|
1507
|
+
});
|
|
1481
1508
|
if (maybeConfig) {
|
|
1482
1509
|
return MicrofrontendsServer.fromFile({
|
|
1483
1510
|
filePath: maybeConfig,
|
|
@@ -1486,11 +1513,9 @@ var MicrofrontendsServer = class {
|
|
|
1486
1513
|
}
|
|
1487
1514
|
const repositoryRoot = findRepositoryRoot();
|
|
1488
1515
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1493
|
-
);
|
|
1516
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1517
|
+
if (typeof configFromEnv === "string") {
|
|
1518
|
+
const maybeConfigFromEnv = (0, import_node_path8.resolve)(packageRoot, configFromEnv);
|
|
1494
1519
|
if (maybeConfigFromEnv) {
|
|
1495
1520
|
return MicrofrontendsServer.fromFile({
|
|
1496
1521
|
filePath: maybeConfigFromEnv,
|
|
@@ -1499,7 +1524,8 @@ var MicrofrontendsServer = class {
|
|
|
1499
1524
|
}
|
|
1500
1525
|
} else {
|
|
1501
1526
|
const maybeConfigFromVercel = findConfig({
|
|
1502
|
-
dir: (0, import_node_path8.join)(packageRoot, ".vercel")
|
|
1527
|
+
dir: (0, import_node_path8.join)(packageRoot, ".vercel"),
|
|
1528
|
+
customConfigFilename
|
|
1503
1529
|
});
|
|
1504
1530
|
if (maybeConfigFromVercel) {
|
|
1505
1531
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1510,9 +1536,13 @@ var MicrofrontendsServer = class {
|
|
|
1510
1536
|
if (isMonorepo2) {
|
|
1511
1537
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1512
1538
|
repositoryRoot,
|
|
1513
|
-
applicationContext
|
|
1539
|
+
applicationContext,
|
|
1540
|
+
customConfigFilename
|
|
1541
|
+
});
|
|
1542
|
+
const maybeConfigFromDefault = findConfig({
|
|
1543
|
+
dir: defaultPackage,
|
|
1544
|
+
customConfigFilename
|
|
1514
1545
|
});
|
|
1515
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1516
1546
|
if (maybeConfigFromDefault) {
|
|
1517
1547
|
return MicrofrontendsServer.fromFile({
|
|
1518
1548
|
filePath: maybeConfigFromDefault,
|