@vercel/microfrontends 1.4.0-canary.3 → 1.4.0-canary.5
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 +6 -0
- package/dist/bin/cli.cjs +43 -11
- package/dist/config.cjs +12 -2
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +12 -2
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +42 -10
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +43 -11
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +42 -10
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +46 -14
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +42 -10
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.js +43 -11
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +42 -10
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +43 -11
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +12 -2
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +12 -2
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +12 -2
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.js +12 -2
- package/dist/next/testing.js.map +1 -1
- package/dist/utils/mfe-port.cjs +42 -10
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +43 -11
- package/dist/utils/mfe-port.js.map +1 -1
- package/package.json +1 -1
package/dist/next/config.js
CHANGED
|
@@ -17,7 +17,7 @@ function displayLocalProxyInfo(port) {
|
|
|
17
17
|
|
|
18
18
|
// src/config/microfrontends/server/index.ts
|
|
19
19
|
import fs6 from "node:fs";
|
|
20
|
-
import { dirname as dirname2 } from "node:path";
|
|
20
|
+
import { dirname as dirname2, join as join2, resolve } from "node:path";
|
|
21
21
|
|
|
22
22
|
// src/config/overrides/constants.ts
|
|
23
23
|
var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
|
|
@@ -340,6 +340,16 @@ import { parse as parse2 } from "jsonc-parser";
|
|
|
340
340
|
|
|
341
341
|
// src/config/microfrontends-config/client/index.ts
|
|
342
342
|
import { pathToRegexp } from "path-to-regexp";
|
|
343
|
+
var regexpCache = /* @__PURE__ */ new Map();
|
|
344
|
+
var getRegexp = (path6) => {
|
|
345
|
+
const existing = regexpCache.get(path6);
|
|
346
|
+
if (existing) {
|
|
347
|
+
return existing;
|
|
348
|
+
}
|
|
349
|
+
const regexp = pathToRegexp(path6);
|
|
350
|
+
regexpCache.set(path6, regexp);
|
|
351
|
+
return regexp;
|
|
352
|
+
};
|
|
343
353
|
var MicrofrontendConfigClient = class {
|
|
344
354
|
constructor(config, opts) {
|
|
345
355
|
this.pathCache = {};
|
|
@@ -369,7 +379,7 @@ var MicrofrontendConfigClient = class {
|
|
|
369
379
|
);
|
|
370
380
|
}
|
|
371
381
|
isEqual(other) {
|
|
372
|
-
return JSON.stringify(this.applications) === JSON.stringify(other.applications);
|
|
382
|
+
return this === other || JSON.stringify(this.applications) === JSON.stringify(other.applications);
|
|
373
383
|
}
|
|
374
384
|
getApplicationNameForPath(path6) {
|
|
375
385
|
if (!path6.startsWith("/")) {
|
|
@@ -383,7 +393,7 @@ var MicrofrontendConfigClient = class {
|
|
|
383
393
|
if (application.routing) {
|
|
384
394
|
for (const group of application.routing) {
|
|
385
395
|
for (const childPath of group.paths) {
|
|
386
|
-
const regexp =
|
|
396
|
+
const regexp = getRegexp(childPath);
|
|
387
397
|
if (regexp.test(pathname)) {
|
|
388
398
|
this.pathCache[path6] = name;
|
|
389
399
|
return name;
|
|
@@ -1385,21 +1395,43 @@ var MicrofrontendsServer = class {
|
|
|
1385
1395
|
}
|
|
1386
1396
|
const repositoryRoot = findRepositoryRoot();
|
|
1387
1397
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1388
|
-
if (
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1398
|
+
if (typeof process.env.VC_MICROFRONTENDS_CONFIG === "string") {
|
|
1399
|
+
const maybeConfigFromEnv = resolve(
|
|
1400
|
+
packageRoot,
|
|
1401
|
+
process.env.VC_MICROFRONTENDS_CONFIG
|
|
1402
|
+
);
|
|
1403
|
+
if (maybeConfigFromEnv) {
|
|
1404
|
+
return MicrofrontendsServer.fromFile({
|
|
1405
|
+
filePath: maybeConfigFromEnv,
|
|
1406
|
+
cookies
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
} else {
|
|
1410
|
+
const maybeConfigFromVercel = findConfig({
|
|
1411
|
+
dir: join2(packageRoot, ".vercel")
|
|
1392
1412
|
});
|
|
1393
|
-
|
|
1394
|
-
if (maybeConfigFromDefault) {
|
|
1413
|
+
if (maybeConfigFromVercel) {
|
|
1395
1414
|
return MicrofrontendsServer.fromFile({
|
|
1396
|
-
filePath:
|
|
1415
|
+
filePath: maybeConfigFromVercel,
|
|
1397
1416
|
cookies
|
|
1398
1417
|
});
|
|
1399
1418
|
}
|
|
1419
|
+
if (isMonorepo2) {
|
|
1420
|
+
const defaultPackage = inferMicrofrontendsLocation({
|
|
1421
|
+
repositoryRoot,
|
|
1422
|
+
applicationName: appName
|
|
1423
|
+
});
|
|
1424
|
+
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
1425
|
+
if (maybeConfigFromDefault) {
|
|
1426
|
+
return MicrofrontendsServer.fromFile({
|
|
1427
|
+
filePath: maybeConfigFromDefault,
|
|
1428
|
+
cookies
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1400
1432
|
}
|
|
1401
1433
|
throw new MicrofrontendError(
|
|
1402
|
-
|
|
1434
|
+
'Unable to automatically infer the location of the `microfrontends.json` file. 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. If you suspect this is thrown in error, please reach out to the Vercel team.',
|
|
1403
1435
|
{ type: "config", subtype: "inference_failed" }
|
|
1404
1436
|
);
|
|
1405
1437
|
} catch (e) {
|