@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/next/config.js
CHANGED
|
@@ -204,22 +204,38 @@ import { readFileSync } from "node:fs";
|
|
|
204
204
|
import { parse } from "jsonc-parser";
|
|
205
205
|
import fg from "fast-glob";
|
|
206
206
|
|
|
207
|
-
// src/config/
|
|
208
|
-
var
|
|
207
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
208
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
209
209
|
"microfrontends.jsonc",
|
|
210
210
|
"microfrontends.json"
|
|
211
211
|
];
|
|
212
|
+
function getPossibleConfigurationFilenames({
|
|
213
|
+
customConfigFilename
|
|
214
|
+
}) {
|
|
215
|
+
if (customConfigFilename) {
|
|
216
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
217
|
+
throw new Error(
|
|
218
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
return Array.from(
|
|
222
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
226
|
+
}
|
|
212
227
|
|
|
213
228
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
214
229
|
var configCache = {};
|
|
215
230
|
function findPackageWithMicrofrontendsConfig({
|
|
216
231
|
repositoryRoot,
|
|
217
|
-
applicationContext
|
|
232
|
+
applicationContext,
|
|
233
|
+
customConfigFilename
|
|
218
234
|
}) {
|
|
219
235
|
const applicationName = applicationContext.name;
|
|
220
236
|
try {
|
|
221
237
|
const microfrontendsJsonPaths = fg.globSync(
|
|
222
|
-
`**/{${
|
|
238
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
223
239
|
{
|
|
224
240
|
cwd: repositoryRoot,
|
|
225
241
|
absolute: true,
|
|
@@ -275,6 +291,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
275
291
|
|
|
276
292
|
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.
|
|
277
293
|
|
|
294
|
+
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.
|
|
295
|
+
|
|
278
296
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
279
297
|
{ type: "config", subtype: "inference_failed" }
|
|
280
298
|
);
|
|
@@ -289,7 +307,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
289
307
|
}
|
|
290
308
|
}
|
|
291
309
|
function inferMicrofrontendsLocation(opts) {
|
|
292
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
310
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
293
311
|
if (configCache[cacheKey]) {
|
|
294
312
|
return configCache[cacheKey];
|
|
295
313
|
}
|
|
@@ -355,8 +373,13 @@ function findPackageRoot(startDir) {
|
|
|
355
373
|
// src/config/microfrontends/utils/find-config.ts
|
|
356
374
|
import fs4 from "node:fs";
|
|
357
375
|
import { join } from "node:path";
|
|
358
|
-
function findConfig({
|
|
359
|
-
|
|
376
|
+
function findConfig({
|
|
377
|
+
dir,
|
|
378
|
+
customConfigFilename
|
|
379
|
+
}) {
|
|
380
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
381
|
+
customConfigFilename
|
|
382
|
+
})) {
|
|
360
383
|
const maybeConfig = join(dir, filename);
|
|
361
384
|
if (fs4.existsSync(maybeConfig)) {
|
|
362
385
|
return maybeConfig;
|
|
@@ -1459,7 +1482,11 @@ var MicrofrontendsServer = class {
|
|
|
1459
1482
|
appName,
|
|
1460
1483
|
packageRoot
|
|
1461
1484
|
});
|
|
1462
|
-
const
|
|
1485
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1486
|
+
const maybeConfig = findConfig({
|
|
1487
|
+
dir: packageRoot,
|
|
1488
|
+
customConfigFilename
|
|
1489
|
+
});
|
|
1463
1490
|
if (maybeConfig) {
|
|
1464
1491
|
return MicrofrontendsServer.fromFile({
|
|
1465
1492
|
filePath: maybeConfig,
|
|
@@ -1468,11 +1495,9 @@ var MicrofrontendsServer = class {
|
|
|
1468
1495
|
}
|
|
1469
1496
|
const repositoryRoot = findRepositoryRoot();
|
|
1470
1497
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1475
|
-
);
|
|
1498
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1499
|
+
if (typeof configFromEnv === "string") {
|
|
1500
|
+
const maybeConfigFromEnv = resolve(packageRoot, configFromEnv);
|
|
1476
1501
|
if (maybeConfigFromEnv) {
|
|
1477
1502
|
return MicrofrontendsServer.fromFile({
|
|
1478
1503
|
filePath: maybeConfigFromEnv,
|
|
@@ -1481,7 +1506,8 @@ var MicrofrontendsServer = class {
|
|
|
1481
1506
|
}
|
|
1482
1507
|
} else {
|
|
1483
1508
|
const maybeConfigFromVercel = findConfig({
|
|
1484
|
-
dir: join2(packageRoot, ".vercel")
|
|
1509
|
+
dir: join2(packageRoot, ".vercel"),
|
|
1510
|
+
customConfigFilename
|
|
1485
1511
|
});
|
|
1486
1512
|
if (maybeConfigFromVercel) {
|
|
1487
1513
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1492,9 +1518,13 @@ var MicrofrontendsServer = class {
|
|
|
1492
1518
|
if (isMonorepo2) {
|
|
1493
1519
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1494
1520
|
repositoryRoot,
|
|
1495
|
-
applicationContext
|
|
1521
|
+
applicationContext,
|
|
1522
|
+
customConfigFilename
|
|
1523
|
+
});
|
|
1524
|
+
const maybeConfigFromDefault = findConfig({
|
|
1525
|
+
dir: defaultPackage,
|
|
1526
|
+
customConfigFilename
|
|
1496
1527
|
});
|
|
1497
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1498
1528
|
if (maybeConfigFromDefault) {
|
|
1499
1529
|
return MicrofrontendsServer.fromFile({
|
|
1500
1530
|
filePath: maybeConfigFromDefault,
|
|
@@ -1645,7 +1675,14 @@ function transform4(args) {
|
|
|
1645
1675
|
source: "/:path*",
|
|
1646
1676
|
destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
|
|
1647
1677
|
permanent: false,
|
|
1648
|
-
missing: [
|
|
1678
|
+
missing: [
|
|
1679
|
+
{ type: "header", key: "x-vercel-mfe-local-proxy-origin" },
|
|
1680
|
+
{
|
|
1681
|
+
type: "host",
|
|
1682
|
+
value: `localhost:${microfrontend.getLocalProxyPort()}`
|
|
1683
|
+
// if it's already on the host, we don't need to redirect
|
|
1684
|
+
}
|
|
1685
|
+
]
|
|
1649
1686
|
}
|
|
1650
1687
|
];
|
|
1651
1688
|
if (next.redirects && typeof next.redirects === "function") {
|
|
@@ -1733,6 +1770,14 @@ function transform6(args) {
|
|
|
1733
1770
|
pathname: "/.well-known/vercel/flags"
|
|
1734
1771
|
}
|
|
1735
1772
|
});
|
|
1773
|
+
rewrites.set(
|
|
1774
|
+
`/${app.getAssetPrefix()}/.well-known/vercel/rate-limit-api/:path*`,
|
|
1775
|
+
{
|
|
1776
|
+
destination: {
|
|
1777
|
+
pathname: "/.well-known/vercel/rate-limit-api/:path*"
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
);
|
|
1736
1781
|
rewrites.set(`/${app.getAssetPrefix()}/_vercel/:path*`, {
|
|
1737
1782
|
destination: {
|
|
1738
1783
|
pathname: "/_vercel/:path*"
|
|
@@ -1920,6 +1965,9 @@ function setEnvironment({
|
|
|
1920
1965
|
removeFlaggedPaths: true
|
|
1921
1966
|
}).serialize()
|
|
1922
1967
|
),
|
|
1968
|
+
...app.getAssetPrefix() ? {
|
|
1969
|
+
NEXT_PUBLIC_VERCEL_FIREWALL_PATH_PREFIX: `/${app.getAssetPrefix()}`
|
|
1970
|
+
} : {},
|
|
1923
1971
|
...process.env.ROUTE_OBSERVABILITY_TO_THIS_PROJECT && app.getAssetPrefix() ? {
|
|
1924
1972
|
NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH: `/${app.getAssetPrefix()}/_vercel`
|
|
1925
1973
|
} : {}
|