@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/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
# @vercel/microfrontends
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c856a5d:
|
|
8
|
+
- Add support for custom `microfrontends.json` file names. This enables a single application to be deployed as multiple different vercel projects / microfrontends.
|
|
9
|
+
- Strip asset prefix from Vercel Firewall rate limit paths. Support Vercel Firewall rate limit requests when they go to a child application.
|
|
10
|
+
|
|
3
11
|
## 2.0.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
7
|
-
- 8c11bdc:
|
|
15
|
+
- 8c11bdc:
|
|
8
16
|
- Support hyphens and escaped special characters in supported path matching regex https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions
|
|
9
17
|
- Improve error message for when local development proxy can't determine the port
|
|
10
18
|
- Update local proxy double slash routing behaviour to match the production proxy
|
package/README.md
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<source srcset="https://assets.vercel.com/image/upload/v1689795055/docs-assets/static/docs/microfrontends/mfe-package-banner-dark.png" media="(prefers-color-scheme: dark)">
|
|
3
|
-
<source srcset="https://assets.vercel.com/image/upload/v1689795055/docs-assets/static/docs/microfrontends/mfe-package-banner-light.png" media="(prefers-color-scheme: light)">
|
|
4
|
-
<img src="https://assets.vercel.com/image/upload/v1689795055/docs-assets/static/docs/microfrontends/mfe-package-banner-dark.png" alt="hero banner">
|
|
5
|
-
</picture>
|
|
1
|
+

|
|
6
2
|
|
|
7
3
|
# @vercel/microfrontends
|
|
8
4
|
|
package/dist/bin/cli.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var import_env = require("@next/env");
|
|
|
30
30
|
// package.json
|
|
31
31
|
var package_default = {
|
|
32
32
|
name: "@vercel/microfrontends",
|
|
33
|
-
version: "2.0
|
|
33
|
+
version: "2.1.0",
|
|
34
34
|
private: false,
|
|
35
35
|
description: "Defines configuration and utilities for microfrontends development",
|
|
36
36
|
keywords: [
|
|
@@ -1112,22 +1112,38 @@ var import_node_fs2 = require("fs");
|
|
|
1112
1112
|
var import_jsonc_parser2 = require("jsonc-parser");
|
|
1113
1113
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
1114
1114
|
|
|
1115
|
-
// src/config/
|
|
1116
|
-
var
|
|
1115
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
1116
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
1117
1117
|
"microfrontends.jsonc",
|
|
1118
1118
|
"microfrontends.json"
|
|
1119
1119
|
];
|
|
1120
|
+
function getPossibleConfigurationFilenames({
|
|
1121
|
+
customConfigFilename
|
|
1122
|
+
}) {
|
|
1123
|
+
if (customConfigFilename) {
|
|
1124
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
1125
|
+
throw new Error(
|
|
1126
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
return Array.from(
|
|
1130
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
1134
|
+
}
|
|
1120
1135
|
|
|
1121
1136
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
1122
1137
|
var configCache = {};
|
|
1123
1138
|
function findPackageWithMicrofrontendsConfig({
|
|
1124
1139
|
repositoryRoot,
|
|
1125
|
-
applicationContext
|
|
1140
|
+
applicationContext,
|
|
1141
|
+
customConfigFilename
|
|
1126
1142
|
}) {
|
|
1127
1143
|
const applicationName = applicationContext.name;
|
|
1128
1144
|
try {
|
|
1129
1145
|
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
1130
|
-
`**/{${
|
|
1146
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
1131
1147
|
{
|
|
1132
1148
|
cwd: repositoryRoot,
|
|
1133
1149
|
absolute: true,
|
|
@@ -1183,6 +1199,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
1183
1199
|
|
|
1184
1200
|
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.
|
|
1185
1201
|
|
|
1202
|
+
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.
|
|
1203
|
+
|
|
1186
1204
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
1187
1205
|
{ type: "config", subtype: "inference_failed" }
|
|
1188
1206
|
);
|
|
@@ -1197,7 +1215,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
1197
1215
|
}
|
|
1198
1216
|
}
|
|
1199
1217
|
function inferMicrofrontendsLocation(opts) {
|
|
1200
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
1218
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
1201
1219
|
if (configCache[cacheKey]) {
|
|
1202
1220
|
return configCache[cacheKey];
|
|
1203
1221
|
}
|
|
@@ -1263,8 +1281,13 @@ function findPackageRoot(startDir) {
|
|
|
1263
1281
|
// src/config/microfrontends/utils/find-config.ts
|
|
1264
1282
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
1265
1283
|
var import_node_path5 = require("path");
|
|
1266
|
-
function findConfig({
|
|
1267
|
-
|
|
1284
|
+
function findConfig({
|
|
1285
|
+
dir,
|
|
1286
|
+
customConfigFilename
|
|
1287
|
+
}) {
|
|
1288
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
1289
|
+
customConfigFilename
|
|
1290
|
+
})) {
|
|
1268
1291
|
const maybeConfig = (0, import_node_path5.join)(dir, filename);
|
|
1269
1292
|
if (import_node_fs5.default.existsSync(maybeConfig)) {
|
|
1270
1293
|
return maybeConfig;
|
|
@@ -1696,7 +1719,11 @@ var MicrofrontendsServer = class {
|
|
|
1696
1719
|
appName,
|
|
1697
1720
|
packageRoot
|
|
1698
1721
|
});
|
|
1699
|
-
const
|
|
1722
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1723
|
+
const maybeConfig = findConfig({
|
|
1724
|
+
dir: packageRoot,
|
|
1725
|
+
customConfigFilename
|
|
1726
|
+
});
|
|
1700
1727
|
if (maybeConfig) {
|
|
1701
1728
|
return MicrofrontendsServer.fromFile({
|
|
1702
1729
|
filePath: maybeConfig,
|
|
@@ -1705,11 +1732,9 @@ var MicrofrontendsServer = class {
|
|
|
1705
1732
|
}
|
|
1706
1733
|
const repositoryRoot = findRepositoryRoot();
|
|
1707
1734
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1712
|
-
);
|
|
1735
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1736
|
+
if (typeof configFromEnv === "string") {
|
|
1737
|
+
const maybeConfigFromEnv = (0, import_node_path8.resolve)(packageRoot, configFromEnv);
|
|
1713
1738
|
if (maybeConfigFromEnv) {
|
|
1714
1739
|
return MicrofrontendsServer.fromFile({
|
|
1715
1740
|
filePath: maybeConfigFromEnv,
|
|
@@ -1718,7 +1743,8 @@ var MicrofrontendsServer = class {
|
|
|
1718
1743
|
}
|
|
1719
1744
|
} else {
|
|
1720
1745
|
const maybeConfigFromVercel = findConfig({
|
|
1721
|
-
dir: (0, import_node_path8.join)(packageRoot, ".vercel")
|
|
1746
|
+
dir: (0, import_node_path8.join)(packageRoot, ".vercel"),
|
|
1747
|
+
customConfigFilename
|
|
1722
1748
|
});
|
|
1723
1749
|
if (maybeConfigFromVercel) {
|
|
1724
1750
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1729,9 +1755,13 @@ var MicrofrontendsServer = class {
|
|
|
1729
1755
|
if (isMonorepo2) {
|
|
1730
1756
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1731
1757
|
repositoryRoot,
|
|
1732
|
-
applicationContext
|
|
1758
|
+
applicationContext,
|
|
1759
|
+
customConfigFilename
|
|
1760
|
+
});
|
|
1761
|
+
const maybeConfigFromDefault = findConfig({
|
|
1762
|
+
dir: defaultPackage,
|
|
1763
|
+
customConfigFilename
|
|
1733
1764
|
});
|
|
1734
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1735
1765
|
if (maybeConfigFromDefault) {
|
|
1736
1766
|
return MicrofrontendsServer.fromFile({
|
|
1737
1767
|
filePath: maybeConfigFromDefault,
|
|
@@ -232,22 +232,38 @@ var import_node_fs2 = require("fs");
|
|
|
232
232
|
var import_jsonc_parser = require("jsonc-parser");
|
|
233
233
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
234
234
|
|
|
235
|
-
// src/config/
|
|
236
|
-
var
|
|
235
|
+
// src/config/microfrontends/utils/get-config-file-name.ts
|
|
236
|
+
var DEFAULT_CONFIGURATION_FILENAMES = [
|
|
237
237
|
"microfrontends.jsonc",
|
|
238
238
|
"microfrontends.json"
|
|
239
239
|
];
|
|
240
|
+
function getPossibleConfigurationFilenames({
|
|
241
|
+
customConfigFilename
|
|
242
|
+
}) {
|
|
243
|
+
if (customConfigFilename) {
|
|
244
|
+
if (!customConfigFilename.endsWith(".json") && !customConfigFilename.endsWith(".jsonc")) {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`The VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable must end with '.json' or '.jsonc'. Received: ${customConfigFilename}`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return Array.from(
|
|
250
|
+
/* @__PURE__ */ new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES])
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return DEFAULT_CONFIGURATION_FILENAMES;
|
|
254
|
+
}
|
|
240
255
|
|
|
241
256
|
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
242
257
|
var configCache = {};
|
|
243
258
|
function findPackageWithMicrofrontendsConfig({
|
|
244
259
|
repositoryRoot,
|
|
245
|
-
applicationContext
|
|
260
|
+
applicationContext,
|
|
261
|
+
customConfigFilename
|
|
246
262
|
}) {
|
|
247
263
|
const applicationName = applicationContext.name;
|
|
248
264
|
try {
|
|
249
265
|
const microfrontendsJsonPaths = import_fast_glob.default.globSync(
|
|
250
|
-
`**/{${
|
|
266
|
+
`**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(",")}}`,
|
|
251
267
|
{
|
|
252
268
|
cwd: repositoryRoot,
|
|
253
269
|
absolute: true,
|
|
@@ -303,6 +319,8 @@ Names of applications in \`microfrontends.json\` must match the Vercel Project n
|
|
|
303
319
|
|
|
304
320
|
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.
|
|
305
321
|
|
|
322
|
+
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.
|
|
323
|
+
|
|
306
324
|
If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
307
325
|
{ type: "config", subtype: "inference_failed" }
|
|
308
326
|
);
|
|
@@ -317,7 +335,7 @@ If you suspect this is thrown in error, please reach out to the Vercel team.`,
|
|
|
317
335
|
}
|
|
318
336
|
}
|
|
319
337
|
function inferMicrofrontendsLocation(opts) {
|
|
320
|
-
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}`;
|
|
338
|
+
const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ""}`;
|
|
321
339
|
if (configCache[cacheKey]) {
|
|
322
340
|
return configCache[cacheKey];
|
|
323
341
|
}
|
|
@@ -383,8 +401,13 @@ function findPackageRoot(startDir) {
|
|
|
383
401
|
// src/config/microfrontends/utils/find-config.ts
|
|
384
402
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
385
403
|
var import_node_path5 = require("path");
|
|
386
|
-
function findConfig({
|
|
387
|
-
|
|
404
|
+
function findConfig({
|
|
405
|
+
dir,
|
|
406
|
+
customConfigFilename
|
|
407
|
+
}) {
|
|
408
|
+
for (const filename of getPossibleConfigurationFilenames({
|
|
409
|
+
customConfigFilename
|
|
410
|
+
})) {
|
|
388
411
|
const maybeConfig = (0, import_node_path5.join)(dir, filename);
|
|
389
412
|
if (import_node_fs5.default.existsSync(maybeConfig)) {
|
|
390
413
|
return maybeConfig;
|
|
@@ -1487,7 +1510,11 @@ var MicrofrontendsServer = class {
|
|
|
1487
1510
|
appName,
|
|
1488
1511
|
packageRoot
|
|
1489
1512
|
});
|
|
1490
|
-
const
|
|
1513
|
+
const customConfigFilename = process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;
|
|
1514
|
+
const maybeConfig = findConfig({
|
|
1515
|
+
dir: packageRoot,
|
|
1516
|
+
customConfigFilename
|
|
1517
|
+
});
|
|
1491
1518
|
if (maybeConfig) {
|
|
1492
1519
|
return MicrofrontendsServer.fromFile({
|
|
1493
1520
|
filePath: maybeConfig,
|
|
@@ -1496,11 +1523,9 @@ var MicrofrontendsServer = class {
|
|
|
1496
1523
|
}
|
|
1497
1524
|
const repositoryRoot = findRepositoryRoot();
|
|
1498
1525
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1503
|
-
);
|
|
1526
|
+
const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;
|
|
1527
|
+
if (typeof configFromEnv === "string") {
|
|
1528
|
+
const maybeConfigFromEnv = (0, import_node_path8.resolve)(packageRoot, configFromEnv);
|
|
1504
1529
|
if (maybeConfigFromEnv) {
|
|
1505
1530
|
return MicrofrontendsServer.fromFile({
|
|
1506
1531
|
filePath: maybeConfigFromEnv,
|
|
@@ -1509,7 +1534,8 @@ var MicrofrontendsServer = class {
|
|
|
1509
1534
|
}
|
|
1510
1535
|
} else {
|
|
1511
1536
|
const maybeConfigFromVercel = findConfig({
|
|
1512
|
-
dir: (0, import_node_path8.join)(packageRoot, ".vercel")
|
|
1537
|
+
dir: (0, import_node_path8.join)(packageRoot, ".vercel"),
|
|
1538
|
+
customConfigFilename
|
|
1513
1539
|
});
|
|
1514
1540
|
if (maybeConfigFromVercel) {
|
|
1515
1541
|
return MicrofrontendsServer.fromFile({
|
|
@@ -1520,9 +1546,13 @@ var MicrofrontendsServer = class {
|
|
|
1520
1546
|
if (isMonorepo2) {
|
|
1521
1547
|
const defaultPackage = inferMicrofrontendsLocation({
|
|
1522
1548
|
repositoryRoot,
|
|
1523
|
-
applicationContext
|
|
1549
|
+
applicationContext,
|
|
1550
|
+
customConfigFilename
|
|
1551
|
+
});
|
|
1552
|
+
const maybeConfigFromDefault = findConfig({
|
|
1553
|
+
dir: defaultPackage,
|
|
1554
|
+
customConfigFilename
|
|
1524
1555
|
});
|
|
1525
|
-
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1526
1556
|
if (maybeConfigFromDefault) {
|
|
1527
1557
|
return MicrofrontendsServer.fromFile({
|
|
1528
1558
|
filePath: maybeConfigFromDefault,
|