@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
package/dist/utils/mfe-port.js
CHANGED
|
@@ -191,22 +191,38 @@ import { readFileSync } from "node:fs";
|
|
|
191
191
|
import { parse } from "jsonc-parser";
|
|
192
192
|
import fg from "fast-glob";
|
|
193
193
|
|
|
194
|
-
// src/config/
|
|
195
|
-
var
|
|
194
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
195
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
196
196
|
"microfrontends.jsonc",
|
|
197
197
|
"microfrontends.json"
|
|
198
198
|
];
|
|
199
|
+
function getPossibleConfigurationFilenames({
|
|
200
|
+
customConfigFilename
|
|
201
|
+
}) {
|
|
202
|
+
if (customConfigFilename) {
|
|
203
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return Array.from(
|
|
209
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
213
|
+
}
|
|
199
214
|
|
|
200
215
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
201
216
|
var configCache = {};
|
|
202
217
|
function findPackageWithMicrofrontendsConfig({
|
|
203
218
|
repositoryRoot,
|
|
204
|
-
applicationContext
|
|
219
|
+
applicationContext,
|
|
220
|
+
customConfigFilename
|
|
205
221
|
}) {
|
|
206
222
|
const applicationName = applicationContext.name;
|
|
207
223
|
try {
|
|
208
224
|
const microfrontendsJsonPaths = fg.globSync(
|
|
209
|
-
`**/{${
|
|
225
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
210
226
|
{
|
|
211
227
|
cwd: repositoryRoot,
|
|
212
228
|
absolute: true,
|
|
@@ -262,6 +278,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
262
278
|
|
|
263
279
|
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.
|
|
264
280
|
|
|
281
|
+
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.
|
|
282
|
+
|
|
265
283
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
266
284
|
{ type: "config", subtype: "inference_failed" }
|
|
267
285
|
);
|
|
@@ -276,7 +294,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
276
294
|
}
|
|
277
295
|
}
|
|
278
296
|
function inferMicrofrontendsLocation(opts) {
|
|
279
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
297
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
280
298
|
if (configCache[cacheKey]) {
|
|
281
299
|
return configCache[cacheKey];
|
|
282
300
|
}
|
|
@@ -342,8 +360,13 @@ function findPackageRoot(startDir) {
|
|
|
342
360
|
// src/config/microfrontends/utils/find-config.ts
|
|
343
361
|
import fs4 from "node:fs";
|
|
344
362
|
import { join } from "node:path";
|
|
345
|
-
function findConfig({
|
|
346
|
-
|
|
363
|
+
function findConfig({
|
|
364
|
+
dir,
|
|
365
|
+
customConfigFilename
|
|
366
|
+
}) {
|
|
367
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
368
|
+
customConfigFilename
|
|
369
|
+
})) {
|
|
347
370
|
const maybeConfig = join(dir, filename);
|
|
348
371
|
if (fs4.existsSync(maybeConfig)) {
|
|
349
372
|
return maybeConfig;
|
|
@@ -1446,7 +1469,11 @@ var MicrofrontendsServer = class {
|
|
|
1446
1469
|
appName,
|
|
1447
1470
|
packageRoot
|
|
1448
1471
|
});
|
|
1449
|
-
const
|
|
1472
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1473
|
+
const maybeConfig = findConfig({
|
|
1474
|
+
dir: packageRoot,
|
|
1475
|
+
customConfigFilename
|
|
1476
|
+
});
|
|
1450
1477
|
if (maybeConfig) {
|
|
1451
1478
|
return MicrofrontendsServer.fromFile({
|
|
1452
1479
|
filePath: maybeConfig,
|
|
@@ -1455,11 +1482,9 @@ var MicrofrontendsServer = class {
|
|
|
1455
1482
|
}
|
|
1456
1483
|
const repositoryRoot = findRepositoryRoot();
|
|
1457
1484
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1462
|
-
);
|
|
1485
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1486
|
+
if (typeof configFromEnv === "string") {
|
|
1487
|
+
const maybeConfigFromEnv = resolve(packageRoot, configFromEnv);
|
|
1463
1488
|
if (maybeConfigFromEnv) {
|
|
1464
1489
|
return MicrofrontendsServer.fromFile({
|
|
1465
1490
|
filePath: maybeConfigFromEnv,
|
|
@@ -1468,7 +1493,8 @@ var MicrofrontendsServer = class {
|
|
|
1468
1493
|
}
|
|
1469
1494
|
} else {
|
|
1470
1495
|
const maybeConfigFromVercel = findConfig({
|
|
1471
|
-
dir: join2(packageRoot, ".vercel")
|
|
1496
|
+
dir: join2(packageRoot, ".vercel"),
|
|
1497
|
+
customConfigFilename
|
|
1472
1498
|
});
|
|
1473
1499
|
if (maybeConfigFromVercel) {
|
|
1474
1500
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1479,9 +1505,13 @@ var MicrofrontendsServer = class {
|
|
|
1479
1505
|
if (isMonorepo2) {
|
|
1480
1506
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1481
1507
|
repositoryRoot,
|
|
1482
|
-
applicationContext
|
|
1508
|
+
applicationContext,
|
|
1509
|
+
customConfigFilename
|
|
1510
|
+
});
|
|
1511
|
+
const maybeConfigFromDefault = findConfig({
|
|
1512
|
+
dir: defaultPackage,
|
|
1513
|
+
customConfigFilename
|
|
1483
1514
|
});
|
|
1484
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1485
1515
|
if (maybeConfigFromDefault) {
|
|
1486
1516
|
return MicrofrontendsServer.fromFile({
|
|
1487
1517
|
filePath: maybeConfigFromDefault,
|