@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
|
@@ -196,22 +196,38 @@ import { readFileSync } from "node:fs";
|
|
|
196
196
|
import { parse } from "jsonc-parser";
|
|
197
197
|
import fg from "fast-glob";
|
|
198
198
|
|
|
199
|
-
// src/config/
|
|
200
|
-
var
|
|
199
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
200
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
201
201
|
"microfrontends.jsonc",
|
|
202
202
|
"microfrontends.json"
|
|
203
203
|
];
|
|
204
|
+
function getPossibleConfigurationFilenames({
|
|
205
|
+
customConfigFilename
|
|
206
|
+
}) {
|
|
207
|
+
if (customConfigFilename) {
|
|
208
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return Array.from(
|
|
214
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
218
|
+
}
|
|
204
219
|
|
|
205
220
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
206
221
|
var configCache = {};
|
|
207
222
|
function findPackageWithMicrofrontendsConfig({
|
|
208
223
|
repositoryRoot,
|
|
209
|
-
applicationContext
|
|
224
|
+
applicationContext,
|
|
225
|
+
customConfigFilename
|
|
210
226
|
}) {
|
|
211
227
|
const applicationName = applicationContext.name;
|
|
212
228
|
try {
|
|
213
229
|
const microfrontendsJsonPaths = fg.globSync(
|
|
214
|
-
`**/{${
|
|
230
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
215
231
|
{
|
|
216
232
|
cwd: repositoryRoot,
|
|
217
233
|
absolute: true,
|
|
@@ -267,6 +283,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
267
283
|
|
|
268
284
|
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.
|
|
269
285
|
|
|
286
|
+
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.
|
|
287
|
+
|
|
270
288
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
271
289
|
{ type: "config", subtype: "inference_failed" }
|
|
272
290
|
);
|
|
@@ -281,7 +299,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
281
299
|
}
|
|
282
300
|
}
|
|
283
301
|
function inferMicrofrontendsLocation(opts) {
|
|
284
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
302
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
285
303
|
if (configCache[cacheKey]) {
|
|
286
304
|
return configCache[cacheKey];
|
|
287
305
|
}
|
|
@@ -347,8 +365,13 @@ function findPackageRoot(startDir) {
|
|
|
347
365
|
// src/config/microfrontends/utils/find-config.ts
|
|
348
366
|
import fs4 from "node:fs";
|
|
349
367
|
import { join } from "node:path";
|
|
350
|
-
function findConfig({
|
|
351
|
-
|
|
368
|
+
function findConfig({
|
|
369
|
+
dir,
|
|
370
|
+
customConfigFilename
|
|
371
|
+
}) {
|
|
372
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
373
|
+
customConfigFilename
|
|
374
|
+
})) {
|
|
352
375
|
const maybeConfig = join(dir, filename);
|
|
353
376
|
if (fs4.existsSync(maybeConfig)) {
|
|
354
377
|
return maybeConfig;
|
|
@@ -1451,7 +1474,11 @@ var MicrofrontendsServer = class {
|
|
|
1451
1474
|
appName,
|
|
1452
1475
|
packageRoot
|
|
1453
1476
|
});
|
|
1454
|
-
const
|
|
1477
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1478
|
+
const maybeConfig = findConfig({
|
|
1479
|
+
dir: packageRoot,
|
|
1480
|
+
customConfigFilename
|
|
1481
|
+
});
|
|
1455
1482
|
if (maybeConfig) {
|
|
1456
1483
|
return MicrofrontendsServer.fromFile({
|
|
1457
1484
|
filePath: maybeConfig,
|
|
@@ -1460,11 +1487,9 @@ var MicrofrontendsServer = class {
|
|
|
1460
1487
|
}
|
|
1461
1488
|
const repositoryRoot = findRepositoryRoot();
|
|
1462
1489
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1467
|
-
);
|
|
1490
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1491
|
+
if (typeof configFromEnv === "string") {
|
|
1492
|
+
const maybeConfigFromEnv = resolve(packageRoot, configFromEnv);
|
|
1468
1493
|
if (maybeConfigFromEnv) {
|
|
1469
1494
|
return MicrofrontendsServer.fromFile({
|
|
1470
1495
|
filePath: maybeConfigFromEnv,
|
|
@@ -1473,7 +1498,8 @@ var MicrofrontendsServer = class {
|
|
|
1473
1498
|
}
|
|
1474
1499
|
} else {
|
|
1475
1500
|
const maybeConfigFromVercel = findConfig({
|
|
1476
|
-
dir: join2(packageRoot, ".vercel")
|
|
1501
|
+
dir: join2(packageRoot, ".vercel"),
|
|
1502
|
+
customConfigFilename
|
|
1477
1503
|
});
|
|
1478
1504
|
if (maybeConfigFromVercel) {
|
|
1479
1505
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1484,9 +1510,13 @@ var MicrofrontendsServer = class {
|
|
|
1484
1510
|
if (isMonorepo2) {
|
|
1485
1511
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1486
1512
|
repositoryRoot,
|
|
1487
|
-
applicationContext
|
|
1513
|
+
applicationContext,
|
|
1514
|
+
customConfigFilename
|
|
1515
|
+
});
|
|
1516
|
+
const maybeConfigFromDefault = findConfig({
|
|
1517
|
+
dir: defaultPackage,
|
|
1518
|
+
customConfigFilename
|
|
1488
1519
|
});
|
|
1489
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1490
1520
|
if (maybeConfigFromDefault) {
|
|
1491
1521
|
return MicrofrontendsServer.fromFile({
|
|
1492
1522
|
filePath: maybeConfigFromDefault,
|