@vercel/microfrontends 0.9.0 → 0.10.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/README.md +7 -7
- package/dist/bin/cli.cjs +1604 -221
- package/dist/config/client.d.ts +1 -1
- package/dist/config/edge.cjs +47 -47
- package/dist/config/edge.cjs.map +1 -1
- package/dist/config/edge.d.ts +6 -6
- package/dist/config/edge.js +46 -46
- package/dist/config/edge.js.map +1 -1
- package/dist/config.cjs +67 -66
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +66 -65
- package/dist/config.js.map +1 -1
- package/dist/{index-eff254d8.d.ts → index-acb44057.d.ts} +12 -23
- package/dist/{micro-frontend-config-42886104.d.ts → microfrontend-config-983a5139.d.ts} +13 -13
- 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 +86 -87
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +3 -3
- package/dist/next/config.js +85 -86
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +60 -62
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +11 -11
- package/dist/next/middleware.js +58 -60
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +80 -79
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +10 -10
- package/dist/next/testing.js +80 -79
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +9 -9
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +2 -2
- package/dist/overrides.js +9 -9
- package/dist/overrides.js.map +1 -1
- package/dist/{schema-83a75e61.d.ts → schema-2922d49e.d.ts} +1 -7
- package/dist/{types-4fd1c7c6.d.ts → types-7b1cd9f7.d.ts} +1 -7
- package/dist/types-c3d15d04.d.ts +15 -0
- package/dist/v2/config.cjs +39 -39
- package/dist/v2/config.cjs.map +1 -1
- package/dist/v2/config.d.ts +3 -2
- package/dist/v2/config.js +38 -38
- package/dist/v2/config.js.map +1 -1
- package/dist/v2/microfrontends/server.cjs +223 -96
- package/dist/v2/microfrontends/server.cjs.map +1 -1
- package/dist/v2/microfrontends/server.d.ts +11 -3
- package/dist/v2/microfrontends/server.js +223 -96
- package/dist/v2/microfrontends/server.js.map +1 -1
- package/dist/v2/microfrontends.cjs +44 -44
- package/dist/v2/microfrontends.cjs.map +1 -1
- package/dist/v2/microfrontends.d.ts +6 -5
- package/dist/v2/microfrontends.js +44 -44
- package/dist/v2/microfrontends.js.map +1 -1
- package/dist/v2/next/client.cjs +1 -1
- package/dist/v2/next/client.cjs.map +1 -1
- package/dist/v2/next/client.js +1 -1
- package/dist/v2/next/client.js.map +1 -1
- package/dist/v2/next/config.cjs +247 -122
- package/dist/v2/next/config.cjs.map +1 -1
- package/dist/v2/next/config.d.ts +4 -4
- package/dist/v2/next/config.js +246 -121
- package/dist/v2/next/config.js.map +1 -1
- package/dist/v2/next/endpoints.cjs +5 -5
- package/dist/v2/next/endpoints.cjs.map +1 -1
- package/dist/v2/next/endpoints.js +5 -5
- package/dist/v2/next/endpoints.js.map +1 -1
- package/dist/v2/next/middleware.cjs +55 -55
- package/dist/v2/next/middleware.cjs.map +1 -1
- package/dist/v2/next/middleware.d.ts +8 -8
- package/dist/v2/next/middleware.js +53 -53
- package/dist/v2/next/middleware.js.map +1 -1
- package/dist/v2/overrides.cjs +75 -0
- package/dist/v2/overrides.cjs.map +1 -0
- package/dist/v2/overrides.d.ts +24 -0
- package/dist/v2/overrides.js +45 -0
- package/dist/v2/overrides.js.map +1 -0
- package/dist/v2/schema.cjs.map +1 -1
- package/dist/v2/schema.d.ts +1 -1
- package/dist/validation.cjs +20 -28
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +2 -8
- package/dist/validation.js +20 -28
- package/dist/validation.js.map +1 -1
- package/package.json +15 -7
- package/schema/schema-v2.json +0 -4
- package/schema/schema.json +0 -4
|
@@ -27,7 +27,7 @@ var import_server = require("next/server");
|
|
|
27
27
|
|
|
28
28
|
// src/config-v2/microfrontends-config/client/index.ts
|
|
29
29
|
var import_path_to_regexp = require("path-to-regexp");
|
|
30
|
-
var
|
|
30
|
+
var MicrofrontendConfigClient = class {
|
|
31
31
|
constructor(config, opts) {
|
|
32
32
|
this.pathCache = {};
|
|
33
33
|
this.serialized = config;
|
|
@@ -41,14 +41,14 @@ var MicroFrontendConfigClient = class {
|
|
|
41
41
|
this.applications = config.applications;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Create a new `
|
|
44
|
+
* Create a new `MicrofrontendConfigClient` from a JSON string.
|
|
45
45
|
* Config must be passed in to remain framework agnostic
|
|
46
46
|
*/
|
|
47
47
|
static fromEnv(config, opts) {
|
|
48
48
|
if (!config) {
|
|
49
|
-
throw new Error("No
|
|
49
|
+
throw new Error("No microfrontends configuration found");
|
|
50
50
|
}
|
|
51
|
-
return new
|
|
51
|
+
return new MicrofrontendConfigClient(
|
|
52
52
|
JSON.parse(config),
|
|
53
53
|
opts
|
|
54
54
|
);
|
|
@@ -93,7 +93,7 @@ var MicroFrontendConfigClient = class {
|
|
|
93
93
|
|
|
94
94
|
// src/config-v2/well-known/endpoints.ts
|
|
95
95
|
async function getWellKnownClientData(clientConfig, flagValues = {}) {
|
|
96
|
-
const config =
|
|
96
|
+
const config = MicrofrontendConfigClient.fromEnv(clientConfig);
|
|
97
97
|
for (const [applicationName, application] of Object.entries(
|
|
98
98
|
config.applications
|
|
99
99
|
)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next-v2/endpoints/index.ts","../../../src/config-v2/microfrontends-config/client/index.ts","../../../src/config-v2/well-known/endpoints.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\nimport { getWellKnownClientData } from '../../config-v2/well-known/endpoints';\nimport type { WellKnownClientData } from '../../config-v2/well-known/types';\n\n/**\n * A Next.js App Router API handler to export the micro-frontends client config\n * data.\n *\n * @example In the `app/.well-known/vercel/micro-frontends/client-config/route.ts` file,\n * add this code:\n * ```\n * export { wellKnownNextjsClientConfigAppRoute as GET } from '@vercel/microfrontends/next/endpoints';\n * ```\n */\nexport async function wellKnownNextjsClientConfigAppRoute(): Promise<NextResponse> {\n return NextResponse.json<WellKnownClientData>(\n await getWellKnownClientData(process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG),\n );\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\ninterface
|
|
1
|
+
{"version":3,"sources":["../../../src/next-v2/endpoints/index.ts","../../../src/config-v2/microfrontends-config/client/index.ts","../../../src/config-v2/well-known/endpoints.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\nimport { getWellKnownClientData } from '../../config-v2/well-known/endpoints';\nimport type { WellKnownClientData } from '../../config-v2/well-known/types';\n\n/**\n * A Next.js App Router API handler to export the micro-frontends client config\n * data.\n *\n * @example In the `app/.well-known/vercel/micro-frontends/client-config/route.ts` file,\n * add this code:\n * ```\n * export { wellKnownNextjsClientConfigAppRoute as GET } from '@vercel/microfrontends/next/endpoints';\n * ```\n */\nexport async function wellKnownNextjsClientConfigAppRoute(): Promise<NextResponse> {\n return NextResponse.json<WellKnownClientData>(\n await getWellKnownClientData(process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG),\n );\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\ninterface MicrofrontendConfigClientOptions {\n removeFlaggedPaths?: boolean;\n}\n\nexport class MicrofrontendConfigClient {\n applications: ClientConfig['applications'];\n pathCache: Record<string, string> = {};\n private readonly serialized: ClientConfig;\n\n constructor(config: ClientConfig, opts?: MicrofrontendConfigClientOptions) {\n this.serialized = config;\n if (opts?.removeFlaggedPaths) {\n for (const app of Object.values(config.applications)) {\n if (app.routing) {\n app.routing = app.routing.filter((match) => !match.flag);\n }\n }\n }\n this.applications = config.applications;\n }\n\n /**\n * Create a new `MicrofrontendConfigClient` from a JSON string.\n * Config must be passed in to remain framework agnostic\n */\n static fromEnv(\n config: string | undefined,\n opts?: MicrofrontendConfigClientOptions,\n ): MicrofrontendConfigClient {\n if (!config) {\n throw new Error('No microfrontends configuration found');\n }\n return new MicrofrontendConfigClient(\n JSON.parse(config) as ClientConfig,\n opts,\n );\n }\n\n isEqual(other: MicrofrontendConfigClient): boolean {\n return (\n JSON.stringify(this.applications) === JSON.stringify(other.applications)\n );\n }\n\n getApplicationNameForPath(path: string): string | null {\n if (!path.startsWith('/')) {\n throw new Error(`Path must start with a /`);\n }\n\n if (this.pathCache[path]) {\n return this.pathCache[path];\n }\n\n const pathname = new URL(path, 'https://example.com').pathname;\n for (const [name, application] of Object.entries(this.applications)) {\n if (application.routing) {\n for (const group of application.routing) {\n for (const childPath of group.paths) {\n const regexp = pathToRegexp(childPath);\n if (regexp.test(pathname)) {\n this.pathCache[path] = name;\n return name;\n }\n }\n }\n }\n }\n const defaultApplication = Object.entries(this.applications).find(\n ([, application]) => application.default,\n );\n if (!defaultApplication) {\n return null;\n }\n\n this.pathCache[path] = defaultApplication[0];\n return defaultApplication[0];\n }\n\n serialize(): ClientConfig {\n return this.serialized;\n }\n}\n","import { MicrofrontendConfigClient } from '../microfrontends-config/client';\nimport type { WellKnownClientData } from './types';\n\n/**\n * Returns data used by the client to ensure that navigations across\n * microfrontend boundaries are routed and prefetched correctly. The client\n * configuration is safe to expose to users.\n *\n * This data should be exposed in a `.well-known/vercel/micro-frontends/client-config`\n * endpoint.\n */\nexport async function getWellKnownClientData(\n clientConfig: string | undefined,\n flagValues: Record<string, () => Promise<boolean>> = {},\n): Promise<WellKnownClientData> {\n const config = MicrofrontendConfigClient.fromEnv(clientConfig);\n for (const [applicationName, application] of Object.entries(\n config.applications,\n )) {\n if (!application.routing) {\n continue;\n }\n const newRoutingMatches = [];\n for (const pathGroup of application.routing) {\n if (pathGroup.flag) {\n const flagName = pathGroup.flag;\n const flagFn = flagValues[flagName];\n if (!flagFn) {\n throw new Error(\n `Flag \"${flagName}\" was specified to control routing for path group \"${pathGroup.group}\" in application ${applicationName} but not found in provided flag values.`,\n );\n }\n // eslint-disable-next-line no-await-in-loop\n const flagEnabled = await flagFn();\n if (flagEnabled) {\n newRoutingMatches.push(pathGroup);\n }\n } else {\n newRoutingMatches.push(pathGroup);\n }\n }\n application.routing = newRoutingMatches;\n }\n\n return {\n config: config.serialize(),\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -3,7 +3,7 @@ import { NextResponse } from "next/server";
|
|
|
3
3
|
|
|
4
4
|
// src/config-v2/microfrontends-config/client/index.ts
|
|
5
5
|
import { pathToRegexp } from "path-to-regexp";
|
|
6
|
-
var
|
|
6
|
+
var MicrofrontendConfigClient = class {
|
|
7
7
|
constructor(config, opts) {
|
|
8
8
|
this.pathCache = {};
|
|
9
9
|
this.serialized = config;
|
|
@@ -17,14 +17,14 @@ var MicroFrontendConfigClient = class {
|
|
|
17
17
|
this.applications = config.applications;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Create a new `
|
|
20
|
+
* Create a new `MicrofrontendConfigClient` from a JSON string.
|
|
21
21
|
* Config must be passed in to remain framework agnostic
|
|
22
22
|
*/
|
|
23
23
|
static fromEnv(config, opts) {
|
|
24
24
|
if (!config) {
|
|
25
|
-
throw new Error("No
|
|
25
|
+
throw new Error("No microfrontends configuration found");
|
|
26
26
|
}
|
|
27
|
-
return new
|
|
27
|
+
return new MicrofrontendConfigClient(
|
|
28
28
|
JSON.parse(config),
|
|
29
29
|
opts
|
|
30
30
|
);
|
|
@@ -69,7 +69,7 @@ var MicroFrontendConfigClient = class {
|
|
|
69
69
|
|
|
70
70
|
// src/config-v2/well-known/endpoints.ts
|
|
71
71
|
async function getWellKnownClientData(clientConfig, flagValues = {}) {
|
|
72
|
-
const config =
|
|
72
|
+
const config = MicrofrontendConfigClient.fromEnv(clientConfig);
|
|
73
73
|
for (const [applicationName, application] of Object.entries(
|
|
74
74
|
config.applications
|
|
75
75
|
)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next-v2/endpoints/index.ts","../../../src/config-v2/microfrontends-config/client/index.ts","../../../src/config-v2/well-known/endpoints.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\nimport { getWellKnownClientData } from '../../config-v2/well-known/endpoints';\nimport type { WellKnownClientData } from '../../config-v2/well-known/types';\n\n/**\n * A Next.js App Router API handler to export the micro-frontends client config\n * data.\n *\n * @example In the `app/.well-known/vercel/micro-frontends/client-config/route.ts` file,\n * add this code:\n * ```\n * export { wellKnownNextjsClientConfigAppRoute as GET } from '@vercel/microfrontends/next/endpoints';\n * ```\n */\nexport async function wellKnownNextjsClientConfigAppRoute(): Promise<NextResponse> {\n return NextResponse.json<WellKnownClientData>(\n await getWellKnownClientData(process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG),\n );\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\ninterface
|
|
1
|
+
{"version":3,"sources":["../../../src/next-v2/endpoints/index.ts","../../../src/config-v2/microfrontends-config/client/index.ts","../../../src/config-v2/well-known/endpoints.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\nimport { getWellKnownClientData } from '../../config-v2/well-known/endpoints';\nimport type { WellKnownClientData } from '../../config-v2/well-known/types';\n\n/**\n * A Next.js App Router API handler to export the micro-frontends client config\n * data.\n *\n * @example In the `app/.well-known/vercel/micro-frontends/client-config/route.ts` file,\n * add this code:\n * ```\n * export { wellKnownNextjsClientConfigAppRoute as GET } from '@vercel/microfrontends/next/endpoints';\n * ```\n */\nexport async function wellKnownNextjsClientConfigAppRoute(): Promise<NextResponse> {\n return NextResponse.json<WellKnownClientData>(\n await getWellKnownClientData(process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG),\n );\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\ninterface MicrofrontendConfigClientOptions {\n removeFlaggedPaths?: boolean;\n}\n\nexport class MicrofrontendConfigClient {\n applications: ClientConfig['applications'];\n pathCache: Record<string, string> = {};\n private readonly serialized: ClientConfig;\n\n constructor(config: ClientConfig, opts?: MicrofrontendConfigClientOptions) {\n this.serialized = config;\n if (opts?.removeFlaggedPaths) {\n for (const app of Object.values(config.applications)) {\n if (app.routing) {\n app.routing = app.routing.filter((match) => !match.flag);\n }\n }\n }\n this.applications = config.applications;\n }\n\n /**\n * Create a new `MicrofrontendConfigClient` from a JSON string.\n * Config must be passed in to remain framework agnostic\n */\n static fromEnv(\n config: string | undefined,\n opts?: MicrofrontendConfigClientOptions,\n ): MicrofrontendConfigClient {\n if (!config) {\n throw new Error('No microfrontends configuration found');\n }\n return new MicrofrontendConfigClient(\n JSON.parse(config) as ClientConfig,\n opts,\n );\n }\n\n isEqual(other: MicrofrontendConfigClient): boolean {\n return (\n JSON.stringify(this.applications) === JSON.stringify(other.applications)\n );\n }\n\n getApplicationNameForPath(path: string): string | null {\n if (!path.startsWith('/')) {\n throw new Error(`Path must start with a /`);\n }\n\n if (this.pathCache[path]) {\n return this.pathCache[path];\n }\n\n const pathname = new URL(path, 'https://example.com').pathname;\n for (const [name, application] of Object.entries(this.applications)) {\n if (application.routing) {\n for (const group of application.routing) {\n for (const childPath of group.paths) {\n const regexp = pathToRegexp(childPath);\n if (regexp.test(pathname)) {\n this.pathCache[path] = name;\n return name;\n }\n }\n }\n }\n }\n const defaultApplication = Object.entries(this.applications).find(\n ([, application]) => application.default,\n );\n if (!defaultApplication) {\n return null;\n }\n\n this.pathCache[path] = defaultApplication[0];\n return defaultApplication[0];\n }\n\n serialize(): ClientConfig {\n return this.serialized;\n }\n}\n","import { MicrofrontendConfigClient } from '../microfrontends-config/client';\nimport type { WellKnownClientData } from './types';\n\n/**\n * Returns data used by the client to ensure that navigations across\n * microfrontend boundaries are routed and prefetched correctly. The client\n * configuration is safe to expose to users.\n *\n * This data should be exposed in a `.well-known/vercel/micro-frontends/client-config`\n * endpoint.\n */\nexport async function getWellKnownClientData(\n clientConfig: string | undefined,\n flagValues: Record<string, () => Promise<boolean>> = {},\n): Promise<WellKnownClientData> {\n const config = MicrofrontendConfigClient.fromEnv(clientConfig);\n for (const [applicationName, application] of Object.entries(\n config.applications,\n )) {\n if (!application.routing) {\n continue;\n }\n const newRoutingMatches = [];\n for (const pathGroup of application.routing) {\n if (pathGroup.flag) {\n const flagName = pathGroup.flag;\n const flagFn = flagValues[flagName];\n if (!flagFn) {\n throw new Error(\n `Flag \"${flagName}\" was specified to control routing for path group \"${pathGroup.group}\" in application ${applicationName} but not found in provided flag values.`,\n );\n }\n // eslint-disable-next-line no-await-in-loop\n const flagEnabled = await flagFn();\n if (flagEnabled) {\n newRoutingMatches.push(pathGroup);\n }\n } else {\n newRoutingMatches.push(pathGroup);\n }\n }\n application.routing = newRoutingMatches;\n }\n\n return {\n config: config.serialize(),\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/next-v2/middleware/index.ts
|
|
21
21
|
var middleware_exports = {};
|
|
22
22
|
__export(middleware_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
getMicrofrontendsMiddleware: () => getMicrofrontendsMiddleware,
|
|
24
|
+
runMicrofrontendsMiddleware: () => runMicrofrontendsMiddleware
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(middleware_exports);
|
|
27
27
|
|
|
@@ -33,14 +33,14 @@ var import_path_to_regexp3 = require("path-to-regexp");
|
|
|
33
33
|
var import_jsonc_parser = require("jsonc-parser");
|
|
34
34
|
|
|
35
35
|
// src/config-v2/errors.ts
|
|
36
|
-
var
|
|
36
|
+
var MicrofrontendError = class extends Error {
|
|
37
37
|
constructor(message, opts) {
|
|
38
38
|
super(message);
|
|
39
|
-
this.name = "
|
|
40
|
-
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/
|
|
39
|
+
this.name = "MicrofrontendsError";
|
|
40
|
+
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
|
|
41
41
|
this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
|
|
42
42
|
this.subtype = opts == null ? void 0 : opts.subtype;
|
|
43
|
-
Error.captureStackTrace(this,
|
|
43
|
+
Error.captureStackTrace(this, MicrofrontendError);
|
|
44
44
|
}
|
|
45
45
|
isKnown() {
|
|
46
46
|
return this.type !== "unknown";
|
|
@@ -49,13 +49,13 @@ var MicroFrontendError = class extends Error {
|
|
|
49
49
|
return !this.isKnown();
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* Converts an error to a
|
|
52
|
+
* Converts an error to a MicrofrontendsError.
|
|
53
53
|
* @param original - The original error to convert.
|
|
54
|
-
* @returns The converted
|
|
54
|
+
* @returns The converted MicrofrontendsError.
|
|
55
55
|
*/
|
|
56
56
|
static convert(original, opts) {
|
|
57
57
|
if (opts == null ? void 0 : opts.fileName) {
|
|
58
|
-
const err =
|
|
58
|
+
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
59
59
|
if (err) {
|
|
60
60
|
return err;
|
|
61
61
|
}
|
|
@@ -63,25 +63,25 @@ var MicroFrontendError = class extends Error {
|
|
|
63
63
|
if (original.message.includes(
|
|
64
64
|
"Code generation from strings disallowed for this context"
|
|
65
65
|
)) {
|
|
66
|
-
return new
|
|
66
|
+
return new MicrofrontendError(original.message, {
|
|
67
67
|
type: "config",
|
|
68
68
|
subtype: "unsupported_validation_env",
|
|
69
69
|
source: "ajv"
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
return new
|
|
72
|
+
return new MicrofrontendError(original.message);
|
|
73
73
|
}
|
|
74
74
|
static convertFSError(original, fileName) {
|
|
75
75
|
if (original instanceof Error && "code" in original) {
|
|
76
76
|
if (original.code === "ENOENT") {
|
|
77
|
-
return new
|
|
77
|
+
return new MicrofrontendError(`Could not find "${fileName}"`, {
|
|
78
78
|
type: "config",
|
|
79
79
|
subtype: "unable_to_read_file",
|
|
80
80
|
source: "fs"
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
if (original.code === "EACCES") {
|
|
84
|
-
return new
|
|
84
|
+
return new MicrofrontendError(
|
|
85
85
|
`Permission denied while accessing "${fileName}"`,
|
|
86
86
|
{
|
|
87
87
|
type: "config",
|
|
@@ -92,7 +92,7 @@ var MicroFrontendError = class extends Error {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
if (original instanceof SyntaxError) {
|
|
95
|
-
return new
|
|
95
|
+
return new MicrofrontendError(
|
|
96
96
|
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
97
97
|
{
|
|
98
98
|
type: "config",
|
|
@@ -104,23 +104,23 @@ var MicroFrontendError = class extends Error {
|
|
|
104
104
|
return null;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* Handles an unknown error and returns a
|
|
107
|
+
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
108
108
|
* @param err - The error to handle.
|
|
109
|
-
* @returns A
|
|
109
|
+
* @returns A MicrofrontendsError instance.
|
|
110
110
|
*/
|
|
111
111
|
static handle(err, opts) {
|
|
112
|
-
if (err instanceof
|
|
112
|
+
if (err instanceof MicrofrontendError) {
|
|
113
113
|
return err;
|
|
114
114
|
}
|
|
115
115
|
if (err instanceof Error) {
|
|
116
|
-
return
|
|
116
|
+
return MicrofrontendError.convert(err, opts);
|
|
117
117
|
}
|
|
118
118
|
if (typeof err === "object" && err !== null) {
|
|
119
119
|
if ("message" in err && typeof err.message === "string") {
|
|
120
|
-
return
|
|
120
|
+
return MicrofrontendError.convert(new Error(err.message), opts);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
return new
|
|
123
|
+
return new MicrofrontendError("An unknown error occurred");
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
|
|
@@ -128,7 +128,7 @@ var MicroFrontendError = class extends Error {
|
|
|
128
128
|
function getConfigStringFromEnv() {
|
|
129
129
|
const config = process.env.MFE_CONFIG;
|
|
130
130
|
if (!config) {
|
|
131
|
-
throw new
|
|
131
|
+
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
132
132
|
type: "config",
|
|
133
133
|
subtype: "not_found_in_env"
|
|
134
134
|
});
|
|
@@ -148,7 +148,7 @@ function isDefaultApp(a) {
|
|
|
148
148
|
|
|
149
149
|
// src/config-v2/microfrontends-config/client/index.ts
|
|
150
150
|
var import_path_to_regexp = require("path-to-regexp");
|
|
151
|
-
var
|
|
151
|
+
var MicrofrontendConfigClient = class {
|
|
152
152
|
constructor(config, opts) {
|
|
153
153
|
this.pathCache = {};
|
|
154
154
|
this.serialized = config;
|
|
@@ -162,14 +162,14 @@ var MicroFrontendConfigClient = class {
|
|
|
162
162
|
this.applications = config.applications;
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
|
-
* Create a new `
|
|
165
|
+
* Create a new `MicrofrontendConfigClient` from a JSON string.
|
|
166
166
|
* Config must be passed in to remain framework agnostic
|
|
167
167
|
*/
|
|
168
168
|
static fromEnv(config, opts) {
|
|
169
169
|
if (!config) {
|
|
170
|
-
throw new Error("No
|
|
170
|
+
throw new Error("No microfrontends configuration found");
|
|
171
171
|
}
|
|
172
|
-
return new
|
|
172
|
+
return new MicrofrontendConfigClient(
|
|
173
173
|
JSON.parse(config),
|
|
174
174
|
opts
|
|
175
175
|
);
|
|
@@ -251,7 +251,7 @@ var import_path_to_regexp2 = require("path-to-regexp");
|
|
|
251
251
|
var SUPPORTED_VERSIONS = ["2"];
|
|
252
252
|
var validateConfigVersion = (version) => {
|
|
253
253
|
if (!SUPPORTED_VERSIONS.includes(version)) {
|
|
254
|
-
throw new
|
|
254
|
+
throw new MicrofrontendError(
|
|
255
255
|
`Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
|
|
256
256
|
", "
|
|
257
257
|
)}`,
|
|
@@ -321,7 +321,7 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
321
321
|
);
|
|
322
322
|
});
|
|
323
323
|
if (errors.length) {
|
|
324
|
-
throw new
|
|
324
|
+
throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
|
|
325
325
|
type: "config",
|
|
326
326
|
subtype: "conflicting_paths"
|
|
327
327
|
});
|
|
@@ -334,13 +334,13 @@ var validateAppPaths = (name, app) => {
|
|
|
334
334
|
continue;
|
|
335
335
|
}
|
|
336
336
|
if (p.endsWith("/")) {
|
|
337
|
-
throw new
|
|
337
|
+
throw new MicrofrontendError(
|
|
338
338
|
`Invalid path for application "${name}". ${p} must not end with a slash.`,
|
|
339
339
|
{ type: "application", subtype: "invalid_path" }
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
if (!p.startsWith("/")) {
|
|
343
|
-
throw new
|
|
343
|
+
throw new MicrofrontendError(
|
|
344
344
|
`Invalid path for application "${name}". ${p} must start with a slash.`,
|
|
345
345
|
{ type: "application", subtype: "invalid_path" }
|
|
346
346
|
);
|
|
@@ -362,13 +362,13 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
362
362
|
const numApplicationsWithRouting = applicationsWithRoutingNames.length;
|
|
363
363
|
const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
|
|
364
364
|
if (numApplicationsWithoutRouting === 0) {
|
|
365
|
-
throw new
|
|
365
|
+
throw new MicrofrontendError(
|
|
366
366
|
`No default application found. At least one application needs to be the default by omitting routing.`,
|
|
367
367
|
{ type: "config", subtype: "no_default_application" }
|
|
368
368
|
);
|
|
369
369
|
}
|
|
370
370
|
if (numApplicationsWithoutRouting > 1) {
|
|
371
|
-
throw new
|
|
371
|
+
throw new MicrofrontendError(
|
|
372
372
|
`Only one application can omit "routing". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,
|
|
373
373
|
{ type: "config", subtype: "multiple_default_applications" }
|
|
374
374
|
);
|
|
@@ -380,7 +380,7 @@ var validateConfigOptions = (options) => {
|
|
|
380
380
|
if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
|
|
381
381
|
options.vercel.previewDeploymentSuffix
|
|
382
382
|
)) {
|
|
383
|
-
throw new
|
|
383
|
+
throw new MicrofrontendError(
|
|
384
384
|
`Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
|
|
385
385
|
{ type: "config", subtype: "invalid_preview_deployment_suffix" }
|
|
386
386
|
);
|
|
@@ -539,7 +539,7 @@ var ChildApplication = class extends Application {
|
|
|
539
539
|
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
540
540
|
|
|
541
541
|
// src/config-v2/microfrontends-config/isomorphic/index.ts
|
|
542
|
-
var
|
|
542
|
+
var MicrofrontendConfigIsomorphic = class {
|
|
543
543
|
constructor({
|
|
544
544
|
config,
|
|
545
545
|
overrides,
|
|
@@ -547,7 +547,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
547
547
|
}) {
|
|
548
548
|
this.childApplications = {};
|
|
549
549
|
var _a, _b, _c, _d;
|
|
550
|
-
|
|
550
|
+
MicrofrontendConfigIsomorphic.validate(config);
|
|
551
551
|
const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
|
|
552
552
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
553
553
|
this.isMainConfig = isMainConfig(config);
|
|
@@ -579,7 +579,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
579
579
|
);
|
|
580
580
|
}
|
|
581
581
|
if (isMainConfig(config) && !this.defaultApplication) {
|
|
582
|
-
throw new
|
|
582
|
+
throw new MicrofrontendError(
|
|
583
583
|
`Could not find default application in microfrontends configuration`,
|
|
584
584
|
{
|
|
585
585
|
type: "application",
|
|
@@ -609,7 +609,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
609
609
|
meta,
|
|
610
610
|
cookies
|
|
611
611
|
}) {
|
|
612
|
-
return new
|
|
612
|
+
return new MicrofrontendConfigIsomorphic({
|
|
613
613
|
config: (0, import_jsonc_parser.parse)(getConfigStringFromEnv()),
|
|
614
614
|
overrides: parseOverrides(cookies ?? []),
|
|
615
615
|
meta
|
|
@@ -644,7 +644,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
644
644
|
}
|
|
645
645
|
const app = this.childApplications[name];
|
|
646
646
|
if (!app) {
|
|
647
|
-
throw new
|
|
647
|
+
throw new MicrofrontendError(
|
|
648
648
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
649
649
|
{
|
|
650
650
|
type: "application",
|
|
@@ -672,7 +672,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
672
672
|
*/
|
|
673
673
|
getDefaultApplication() {
|
|
674
674
|
if (!this.defaultApplication) {
|
|
675
|
-
throw new
|
|
675
|
+
throw new MicrofrontendError(
|
|
676
676
|
`Could not find default application in microfrontends configuration`,
|
|
677
677
|
{
|
|
678
678
|
type: "application",
|
|
@@ -712,7 +712,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
712
712
|
default: true
|
|
713
713
|
};
|
|
714
714
|
}
|
|
715
|
-
return new
|
|
715
|
+
return new MicrofrontendConfigClient({
|
|
716
716
|
applications
|
|
717
717
|
});
|
|
718
718
|
}
|
|
@@ -722,7 +722,7 @@ var MicroFrontendConfigIsomorphic = class {
|
|
|
722
722
|
};
|
|
723
723
|
|
|
724
724
|
// src/config-v2/microfrontends-config/isomorphic/child.ts
|
|
725
|
-
var
|
|
725
|
+
var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
|
|
726
726
|
constructor({
|
|
727
727
|
config,
|
|
728
728
|
overrides,
|
|
@@ -735,7 +735,7 @@ var MicroFrontendChildConfig = class extends MicroFrontendConfigIsomorphic {
|
|
|
735
735
|
};
|
|
736
736
|
|
|
737
737
|
// src/config-v2/microfrontends-config/isomorphic/main.ts
|
|
738
|
-
var
|
|
738
|
+
var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
|
|
739
739
|
constructor({
|
|
740
740
|
config,
|
|
741
741
|
overrides,
|
|
@@ -762,7 +762,7 @@ var MicroFrontendMainConfig = class extends MicroFrontendConfigIsomorphic {
|
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
if (!defaultApplication) {
|
|
765
|
-
throw new
|
|
765
|
+
throw new MicrofrontendError(
|
|
766
766
|
`Could not find default application in microfrontends configuration`,
|
|
767
767
|
{
|
|
768
768
|
type: "application",
|
|
@@ -782,19 +782,19 @@ var Microfrontends = class {
|
|
|
782
782
|
meta
|
|
783
783
|
}) {
|
|
784
784
|
if (isMainConfig(config)) {
|
|
785
|
-
this.config = new
|
|
785
|
+
this.config = new MicrofrontendMainConfig({ config, overrides, meta });
|
|
786
786
|
} else {
|
|
787
|
-
this.config = new
|
|
787
|
+
this.config = new MicrofrontendChildConfig({ config, overrides, meta });
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
790
|
isChildConfig() {
|
|
791
|
-
return this.config instanceof
|
|
791
|
+
return this.config instanceof MicrofrontendChildConfig;
|
|
792
792
|
}
|
|
793
793
|
static fromEnv({
|
|
794
794
|
cookies,
|
|
795
795
|
meta
|
|
796
796
|
}) {
|
|
797
|
-
const config =
|
|
797
|
+
const config = MicrofrontendConfigIsomorphic.fromEnv({
|
|
798
798
|
cookies,
|
|
799
799
|
meta
|
|
800
800
|
});
|
|
@@ -901,7 +901,7 @@ async function verifyPreviewDomain(req, rewriteDomain) {
|
|
|
901
901
|
const vercelError = previewResponse.headers.get("x-vercel-error");
|
|
902
902
|
return !(previewResponse.status === 404 && (vercelError === "DEPLOYMENT_NOT_FOUND" || vercelError === "NOT_FOUND"));
|
|
903
903
|
}
|
|
904
|
-
function
|
|
904
|
+
function microfrontendInternalRoutingHandler({
|
|
905
905
|
config,
|
|
906
906
|
production
|
|
907
907
|
}) {
|
|
@@ -1021,7 +1021,7 @@ function getHandler({
|
|
|
1021
1021
|
}
|
|
1022
1022
|
};
|
|
1023
1023
|
}
|
|
1024
|
-
function
|
|
1024
|
+
function getMicrofrontendsMiddleware({
|
|
1025
1025
|
request,
|
|
1026
1026
|
flagValues
|
|
1027
1027
|
}) {
|
|
@@ -1032,14 +1032,14 @@ function getMicroFrontendsMiddleware({
|
|
|
1032
1032
|
}
|
|
1033
1033
|
});
|
|
1034
1034
|
const middlewares = [];
|
|
1035
|
-
if (microfrontends.config instanceof
|
|
1035
|
+
if (microfrontends.config instanceof MicrofrontendChildConfig) {
|
|
1036
1036
|
return middlewares;
|
|
1037
1037
|
}
|
|
1038
1038
|
const config = microfrontends.config;
|
|
1039
1039
|
const production = config.defaultApplication.production;
|
|
1040
1040
|
middlewares.push({
|
|
1041
1041
|
src: "/.well-known/vercel/microfrontend-routing",
|
|
1042
|
-
fn:
|
|
1042
|
+
fn: microfrontendInternalRoutingHandler({ config, production })
|
|
1043
1043
|
});
|
|
1044
1044
|
for (const application of config.getChildApplications()) {
|
|
1045
1045
|
if (application.name === process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION) {
|
|
@@ -1058,7 +1058,7 @@ function getMicroFrontendsMiddleware({
|
|
|
1058
1058
|
});
|
|
1059
1059
|
}
|
|
1060
1060
|
for (const pathGroup of application.routing) {
|
|
1061
|
-
if (process.env.VERCEL_ENV === "preview" || pathGroup.flag
|
|
1061
|
+
if (process.env.VERCEL_ENV === "preview" || pathGroup.flag) {
|
|
1062
1062
|
const flagName = pathGroup.flag;
|
|
1063
1063
|
let flagFn;
|
|
1064
1064
|
if (flagName) {
|
|
@@ -1087,9 +1087,9 @@ function getMicroFrontendsMiddleware({
|
|
|
1087
1087
|
}
|
|
1088
1088
|
return middlewares;
|
|
1089
1089
|
}
|
|
1090
|
-
async function
|
|
1090
|
+
async function runMicrofrontendsMiddleware(request, flagValues) {
|
|
1091
1091
|
const pathname = request.nextUrl.pathname;
|
|
1092
|
-
const middlewares =
|
|
1092
|
+
const middlewares = getMicrofrontendsMiddleware({
|
|
1093
1093
|
request,
|
|
1094
1094
|
flagValues
|
|
1095
1095
|
});
|
|
@@ -1104,7 +1104,7 @@ async function runMicroFrontendsMiddleware(request, flagValues) {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1106
1106
|
0 && (module.exports = {
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
getMicrofrontendsMiddleware,
|
|
1108
|
+
runMicrofrontendsMiddleware
|
|
1109
1109
|
});
|
|
1110
1110
|
//# sourceMappingURL=middleware.cjs.map
|