@vercel/microfrontends 1.1.1-canary.6 → 1.2.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/dist/bin/cli.cjs +405 -204
- package/dist/config.cjs +25 -68
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +5 -5
- package/dist/config.js +25 -68
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +64 -193
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +64 -193
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +64 -193
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +64 -193
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +64 -193
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +3 -3
- package/dist/microfrontends/server.js +64 -193
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/next/config.cjs +69 -358
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +69 -358
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/middleware.cjs +25 -68
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +25 -68
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +123 -144
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +36 -5
- package/dist/next/testing.js +122 -143
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.d.ts +2 -2
- package/dist/{types-f1260e44.d.ts → types-b970b583.d.ts} +1 -1
- package/dist/{types-a4add5ab.d.ts → types-bee19651.d.ts} +11 -2
- package/dist/{types-54064641.d.ts → types-c9f15465.d.ts} +31 -85
- package/dist/utils/mfe-port.cjs +64 -193
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +64 -193
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +39 -125
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +39 -125
- package/dist/validation.js.map +1 -1
- package/package.json +2 -8
- package/schema/schema.json +45 -131
- package/dist/routing.cjs +0 -19
- package/dist/routing.cjs.map +0 -1
- package/dist/routing.d.ts +0 -26
- package/dist/routing.js +0 -1
- package/dist/routing.js.map +0 -1
package/dist/next/endpoints.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextApiResponse } from 'next';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
|
-
import { C as ClientConfig } from '../types-
|
|
4
|
-
import '../types-
|
|
3
|
+
import { C as ClientConfig } from '../types-b970b583.js';
|
|
4
|
+
import '../types-c9f15465.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Data that is returned from the `.well-known/vercel/microfrontends/client-config`
|
package/dist/next/middleware.cjs
CHANGED
|
@@ -262,8 +262,7 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
262
262
|
if (isDefaultApp(app)) {
|
|
263
263
|
continue;
|
|
264
264
|
}
|
|
265
|
-
const
|
|
266
|
-
for (const pathMatch of childApp.routing) {
|
|
265
|
+
for (const pathMatch of app.routing) {
|
|
267
266
|
for (const path of pathMatch.paths) {
|
|
268
267
|
const maybeError = validatePathExpression(path);
|
|
269
268
|
if (maybeError) {
|
|
@@ -411,64 +410,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
411
410
|
};
|
|
412
411
|
var validateDeprecatedFields = (config) => {
|
|
413
412
|
const errors = [];
|
|
414
|
-
if (config.options?.vercel) {
|
|
415
|
-
errors.push(
|
|
416
|
-
`Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
if (config.options?.localProxy) {
|
|
420
|
-
errors.push(
|
|
421
|
-
`Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
413
|
for (const [applicationId, application] of Object.entries(
|
|
425
414
|
config.applications
|
|
426
415
|
)) {
|
|
427
|
-
if (application.vercel) {
|
|
428
|
-
errors.push(
|
|
429
|
-
`Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
if (application.production) {
|
|
433
|
-
errors.push(
|
|
434
|
-
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
416
|
if (application.development?.localPort) {
|
|
438
417
|
errors.push(
|
|
439
418
|
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
440
419
|
);
|
|
441
420
|
}
|
|
442
|
-
if (application.
|
|
443
|
-
const fallback = application.development.fallback;
|
|
444
|
-
let asString = fallback.host;
|
|
445
|
-
if (fallback.protocol) {
|
|
446
|
-
asString = `${fallback.protocol}://${asString}`;
|
|
447
|
-
}
|
|
448
|
-
if (fallback.port) {
|
|
449
|
-
asString = `${asString}:${fallback.port}`;
|
|
450
|
-
}
|
|
451
|
-
errors.push(
|
|
452
|
-
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
456
|
-
const local = application.development.local;
|
|
457
|
-
let asString;
|
|
458
|
-
if (local.port && !local.protocol && !local.host) {
|
|
459
|
-
asString = String(local.port);
|
|
460
|
-
} else {
|
|
461
|
-
asString = local.host ?? "localhost";
|
|
462
|
-
if (local.protocol) {
|
|
463
|
-
asString = `${local.protocol}://${asString}`;
|
|
464
|
-
}
|
|
465
|
-
if (local.port) {
|
|
466
|
-
asString = `${asString}:${local.port}`;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
errors.push(
|
|
470
|
-
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
471
|
-
);
|
|
421
|
+
if (application.projectId) {
|
|
472
422
|
}
|
|
473
423
|
}
|
|
474
424
|
if (errors.length) {
|
|
@@ -623,6 +573,13 @@ var LocalHost = class extends Host {
|
|
|
623
573
|
}
|
|
624
574
|
};
|
|
625
575
|
|
|
576
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
|
|
577
|
+
function generateAutomationBypassEnvVarName({
|
|
578
|
+
name
|
|
579
|
+
}) {
|
|
580
|
+
return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
581
|
+
}
|
|
582
|
+
|
|
626
583
|
// src/config/microfrontends-config/isomorphic/application.ts
|
|
627
584
|
var Application = class {
|
|
628
585
|
constructor(name, {
|
|
@@ -641,10 +598,8 @@ var Application = class {
|
|
|
641
598
|
};
|
|
642
599
|
if (app.development?.fallback) {
|
|
643
600
|
this.fallback = new Host(app.development.fallback);
|
|
644
|
-
} else if (app.production) {
|
|
645
|
-
this.fallback = new Host(app.production);
|
|
646
601
|
}
|
|
647
|
-
this.projectId = app.projectId
|
|
602
|
+
this.projectId = app.projectId;
|
|
648
603
|
this.packageName = app.packageName;
|
|
649
604
|
this.overrides = overrides?.environment ? {
|
|
650
605
|
environment: new Host(overrides.environment)
|
|
@@ -658,6 +613,9 @@ var Application = class {
|
|
|
658
613
|
getAssetPrefix() {
|
|
659
614
|
return generateAssetPrefixFromName({ name: this.name });
|
|
660
615
|
}
|
|
616
|
+
getAutomationBypassEnvVarName() {
|
|
617
|
+
return generateAutomationBypassEnvVarName({ name: this.name });
|
|
618
|
+
}
|
|
661
619
|
serialize() {
|
|
662
620
|
return this.serialized;
|
|
663
621
|
}
|
|
@@ -673,16 +631,7 @@ var DefaultApplication = class extends Application {
|
|
|
673
631
|
isDefault: true
|
|
674
632
|
});
|
|
675
633
|
this.default = true;
|
|
676
|
-
|
|
677
|
-
if (fallbackHost === void 0) {
|
|
678
|
-
throw new Error(
|
|
679
|
-
"`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
this.fallback = new Host(fallbackHost);
|
|
683
|
-
if (app.production) {
|
|
684
|
-
this.production = new Host(app.production);
|
|
685
|
-
}
|
|
634
|
+
this.fallback = new Host(app.development.fallback);
|
|
686
635
|
}
|
|
687
636
|
getAssetPrefix() {
|
|
688
637
|
return "";
|
|
@@ -719,7 +668,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
719
668
|
}) {
|
|
720
669
|
this.childApplications = {};
|
|
721
670
|
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
722
|
-
const disableOverrides = config.options?.disableOverrides ??
|
|
671
|
+
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
723
672
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
724
673
|
let defaultApplication;
|
|
725
674
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
@@ -772,7 +721,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
772
721
|
});
|
|
773
722
|
}
|
|
774
723
|
isOverridesDisabled() {
|
|
775
|
-
return this.options?.
|
|
724
|
+
return this.options?.disableOverrides ?? false;
|
|
776
725
|
}
|
|
777
726
|
getConfig() {
|
|
778
727
|
return this.config;
|
|
@@ -810,6 +759,14 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
810
759
|
}
|
|
811
760
|
return app;
|
|
812
761
|
}
|
|
762
|
+
hasApplication(name) {
|
|
763
|
+
try {
|
|
764
|
+
this.getApplication(name);
|
|
765
|
+
return true;
|
|
766
|
+
} catch {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
813
770
|
getApplicationByProjectId(projectId) {
|
|
814
771
|
if (this.defaultApplication.projectId === projectId) {
|
|
815
772
|
return this.defaultApplication;
|
|
@@ -828,7 +785,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
828
785
|
* Returns the configured port for the local proxy
|
|
829
786
|
*/
|
|
830
787
|
getLocalProxyPort() {
|
|
831
|
-
return this.config.options?.localProxyPort ??
|
|
788
|
+
return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
832
789
|
}
|
|
833
790
|
/**
|
|
834
791
|
* Serializes the class back to the Schema type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/middleware/index.ts","../../src/next/middleware/middleware.ts","../../src/next/utils/route-to-local-proxy.ts","../../src/config/microfrontends-config/isomorphic/index.ts","../../src/config/errors.ts","../../src/config/microfrontends-config/utils/get-config-from-env.ts","../../src/config/schema/utils/is-default-app.ts","../../src/config/microfrontends-config/client/index.ts","../../src/config/overrides/constants.ts","../../src/config/overrides/is-override-cookie.ts","../../src/config/overrides/get-override-from-cookie.ts","../../src/config/overrides/parse-overrides.ts","../../src/config/microfrontends-config/isomorphic/validation.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-port.ts","../../src/config/microfrontends-config/isomorphic/host.ts","../../src/config/microfrontends-config/isomorphic/application.ts","../../src/config/microfrontends-config/isomorphic/constants.ts"],"sourcesContent":["export * from './middleware';\nexport * from './types';\n","/// <reference types=\"@edge-runtime/types\" />\n\nimport type { NextRequest } from 'next/server';\nimport { NextResponse } from 'next/server';\nimport { pathToRegexp } from 'path-to-regexp';\nimport type { ChildApplication } from '../../config/microfrontends-config/isomorphic/application';\nimport { routeToLocalProxy } from '../utils/route-to-local-proxy';\nimport { MicrofrontendConfigIsomorphic } from '../../config/microfrontends-config/isomorphic';\nimport type {\n MicrofrontendsMiddleware,\n MicrofrontendsMiddlewareHandler,\n} from './types';\n\n// Extracts the flag value override if one is present in the headers\nfunction getMfeFlagHeader(req: NextRequest): boolean | null {\n const flagValue = req.headers.get('x-vercel-mfe-flag-value');\n if (flagValue === 'true') {\n return true;\n }\n if (flagValue === 'false') {\n return false;\n }\n return null;\n}\n\ninterface GetFlagHandlerParams {\n application: ChildApplication;\n flagFn: () => Promise<boolean>;\n flagName: string;\n pattern: RegExp;\n localProxyPort: number;\n}\n\nfunction getFlagHandler({\n application,\n flagFn,\n flagName,\n pattern,\n localProxyPort,\n}: GetFlagHandlerParams): MicrofrontendsMiddlewareHandler {\n return async (req: NextRequest): Promise<NextResponse | undefined> => {\n try {\n const pathname = req.nextUrl.pathname;\n\n // If the pattern doesn't match, we don't need to execute the flag\n const flagValueFromHeader = routeToLocalProxy()\n ? getMfeFlagHeader(req)\n : null;\n if (pattern.test(pathname) && (flagValueFromHeader ?? (await flagFn()))) {\n const headers = new Headers(req.headers);\n /**\n * This header informs the proxy which zone the route the request to.\n * It will override any provided redirect / rewrite host.\n *\n * If a rewrite / redirect includes this header, the proxy will perform the\n * action, but will also replace the host with corresponding host for the zone.\n */\n headers.set('x-vercel-mfe-zone', application.name);\n const middlewareResponseInit = {\n request: {\n headers,\n },\n };\n if (routeToLocalProxy()) {\n if (process.env.MFE_DEBUG) {\n // eslint-disable-next-line no-console\n console.log(\n `Routing flagged path \"${pathname}\" to local proxy for application \"${application.name}\"`,\n );\n }\n const url = req.nextUrl;\n url.host = `localhost:${localProxyPort}`;\n return NextResponse.rewrite(url, middlewareResponseInit);\n }\n if (process.env.MFE_DEBUG) {\n // eslint-disable-next-line no-console\n console.log(\n `Routing flagged path \"${pathname}\" to application \"${application.name}\"`,\n );\n }\n return NextResponse.next(middlewareResponseInit);\n }\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n `An error occured in the microfrontends middleware evaluating the flag \"${flagName}\":`,\n e,\n );\n // still want to throw the error, just also making sure the error is logged\n throw e;\n }\n };\n // If the path does not match the pattern, we don't do anything and let the request continue\n}\n\n/**\n * Returns an array of middleware functions that will handle routing to the\n * right micro-frontends for the provided configuration.\n *\n * @param config - The micro-frontends configuration object.\n * @param flagValues - An object that maps flag names to functions that return the flag value.\n */\nexport function getMicrofrontendsMiddleware({\n request,\n flagValues,\n}: {\n request: NextRequest;\n flagValues?: Record<string, () => Promise<boolean>>;\n}): MicrofrontendsMiddleware[] {\n const microfrontends = MicrofrontendConfigIsomorphic.fromEnv({\n cookies: request.cookies.getAll(),\n });\n const middlewares: MicrofrontendsMiddleware[] = [];\n\n if (!process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION) {\n throw new Error('NEXT_PUBLIC_MFE_CURRENT_APPLICATION is not set');\n }\n\n const currentApplication = microfrontends.getApplication(\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION,\n );\n\n if (!currentApplication.isDefault()) {\n return middlewares;\n }\n\n const localProxyPort = microfrontends.getLocalProxyPort();\n\n for (const application of microfrontends.getChildApplications()) {\n for (const pathGroup of application.routing) {\n const flagName = pathGroup.flag;\n if (flagName) {\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 ${application.name} but not found in provided flag values.`,\n );\n }\n for (const path of pathGroup.paths) {\n const pattern = pathToRegexp(path);\n middlewares.push({\n src: pattern,\n fn: getFlagHandler({\n application,\n flagFn,\n flagName,\n pattern,\n localProxyPort,\n }),\n });\n }\n }\n }\n }\n\n return middlewares;\n}\n\n/**\n * Executes the middlewares returned by `getMicrofrontendsMiddleware` and\n * returns a `Response` if any of the micro-frontends middlewares match or\n * `undefined` if none match. If a `Response` object is returned, the calling\n * code should return that Response from the Next.js middleware in order to\n * stop execution of the middleware and perform the rewrite.\n */\nexport async function runMicrofrontendsMiddleware({\n request,\n flagValues,\n}: {\n request: NextRequest;\n flagValues?: Record<string, () => Promise<boolean>>;\n}): Promise<Response | undefined> {\n const pathname = request.nextUrl.pathname;\n const middlewares = getMicrofrontendsMiddleware({\n request,\n flagValues,\n });\n\n for (const mware of middlewares) {\n if (\n typeof mware.src === 'string'\n ? pathname === mware.src\n : mware.src.test(pathname)\n ) {\n // eslint-disable-next-line no-await-in-loop\n const response = await mware.fn(request);\n if (response) {\n return response;\n }\n }\n }\n}\n","export function routeToLocalProxy(): boolean {\n const isDevEnv = (process.env.VERCEL_ENV ?? 'development') === 'development';\n\n return isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY);\n}\n","import { parse } from 'jsonc-parser';\nimport { getConfigStringFromEnv } from '../utils/get-config-from-env';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\nimport type { Config } from '../../schema/types';\nimport type { ClientConfig } from '../client/types';\nimport { MicrofrontendError } from '../../errors';\nimport { MicrofrontendConfigClient } from '../client';\nimport { type OverridesConfig, parseOverrides } from '../../overrides';\nimport { DefaultApplication, ChildApplication } from './application';\nimport { DEFAULT_LOCAL_PROXY_PORT } from './constants';\nimport {\n validateConfigDefaultApplication,\n validateConfigPaths,\n validateDeprecatedFields,\n} from './validation';\n\ninterface ValidationOptions {\n skipValidation?: 'deprecatedFields'[];\n}\n\n/**\n * A class to manage the microfrontends configuration.\n */\nexport class MicrofrontendConfigIsomorphic {\n config: Config;\n defaultApplication: DefaultApplication;\n childApplications: Record<string, ChildApplication> = {};\n overrides?: OverridesConfig;\n options?: Config['options'];\n\n private readonly serialized: {\n config: Config;\n overrides?: OverridesConfig;\n };\n\n constructor({\n config,\n overrides,\n opts,\n }: {\n config: Config;\n overrides?: OverridesConfig;\n opts?: ValidationOptions;\n }) {\n // run validation on init\n MicrofrontendConfigIsomorphic.validate(config, opts);\n\n const disableOverrides =\n config.options?.disableOverrides ??\n config.options?.vercel?.disableOverrides ??\n false;\n this.overrides = overrides && !disableOverrides ? overrides : undefined;\n\n let defaultApplication: DefaultApplication | undefined;\n // create applications\n for (const [appId, appConfig] of Object.entries(config.applications)) {\n const appOverrides = !disableOverrides\n ? this.overrides?.applications[appId]\n : undefined;\n\n if (isDefaultApp(appConfig)) {\n defaultApplication = new DefaultApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n } else {\n this.childApplications[appId] = new ChildApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n }\n }\n\n // validate that this.defaultApplication is defined\n if (!defaultApplication) {\n throw new MicrofrontendError(\n 'Could not find default application in microfrontends configuration',\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n this.defaultApplication = defaultApplication;\n\n this.config = config;\n this.options = config.options;\n this.serialized = {\n config,\n overrides,\n };\n }\n\n static validate(config: string | Config, opts?: ValidationOptions): Config {\n const skipValidation: ValidationOptions['skipValidation'] =\n opts?.skipValidation ?? [];\n // let this throw if it's not valid JSON\n const c = typeof config === 'string' ? (parse(config) as Config) : config;\n\n validateConfigPaths(c.applications);\n validateConfigDefaultApplication(c.applications);\n\n if (!skipValidation.includes('deprecatedFields')) {\n validateDeprecatedFields(c);\n }\n\n return c;\n }\n\n static fromEnv({\n cookies,\n }: {\n cookies?: { name: string; value: string }[];\n }): MicrofrontendConfigIsomorphic {\n return new MicrofrontendConfigIsomorphic({\n config: parse(getConfigStringFromEnv()) as Config,\n overrides: parseOverrides(cookies ?? []),\n });\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getApplicationsByType(): {\n defaultApplication?: DefaultApplication;\n applications: ChildApplication[];\n } {\n return {\n defaultApplication: this.defaultApplication,\n applications: Object.values(this.childApplications),\n };\n }\n\n getChildApplications(): ChildApplication[] {\n return Object.values(this.childApplications);\n }\n\n getAllApplications(): (DefaultApplication | ChildApplication)[] {\n return [\n this.defaultApplication,\n ...Object.values(this.childApplications),\n ].filter(Boolean);\n }\n\n getApplication(name: string): DefaultApplication | ChildApplication {\n // check the default\n if (\n this.defaultApplication.name === name ||\n this.defaultApplication.packageName === name\n ) {\n return this.defaultApplication;\n }\n const app =\n this.childApplications[name] ||\n Object.values(this.childApplications).find(\n (child) => child.packageName === name,\n );\n if (!app) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n return app;\n }\n\n getApplicationByProjectId(\n projectId: string,\n ): DefaultApplication | ChildApplication | undefined {\n // check the default\n if (this.defaultApplication.projectId === projectId) {\n return this.defaultApplication;\n }\n\n return Object.values(this.childApplications).find(\n (app) => app.projectId === projectId,\n );\n }\n\n /**\n * Returns the default application.\n */\n getDefaultApplication(): DefaultApplication {\n return this.defaultApplication;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return (\n this.config.options?.localProxyPort ??\n this.config.options?.localProxy?.port ??\n DEFAULT_LOCAL_PROXY_PORT\n );\n }\n\n /**\n * Serializes the class back to the Schema type.\n *\n * NOTE: This is used when writing the config to disk and must always match the input Schema\n */\n toSchemaJson(): Config {\n return this.serialized.config;\n }\n\n toClientConfig(): MicrofrontendConfigClient {\n const applications: ClientConfig['applications'] = Object.fromEntries(\n Object.entries(this.childApplications).map(([name, application]) => [\n name,\n {\n default: false,\n routing: application.routing,\n },\n ]),\n );\n\n // add the default application\n applications[this.defaultApplication.name] = {\n default: true,\n };\n\n return new MicrofrontendConfigClient({\n applications,\n });\n }\n\n serialize(): {\n config: Config;\n overrides?: OverridesConfig;\n } {\n return this.serialized;\n }\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'application'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\n | 'inference_failed'\n | 'not_found_in_env'\n | 'invalid_asset_prefix'\n | 'invalid_main_path'\n | 'does_not_match_schema'\n | 'unable_to_read_file'\n | 'unsupported_validation_env'\n | 'unsupported_version'\n | 'invalid_path'\n | 'invalid_permissions'\n | 'invalid_syntax'\n | 'missing_microfrontend_config_path'\n | 'unsupported_operation';\n\n// A mapping of error types to their subtypes.\ninterface TypeToSubtype {\n application:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\n | 'depcrecated_field'\n | 'does_not_match_schema'\n | 'invalid_main_path'\n | 'invalid_preview_deployment_suffix'\n | 'multiple_default_applications'\n | 'no_default_application'\n | 'not_found_in_env'\n | 'not_found'\n | 'inference_failed'\n | 'unable_to_read_file'\n | 'invalid_syntax'\n | 'invalid_permissions'\n | 'unsupported_operation'\n | 'unsupported_validation_env'\n | 'unsupported_version';\n packageJson:\n | 'missing_field_name'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n vercelJson:\n | 'missing_field_microfrontend_config_path'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n unknown: never;\n}\n\nexport type MicrofrontendErrorSource =\n | '@vercel/microfrontends'\n | '@vercel/microfrontends/next'\n | 'fs'\n | 'ajv';\n\nexport interface MicrofrontendErrorOptions<T extends MicrofrontendErrorType> {\n cause?: unknown;\n source?: MicrofrontendErrorSource;\n type?: T;\n subtype?: TypeToSubtype[T];\n}\n\ninterface HandleOptions {\n fileName?: string;\n}\n\nexport class MicrofrontendError<\n T extends MicrofrontendErrorType = 'unknown',\n> extends Error {\n public source: MicrofrontendErrorSource;\n public type: T;\n public subtype?: TypeToSubtype[T];\n\n constructor(message: string, opts?: MicrofrontendErrorOptions<T>) {\n super(message, { cause: opts?.cause });\n this.name = 'MicrofrontendsError';\n this.source = opts?.source ?? '@vercel/microfrontends';\n this.type = opts?.type ?? ('unknown' as T);\n this.subtype = opts?.subtype;\n Error.captureStackTrace(this, MicrofrontendError);\n }\n\n isKnown(): boolean {\n return this.type !== 'unknown';\n }\n\n isUnknown(): boolean {\n return !this.isKnown();\n }\n\n /**\n * Converts an error to a MicrofrontendsError.\n * @param original - The original error to convert.\n * @returns The converted MicrofrontendsError.\n */\n static convert(\n original: Error,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (opts?.fileName) {\n const err = MicrofrontendError.convertFSError(original, opts.fileName);\n if (err) {\n return err;\n }\n }\n\n if (\n original.message.includes(\n 'Code generation from strings disallowed for this context',\n )\n ) {\n return new MicrofrontendError(original.message, {\n type: 'config',\n subtype: 'unsupported_validation_env',\n source: 'ajv',\n });\n }\n\n // unknown catch-all\n return new MicrofrontendError(original.message);\n }\n\n static convertFSError(\n original: Error,\n fileName: string,\n ): MicrofrontendError<MicrofrontendErrorType> | null {\n if (original instanceof Error && 'code' in original) {\n if (original.code === 'ENOENT') {\n return new MicrofrontendError(`Could not find \"${fileName}\"`, {\n type: 'config',\n subtype: 'unable_to_read_file',\n source: 'fs',\n });\n }\n if (original.code === 'EACCES') {\n return new MicrofrontendError(\n `Permission denied while accessing \"${fileName}\"`,\n {\n type: 'config',\n subtype: 'invalid_permissions',\n source: 'fs',\n },\n );\n }\n }\n\n if (original instanceof SyntaxError) {\n return new MicrofrontendError(\n `Failed to parse \"${fileName}\": Invalid JSON format.`,\n {\n type: 'config',\n subtype: 'invalid_syntax',\n source: 'fs',\n },\n );\n }\n\n return null;\n }\n\n /**\n * Handles an unknown error and returns a MicrofrontendsError instance.\n * @param err - The error to handle.\n * @returns A MicrofrontendsError instance.\n */\n static handle(\n err: unknown,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (err instanceof MicrofrontendError) {\n return err as MicrofrontendError<MicrofrontendErrorType>;\n }\n\n // handle Error instances\n if (err instanceof Error) {\n return MicrofrontendError.convert(err, opts);\n }\n\n // handle object errors\n if (typeof err === 'object' && err !== null) {\n if ('message' in err && typeof err.message === 'string') {\n return MicrofrontendError.convert(new Error(err.message), opts);\n }\n }\n\n return new MicrofrontendError('An unknown error occurred');\n }\n}\n","import { MicrofrontendError } from '../../errors';\n\n/**\n * Utility to fetch the microfrontend configuration string from the environment.\n */\nexport function getConfigStringFromEnv(): string {\n const config = process.env.MFE_CONFIG;\n if (!config) {\n throw new MicrofrontendError(`Missing \"MFE_CONFIG\" in environment.`, {\n type: 'config',\n subtype: 'not_found_in_env',\n });\n }\n return config;\n}\n","import type { Application, DefaultApplication } from '../types';\n\nexport function isDefaultApp(a: Application): a is DefaultApplication {\n return !('routing' in a);\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","// cookie name needs to match proxy\n// https://github.com/vercel/proxy/blob/fb00d723136ad539a194e4a851dd272010527c35/lib/routing/micro_frontends_overrides.lua#L7\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\nexport const OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n","import { OVERRIDES_COOKIE_PREFIX } from './constants';\n\nexport function isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n}\n","import { isOverrideCookie } from './is-override-cookie';\nimport { OVERRIDES_ENV_COOKIE_PREFIX } from './constants';\n\nexport function getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n}): { application: string; host: string } | undefined {\n if (!isOverrideCookie(cookie) || !cookie.value) return;\n return {\n application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ''),\n host: cookie.value,\n };\n}\n","import type { OverridesConfig } from './types';\nimport { getOverrideFromCookie } from './get-override-from-cookie';\n\nexport function parseOverrides(\n cookies: { name: string; value?: string | null }[],\n): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.application] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n}\n","import { pathToRegexp, parse as parsePathRegexp } from 'path-to-regexp';\nimport type {\n ApplicationId,\n PathGroup,\n ApplicationRouting,\n ChildApplication as ChildApplicationConfig,\n Config,\n} from '../../schema/types';\nimport { MicrofrontendError } from '../../errors';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\n\nconst LIST_FORMATTER = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n});\n\n/**\n * Validate all paths in a configuration - ensures paths do not overlap\n */\nexport const validateConfigPaths = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n const pathsByApplicationId = new Map<\n PathGroup['paths'][number],\n {\n applications: ApplicationId[];\n matcher: RegExp;\n applicationId?: ApplicationId;\n }\n >();\n const errors: string[] = [];\n\n for (const [id, app] of Object.entries(applicationConfigsById)) {\n if (isDefaultApp(app)) {\n // default applications do not have routing\n continue;\n }\n // TODO: remove this once DefaultApplication.development is required (after the migration)\n const childApp = app as ChildApplicationConfig;\n\n for (const pathMatch of childApp.routing) {\n for (const path of pathMatch.paths) {\n const maybeError = validatePathExpression(path);\n if (maybeError) {\n errors.push(maybeError);\n } else {\n const existing = pathsByApplicationId.get(path);\n if (existing) {\n existing.applications.push(id);\n } else {\n pathsByApplicationId.set(path, {\n applications: [id],\n matcher: pathToRegexp(path),\n applicationId: id,\n });\n }\n }\n }\n }\n }\n const entries = Array.from(pathsByApplicationId.entries());\n\n for (const [path, { applications: ids, matcher, applicationId }] of entries) {\n if (ids.length > 1) {\n errors.push(\n `Duplicate path \"${path}\" for applications \"${ids.join(', ')}\"`,\n );\n }\n\n for (const [\n matchPath,\n { applications: matchIds, applicationId: matchApplicationId },\n ] of entries) {\n if (path === matchPath) {\n // we're comparing to ourselves, so skip\n continue;\n }\n\n if (applicationId === matchApplicationId) {\n // we're comparing to paths within our own application, which are allowed to overlap, so skip\n continue;\n }\n\n if (matcher.test(matchPath)) {\n const source = `\"${path}\" of application${ids.length > 0 ? 's' : ''} ${ids.join(', ')}`;\n const destination = `\"${matchPath}\" of application${matchIds.length > 0 ? 's' : ''} ${matchIds.join(', ')}`;\n\n errors.push(\n `Overlapping path detected between ${source} and ${destination}`,\n );\n }\n }\n }\n\n if (errors.length) {\n throw new MicrofrontendError(\n `Invalid paths: ${errors.join(', ')}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,\n {\n type: 'config',\n subtype: 'conflicting_paths',\n },\n );\n }\n};\n\n// From https://github.com/pillarjs/path-to-regexp/blob/b0778f5e8e6c6e9ee4e2f5b34e877cc5229f8036/src/index.ts#L143\nconst PATH_DEFAULT_PATTERN = '[^\\\\/#\\\\?]+?';\n\nfunction validatePathExpression(path: string): string | undefined {\n try {\n const tokens = parsePathRegexp(path);\n if (/(?<!\\\\)\\{/.test(path)) {\n return `Optional paths are not supported: ${path}`;\n }\n if (/(?<!\\\\|\\()\\?/.test(path)) {\n return `Optional paths are not supported: ${path}`;\n }\n if (/\\/[^/]*(?<!\\\\):[^/]*(?<!\\\\):[^/]*/.test(path)) {\n return `Only one wildcard is allowed per path segment: ${path}`;\n }\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token === undefined) {\n return `token ${i} in ${path} is undefined, this shouldn't happen`;\n }\n if (typeof token !== 'string') {\n if (!token.name) {\n return `Only named wildcards are allowed: ${path} (hint: add \":path\" to the wildcard)`;\n }\n if (\n token.pattern !== PATH_DEFAULT_PATTERN &&\n // Allows (a|b|c) and ((?!a|b|c).*) regex\n // Only limited regex is supported for now, due to performance considerations\n !/^(?<allowed>[\\w]+(?:\\|[^:|()]+)+)$|^\\(\\?!(?<disallowed>[\\w]+(?:\\|[^:|()]+)*)\\)\\.\\*$/.test(\n token.pattern,\n )\n ) {\n return `Path ${path} cannot use unsupported regular expression wildcard`;\n }\n if (token.modifier && i !== tokens.length - 1) {\n return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path}. Modifiers are only allowed in the last path component`;\n }\n }\n }\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return `Path ${path} could not be parsed into regexp: ${message}`;\n }\n return undefined;\n}\n\n/**\n * Validate all paths in an application - ensures paths are the correct format\n */\nexport const validateAppPaths = (\n name: string,\n app: ChildApplicationConfig,\n): void => {\n // validate routes\n for (const group of app.routing) {\n for (const p of group.paths) {\n if (p === '/') {\n continue;\n }\n if (p.endsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must not end with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n\n if (!p.startsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must start with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n }\n }\n};\n\n/**\n * Make sure only one `Application` defines routing\n * */\nexport const validateConfigDefaultApplication = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n const applicationsWithoutRouting = Object.entries(\n applicationConfigsById,\n ).filter(([, app]) => isDefaultApp(app));\n const numApplicationsWithoutRouting = applicationsWithoutRouting.reduce(\n (acc) => {\n return acc + 1;\n },\n 0,\n );\n\n if (numApplicationsWithoutRouting === 0) {\n throw new MicrofrontendError(\n 'No default application found. At least one application needs to be the default by omitting routing.',\n { type: 'config', subtype: 'no_default_application' },\n );\n }\n\n if (numApplicationsWithoutRouting > 1) {\n const applicationNamesMissingRouting = applicationsWithoutRouting.map(\n ([name]) => name,\n );\n throw new MicrofrontendError(\n `All applications except for the default app must contain the \"routing\" field. Applications that are missing routing: ${LIST_FORMATTER.format(applicationNamesMissingRouting)}.`,\n { type: 'config', subtype: 'multiple_default_applications' },\n );\n }\n};\n\n// TODO: Remove this after 22 March 2025 when the new schema has been fully in use for 30 days and thus we can delete the deprecated fields.\nexport const validateDeprecatedFields = (config: Config): void => {\n const errors = [];\n\n if (config.options?.vercel) {\n errors.push(\n `Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`,\n );\n }\n if (config.options?.localProxy) {\n errors.push(\n `Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`,\n );\n }\n\n for (const [applicationId, application] of Object.entries(\n config.applications,\n )) {\n if (application.vercel) {\n errors.push(\n `Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`,\n );\n }\n if (application.production) {\n errors.push(\n `Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`,\n );\n }\n if (application.development?.localPort) {\n errors.push(\n `Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`,\n );\n }\n if (\n application.development?.fallback &&\n typeof application.development.fallback !== 'string'\n ) {\n const fallback = application.development.fallback;\n let asString = fallback.host;\n if (fallback.protocol) {\n asString = `${fallback.protocol}://${asString}`;\n }\n if (fallback.port) {\n asString = `${asString}:${fallback.port}`;\n }\n errors.push(\n `Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`,\n );\n }\n if (\n application.development?.local &&\n typeof application.development.local !== 'string' &&\n typeof application.development.local !== 'number'\n ) {\n const local = application.development.local;\n let asString: string | undefined;\n if (local.port && !local.protocol && !local.host) {\n asString = String(local.port);\n } else {\n asString = local.host ?? 'localhost';\n if (local.protocol) {\n asString = `${local.protocol}://${asString}`;\n }\n if (local.port) {\n asString = `${asString}:${local.port}`;\n }\n }\n errors.push(\n `Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`,\n );\n }\n }\n\n if (errors.length) {\n throw new MicrofrontendError(\n `Microfrontends configuration file errors:\\n- ${errors.join('\\n- ')}`,\n {\n type: 'config',\n subtype: 'depcrecated_field',\n },\n );\n }\n};\n","const PREFIX = 'vc-ap';\n\nexport function generateAssetPrefixFromName({\n name,\n}: {\n name: string;\n}): string {\n if (!name) {\n throw new Error('Name is required to generate an asset prefix');\n }\n\n return `${PREFIX}-${name}`;\n}\n","export function generatePortFromName({\n name,\n minPort = 3000,\n maxPort = 8000,\n}: {\n name: string;\n minPort?: number;\n maxPort?: number;\n}): number {\n if (!name) {\n throw new Error('Name is required to generate a port');\n }\n\n // hash the name\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n // eslint-disable-next-line no-bitwise\n hash = (hash << 5) - hash + name.charCodeAt(i);\n // Convert to 32-bit\n // eslint-disable-next-line no-bitwise\n hash |= 0;\n }\n hash = Math.abs(hash);\n\n // Map the hash to the port range\n const range = maxPort - minPort;\n const port = minPort + (hash % range);\n\n return port;\n}\n","import type {\n HostConfig as RemoteHostConfigSchema,\n LocalHostConfig as LocalHostConfigSchema,\n} from '../../schema/types';\nimport { generatePortFromName } from './utils/generate-port';\n\ninterface HostOptions {\n isLocal?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: string;\n port?: number;\n local: boolean | undefined;\n\n constructor(\n hostConfig: RemoteHostConfigSchema | string,\n options?: HostOptions,\n ) {\n if (typeof hostConfig === 'string') {\n ({\n protocol: this.protocol,\n host: this.host,\n port: this.port,\n } = Host.parseUrl(hostConfig));\n } else {\n const { protocol = 'https', host, port } = hostConfig;\n this.protocol = protocol;\n this.host = host;\n this.port = port;\n }\n this.local = options?.isLocal;\n }\n\n protected static parseUrl(\n url: string,\n defaultProtocol = 'https',\n ): {\n protocol: Host['protocol'];\n host: string;\n port?: number;\n } {\n let hostToParse = url;\n if (!/^https?:\\/\\//.exec(hostToParse)) {\n hostToParse = `${defaultProtocol}://${hostToParse}`;\n }\n const parsed = new URL(hostToParse);\n if (!parsed.hostname) {\n throw new Error(Host.getMicrofrontendsError(url, 'requires a host'));\n }\n if (parsed.hash) {\n throw new Error(\n Host.getMicrofrontendsError(url, 'cannot have a fragment'),\n );\n }\n if (parsed.username || parsed.password) {\n throw new Error(\n Host.getMicrofrontendsError(\n url,\n 'cannot have authentication credentials (username and/or password)',\n ),\n );\n }\n if (parsed.pathname !== '/') {\n throw new Error(Host.getMicrofrontendsError(url, 'cannot have a path'));\n }\n if (parsed.search) {\n throw new Error(\n Host.getMicrofrontendsError(url, 'cannot have query parameters'),\n );\n }\n const protocol = parsed.protocol.slice(0, -1) as Host['protocol'];\n return {\n protocol,\n host: parsed.hostname,\n port: parsed.port ? Number.parseInt(parsed.port) : undefined,\n };\n }\n\n private static getMicrofrontendsError(url: string, message: string): string {\n return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;\n }\n\n isLocal(): boolean {\n return this.local || this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n toString(): string {\n const url = this.toUrl();\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(): URL {\n const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ''}`;\n return new URL(url);\n }\n}\n\n/**\n * A Host subclass with defaults for locally running applications\n */\nexport class LocalHost extends Host {\n constructor({\n appName,\n localPort,\n local,\n }: {\n appName: string;\n localPort?: number;\n local?: string | number | LocalHostConfigSchema;\n }) {\n if (localPort && local) {\n throw new Error(\n `Microfrontends configuration error: '${appName}' has both the 'development.local' and 'development.localPort' fields set. Please remove the 'development.localPort' field and ensure the 'development.local' field has the correct port.`,\n );\n }\n let protocol: RemoteHostConfigSchema['protocol'];\n let host: string | undefined;\n let port: number | undefined;\n if (localPort) {\n port = localPort;\n } else if (typeof local === 'number') {\n port = local;\n } else if (typeof local === 'string') {\n if (/^\\d+$/.test(local)) {\n port = Number.parseInt(local);\n } else {\n const parsed = Host.parseUrl(local, 'http');\n protocol = parsed.protocol;\n host = parsed.host;\n port = parsed.port;\n }\n } else if (local) {\n protocol = local.protocol;\n host = local.host;\n port = local.port;\n }\n // set defaults for local\n super({\n protocol: protocol ?? 'http',\n host: host ?? 'localhost',\n port: port ?? generatePortFromName({ name: appName }),\n });\n }\n}\n","import type {\n Application as ApplicationConfig,\n DefaultApplication as DefaultApplicationConfig,\n ChildApplication as ChildApplicationConfig,\n PathGroup,\n} from '../../schema/types';\nimport type { ApplicationOverrideConfig } from '../../overrides';\nimport { validateAppPaths } from './validation';\nimport { generateAssetPrefixFromName } from './utils/generate-asset-prefix';\nimport { Host, LocalHost } from './host';\n\nexport class Application {\n readonly default: boolean;\n name: string;\n development: {\n local: LocalHost;\n fallback?: Host;\n };\n fallback?: Host;\n projectId?: string;\n packageName?: string;\n overrides?: {\n environment?: Host;\n };\n readonly serialized: ApplicationConfig;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n isDefault,\n }: {\n app: ApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n isDefault?: boolean;\n },\n ) {\n this.name = name;\n this.development = {\n local: new LocalHost({\n appName: name,\n localPort: app.development?.localPort,\n local: app.development?.local,\n }),\n fallback: app.development?.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n if (app.development?.fallback) {\n this.fallback = new Host(app.development.fallback);\n } else if (app.production) {\n this.fallback = new Host(app.production);\n }\n this.projectId = app.projectId ?? app.vercel?.projectId;\n this.packageName = app.packageName;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n this.default = isDefault ?? false;\n this.serialized = app;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n getAssetPrefix(): string {\n return generateAssetPrefixFromName({ name: this.name });\n }\n\n serialize(): ApplicationConfig {\n return this.serialized;\n }\n}\n\nexport class DefaultApplication extends Application {\n readonly default = true;\n // TODO: remove this once the config simplification migration is complete.\n /** @deprecated use fallback instead. */\n production?: Host;\n fallback: Host;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: DefaultApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n super(name, {\n app,\n overrides,\n isDefault: true,\n });\n\n const fallbackHost = app.development?.fallback ?? app.production;\n if (fallbackHost === undefined) {\n // TODO: remove this one app.developement.fallback is required after the migration.\n throw new Error(\n '`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json.',\n );\n }\n this.fallback = new Host(fallbackHost);\n if (app.production) {\n this.production = new Host(app.production);\n }\n }\n\n getAssetPrefix(): string {\n return '';\n }\n}\n\nexport class ChildApplication extends Application {\n readonly default = false;\n routing: PathGroup[];\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: ChildApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n // validate\n ChildApplication.validate(name, app);\n\n super(name, {\n app,\n overrides,\n isDefault: false,\n });\n\n this.routing = app.routing;\n }\n\n static validate(name: string, app: ChildApplicationConfig): void {\n // validate routes\n validateAppPaths(name, app);\n }\n}\n","export const DEFAULT_LOCAL_PROXY_PORT = 3024;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AA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A4B;AAAA,IAC9C;AAAA,IACA;AAAA,EACF,CAAC;AAED,aAAW,SAAS,aAAa;AAC/B,QACE,OAAO,MAAM,QAAQ,WACjB,aAAa,MAAM,MACnB,MAAM,IAAI,KAAK,QAAQ,GAC3B;AAEA,YAAM,WAAW,MAAM,MAAM,GAAG,OAAO;AACvC,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["import_path_to_regexp","import_path_to_regexp","parsePathRegexp"]}
|
|
1
|
+
{"version":3,"sources":["../../src/next/middleware/index.ts","../../src/next/middleware/middleware.ts","../../src/next/utils/route-to-local-proxy.ts","../../src/config/microfrontends-config/isomorphic/index.ts","../../src/config/errors.ts","../../src/config/microfrontends-config/utils/get-config-from-env.ts","../../src/config/schema/utils/is-default-app.ts","../../src/config/microfrontends-config/client/index.ts","../../src/config/overrides/constants.ts","../../src/config/overrides/is-override-cookie.ts","../../src/config/overrides/get-override-from-cookie.ts","../../src/config/overrides/parse-overrides.ts","../../src/config/microfrontends-config/isomorphic/validation.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-port.ts","../../src/config/microfrontends-config/isomorphic/host.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts","../../src/config/microfrontends-config/isomorphic/application.ts","../../src/config/microfrontends-config/isomorphic/constants.ts"],"sourcesContent":["export * from './middleware';\nexport * from './types';\n","/// <reference types=\"@edge-runtime/types\" />\n\nimport type { NextRequest } from 'next/server';\nimport { NextResponse } from 'next/server';\nimport { pathToRegexp } from 'path-to-regexp';\nimport type { ChildApplication } from '../../config/microfrontends-config/isomorphic/application';\nimport { routeToLocalProxy } from '../utils/route-to-local-proxy';\nimport { MicrofrontendConfigIsomorphic } from '../../config/microfrontends-config/isomorphic';\nimport type {\n MicrofrontendsMiddleware,\n MicrofrontendsMiddlewareHandler,\n} from './types';\n\n// Extracts the flag value override if one is present in the headers\nfunction getMfeFlagHeader(req: NextRequest): boolean | null {\n const flagValue = req.headers.get('x-vercel-mfe-flag-value');\n if (flagValue === 'true') {\n return true;\n }\n if (flagValue === 'false') {\n return false;\n }\n return null;\n}\n\ninterface GetFlagHandlerParams {\n application: ChildApplication;\n flagFn: () => Promise<boolean>;\n flagName: string;\n pattern: RegExp;\n localProxyPort: number;\n}\n\nfunction getFlagHandler({\n application,\n flagFn,\n flagName,\n pattern,\n localProxyPort,\n}: GetFlagHandlerParams): MicrofrontendsMiddlewareHandler {\n return async (req: NextRequest): Promise<NextResponse | undefined> => {\n try {\n const pathname = req.nextUrl.pathname;\n\n // If the pattern doesn't match, we don't need to execute the flag\n const flagValueFromHeader = routeToLocalProxy()\n ? getMfeFlagHeader(req)\n : null;\n if (pattern.test(pathname) && (flagValueFromHeader ?? (await flagFn()))) {\n const headers = new Headers(req.headers);\n /**\n * This header informs the proxy which zone the route the request to.\n * It will override any provided redirect / rewrite host.\n *\n * If a rewrite / redirect includes this header, the proxy will perform the\n * action, but will also replace the host with corresponding host for the zone.\n */\n headers.set('x-vercel-mfe-zone', application.name);\n const middlewareResponseInit = {\n request: {\n headers,\n },\n };\n if (routeToLocalProxy()) {\n if (process.env.MFE_DEBUG) {\n // eslint-disable-next-line no-console\n console.log(\n `Routing flagged path \"${pathname}\" to local proxy for application \"${application.name}\"`,\n );\n }\n const url = req.nextUrl;\n url.host = `localhost:${localProxyPort}`;\n return NextResponse.rewrite(url, middlewareResponseInit);\n }\n if (process.env.MFE_DEBUG) {\n // eslint-disable-next-line no-console\n console.log(\n `Routing flagged path \"${pathname}\" to application \"${application.name}\"`,\n );\n }\n return NextResponse.next(middlewareResponseInit);\n }\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n `An error occured in the microfrontends middleware evaluating the flag \"${flagName}\":`,\n e,\n );\n // still want to throw the error, just also making sure the error is logged\n throw e;\n }\n };\n // If the path does not match the pattern, we don't do anything and let the request continue\n}\n\n/**\n * Returns an array of middleware functions that will handle routing to the\n * right micro-frontends for the provided configuration.\n *\n * @param config - The micro-frontends configuration object.\n * @param flagValues - An object that maps flag names to functions that return the flag value.\n */\nexport function getMicrofrontendsMiddleware({\n request,\n flagValues,\n}: {\n request: NextRequest;\n flagValues?: Record<string, () => Promise<boolean>>;\n}): MicrofrontendsMiddleware[] {\n const microfrontends = MicrofrontendConfigIsomorphic.fromEnv({\n cookies: request.cookies.getAll(),\n });\n const middlewares: MicrofrontendsMiddleware[] = [];\n\n if (!process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION) {\n throw new Error('NEXT_PUBLIC_MFE_CURRENT_APPLICATION is not set');\n }\n\n const currentApplication = microfrontends.getApplication(\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION,\n );\n\n if (!currentApplication.isDefault()) {\n return middlewares;\n }\n\n const localProxyPort = microfrontends.getLocalProxyPort();\n\n for (const application of microfrontends.getChildApplications()) {\n for (const pathGroup of application.routing) {\n const flagName = pathGroup.flag;\n if (flagName) {\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 ${application.name} but not found in provided flag values.`,\n );\n }\n for (const path of pathGroup.paths) {\n const pattern = pathToRegexp(path);\n middlewares.push({\n src: pattern,\n fn: getFlagHandler({\n application,\n flagFn,\n flagName,\n pattern,\n localProxyPort,\n }),\n });\n }\n }\n }\n }\n\n return middlewares;\n}\n\n/**\n * Executes the middlewares returned by `getMicrofrontendsMiddleware` and\n * returns a `Response` if any of the micro-frontends middlewares match or\n * `undefined` if none match. If a `Response` object is returned, the calling\n * code should return that Response from the Next.js middleware in order to\n * stop execution of the middleware and perform the rewrite.\n */\nexport async function runMicrofrontendsMiddleware({\n request,\n flagValues,\n}: {\n request: NextRequest;\n flagValues?: Record<string, () => Promise<boolean>>;\n}): Promise<Response | undefined> {\n const pathname = request.nextUrl.pathname;\n const middlewares = getMicrofrontendsMiddleware({\n request,\n flagValues,\n });\n\n for (const mware of middlewares) {\n if (\n typeof mware.src === 'string'\n ? pathname === mware.src\n : mware.src.test(pathname)\n ) {\n // eslint-disable-next-line no-await-in-loop\n const response = await mware.fn(request);\n if (response) {\n return response;\n }\n }\n }\n}\n","export function routeToLocalProxy(): boolean {\n const isDevEnv = (process.env.VERCEL_ENV ?? 'development') === 'development';\n\n return isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY);\n}\n","import { parse } from 'jsonc-parser';\nimport { getConfigStringFromEnv } from '../utils/get-config-from-env';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\nimport type { Config } from '../../schema/types';\nimport type { ClientConfig } from '../client/types';\nimport { MicrofrontendError } from '../../errors';\nimport { MicrofrontendConfigClient } from '../client';\nimport { type OverridesConfig, parseOverrides } from '../../overrides';\nimport { DefaultApplication, ChildApplication } from './application';\nimport { DEFAULT_LOCAL_PROXY_PORT } from './constants';\nimport {\n validateConfigDefaultApplication,\n validateConfigPaths,\n validateDeprecatedFields,\n} from './validation';\n\ninterface ValidationOptions {\n skipValidation?: 'deprecatedFields'[];\n}\n\n/**\n * A class to manage the microfrontends configuration.\n */\nexport class MicrofrontendConfigIsomorphic {\n config: Config;\n defaultApplication: DefaultApplication;\n childApplications: Record<string, ChildApplication> = {};\n overrides?: OverridesConfig;\n options?: Config['options'];\n\n private readonly serialized: {\n config: Config;\n overrides?: OverridesConfig;\n };\n\n constructor({\n config,\n overrides,\n opts,\n }: {\n config: Config;\n overrides?: OverridesConfig;\n opts?: ValidationOptions;\n }) {\n // run validation on init\n MicrofrontendConfigIsomorphic.validate(config, opts);\n\n const disableOverrides = config.options?.disableOverrides ?? false;\n this.overrides = overrides && !disableOverrides ? overrides : undefined;\n\n let defaultApplication: DefaultApplication | undefined;\n // create applications\n for (const [appId, appConfig] of Object.entries(config.applications)) {\n const appOverrides = !disableOverrides\n ? this.overrides?.applications[appId]\n : undefined;\n\n if (isDefaultApp(appConfig)) {\n defaultApplication = new DefaultApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n } else {\n this.childApplications[appId] = new ChildApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n }\n }\n\n // validate that this.defaultApplication is defined\n if (!defaultApplication) {\n throw new MicrofrontendError(\n 'Could not find default application in microfrontends configuration',\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n this.defaultApplication = defaultApplication;\n\n this.config = config;\n this.options = config.options;\n this.serialized = {\n config,\n overrides,\n };\n }\n\n static validate(config: string | Config, opts?: ValidationOptions): Config {\n const skipValidation: ValidationOptions['skipValidation'] =\n opts?.skipValidation ?? [];\n // let this throw if it's not valid JSON\n const c = typeof config === 'string' ? (parse(config) as Config) : config;\n\n validateConfigPaths(c.applications);\n validateConfigDefaultApplication(c.applications);\n\n if (!skipValidation.includes('deprecatedFields')) {\n validateDeprecatedFields(c);\n }\n\n return c;\n }\n\n static fromEnv({\n cookies,\n }: {\n cookies?: { name: string; value: string }[];\n }): MicrofrontendConfigIsomorphic {\n return new MicrofrontendConfigIsomorphic({\n config: parse(getConfigStringFromEnv()) as Config,\n overrides: parseOverrides(cookies ?? []),\n });\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.disableOverrides ?? false;\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getApplicationsByType(): {\n defaultApplication?: DefaultApplication;\n applications: ChildApplication[];\n } {\n return {\n defaultApplication: this.defaultApplication,\n applications: Object.values(this.childApplications),\n };\n }\n\n getChildApplications(): ChildApplication[] {\n return Object.values(this.childApplications);\n }\n\n getAllApplications(): (DefaultApplication | ChildApplication)[] {\n return [\n this.defaultApplication,\n ...Object.values(this.childApplications),\n ].filter(Boolean);\n }\n\n getApplication(name: string): DefaultApplication | ChildApplication {\n // check the default\n if (\n this.defaultApplication.name === name ||\n this.defaultApplication.packageName === name\n ) {\n return this.defaultApplication;\n }\n const app =\n this.childApplications[name] ||\n Object.values(this.childApplications).find(\n (child) => child.packageName === name,\n );\n if (!app) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n return app;\n }\n\n hasApplication(name: string): boolean {\n try {\n this.getApplication(name);\n return true;\n } catch {\n return false;\n }\n }\n\n getApplicationByProjectId(\n projectId: string,\n ): DefaultApplication | ChildApplication | undefined {\n // check the default\n if (this.defaultApplication.projectId === projectId) {\n return this.defaultApplication;\n }\n\n return Object.values(this.childApplications).find(\n (app) => app.projectId === projectId,\n );\n }\n\n /**\n * Returns the default application.\n */\n getDefaultApplication(): DefaultApplication {\n return this.defaultApplication;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;\n }\n\n /**\n * Serializes the class back to the Schema type.\n *\n * NOTE: This is used when writing the config to disk and must always match the input Schema\n */\n toSchemaJson(): Config {\n return this.serialized.config;\n }\n\n toClientConfig(): MicrofrontendConfigClient {\n const applications: ClientConfig['applications'] = Object.fromEntries(\n Object.entries(this.childApplications).map(([name, application]) => [\n name,\n {\n default: false,\n routing: application.routing,\n },\n ]),\n );\n\n // add the default application\n applications[this.defaultApplication.name] = {\n default: true,\n };\n\n return new MicrofrontendConfigClient({\n applications,\n });\n }\n\n serialize(): {\n config: Config;\n overrides?: OverridesConfig;\n } {\n return this.serialized;\n }\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'application'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\n | 'inference_failed'\n | 'not_found_in_env'\n | 'invalid_asset_prefix'\n | 'invalid_main_path'\n | 'does_not_match_schema'\n | 'unable_to_read_file'\n | 'unsupported_validation_env'\n | 'unsupported_version'\n | 'invalid_path'\n | 'invalid_permissions'\n | 'invalid_syntax'\n | 'missing_microfrontend_config_path'\n | 'unsupported_operation';\n\n// A mapping of error types to their subtypes.\ninterface TypeToSubtype {\n application:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\n | 'depcrecated_field'\n | 'does_not_match_schema'\n | 'invalid_main_path'\n | 'invalid_preview_deployment_suffix'\n | 'multiple_default_applications'\n | 'no_default_application'\n | 'not_found_in_env'\n | 'not_found'\n | 'inference_failed'\n | 'unable_to_read_file'\n | 'invalid_syntax'\n | 'invalid_permissions'\n | 'unsupported_operation'\n | 'unsupported_validation_env'\n | 'unsupported_version';\n packageJson:\n | 'missing_field_name'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n vercelJson:\n | 'missing_field_microfrontend_config_path'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n unknown: never;\n}\n\nexport type MicrofrontendErrorSource =\n | '@vercel/microfrontends'\n | '@vercel/microfrontends/next'\n | 'fs'\n | 'ajv';\n\nexport interface MicrofrontendErrorOptions<T extends MicrofrontendErrorType> {\n cause?: unknown;\n source?: MicrofrontendErrorSource;\n type?: T;\n subtype?: TypeToSubtype[T];\n}\n\ninterface HandleOptions {\n fileName?: string;\n}\n\nexport class MicrofrontendError<\n T extends MicrofrontendErrorType = 'unknown',\n> extends Error {\n public source: MicrofrontendErrorSource;\n public type: T;\n public subtype?: TypeToSubtype[T];\n\n constructor(message: string, opts?: MicrofrontendErrorOptions<T>) {\n super(message, { cause: opts?.cause });\n this.name = 'MicrofrontendsError';\n this.source = opts?.source ?? '@vercel/microfrontends';\n this.type = opts?.type ?? ('unknown' as T);\n this.subtype = opts?.subtype;\n Error.captureStackTrace(this, MicrofrontendError);\n }\n\n isKnown(): boolean {\n return this.type !== 'unknown';\n }\n\n isUnknown(): boolean {\n return !this.isKnown();\n }\n\n /**\n * Converts an error to a MicrofrontendsError.\n * @param original - The original error to convert.\n * @returns The converted MicrofrontendsError.\n */\n static convert(\n original: Error,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (opts?.fileName) {\n const err = MicrofrontendError.convertFSError(original, opts.fileName);\n if (err) {\n return err;\n }\n }\n\n if (\n original.message.includes(\n 'Code generation from strings disallowed for this context',\n )\n ) {\n return new MicrofrontendError(original.message, {\n type: 'config',\n subtype: 'unsupported_validation_env',\n source: 'ajv',\n });\n }\n\n // unknown catch-all\n return new MicrofrontendError(original.message);\n }\n\n static convertFSError(\n original: Error,\n fileName: string,\n ): MicrofrontendError<MicrofrontendErrorType> | null {\n if (original instanceof Error && 'code' in original) {\n if (original.code === 'ENOENT') {\n return new MicrofrontendError(`Could not find \"${fileName}\"`, {\n type: 'config',\n subtype: 'unable_to_read_file',\n source: 'fs',\n });\n }\n if (original.code === 'EACCES') {\n return new MicrofrontendError(\n `Permission denied while accessing \"${fileName}\"`,\n {\n type: 'config',\n subtype: 'invalid_permissions',\n source: 'fs',\n },\n );\n }\n }\n\n if (original instanceof SyntaxError) {\n return new MicrofrontendError(\n `Failed to parse \"${fileName}\": Invalid JSON format.`,\n {\n type: 'config',\n subtype: 'invalid_syntax',\n source: 'fs',\n },\n );\n }\n\n return null;\n }\n\n /**\n * Handles an unknown error and returns a MicrofrontendsError instance.\n * @param err - The error to handle.\n * @returns A MicrofrontendsError instance.\n */\n static handle(\n err: unknown,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (err instanceof MicrofrontendError) {\n return err as MicrofrontendError<MicrofrontendErrorType>;\n }\n\n // handle Error instances\n if (err instanceof Error) {\n return MicrofrontendError.convert(err, opts);\n }\n\n // handle object errors\n if (typeof err === 'object' && err !== null) {\n if ('message' in err && typeof err.message === 'string') {\n return MicrofrontendError.convert(new Error(err.message), opts);\n }\n }\n\n return new MicrofrontendError('An unknown error occurred');\n }\n}\n","import { MicrofrontendError } from '../../errors';\n\n/**\n * Utility to fetch the microfrontend configuration string from the environment.\n */\nexport function getConfigStringFromEnv(): string {\n const config = process.env.MFE_CONFIG;\n if (!config) {\n throw new MicrofrontendError(`Missing \"MFE_CONFIG\" in environment.`, {\n type: 'config',\n subtype: 'not_found_in_env',\n });\n }\n return config;\n}\n","import type { Application, DefaultApplication } from '../types';\n\nexport function isDefaultApp(a: Application): a is DefaultApplication {\n return !('routing' in a);\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","// cookie name needs to match proxy\n// https://github.com/vercel/proxy/blob/fb00d723136ad539a194e4a851dd272010527c35/lib/routing/micro_frontends_overrides.lua#L7\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\nexport const OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n","import { OVERRIDES_COOKIE_PREFIX } from './constants';\n\nexport function isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n}\n","import { isOverrideCookie } from './is-override-cookie';\nimport { OVERRIDES_ENV_COOKIE_PREFIX } from './constants';\n\nexport function getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n}): { application: string; host: string } | undefined {\n if (!isOverrideCookie(cookie) || !cookie.value) return;\n return {\n application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ''),\n host: cookie.value,\n };\n}\n","import type { OverridesConfig } from './types';\nimport { getOverrideFromCookie } from './get-override-from-cookie';\n\nexport function parseOverrides(\n cookies: { name: string; value?: string | null }[],\n): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.application] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n}\n","import { pathToRegexp, parse as parsePathRegexp } from 'path-to-regexp';\nimport type {\n ApplicationId,\n PathGroup,\n ApplicationRouting,\n ChildApplication as ChildApplicationConfig,\n Config,\n} from '../../schema/types';\nimport { MicrofrontendError } from '../../errors';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\n\nconst LIST_FORMATTER = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n});\n\n/**\n * Validate all paths in a configuration - ensures paths do not overlap\n */\nexport const validateConfigPaths = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n const pathsByApplicationId = new Map<\n PathGroup['paths'][number],\n {\n applications: ApplicationId[];\n matcher: RegExp;\n applicationId?: ApplicationId;\n }\n >();\n const errors: string[] = [];\n\n for (const [id, app] of Object.entries(applicationConfigsById)) {\n if (isDefaultApp(app)) {\n // default applications do not have routing\n continue;\n }\n\n for (const pathMatch of app.routing) {\n for (const path of pathMatch.paths) {\n const maybeError = validatePathExpression(path);\n if (maybeError) {\n errors.push(maybeError);\n } else {\n const existing = pathsByApplicationId.get(path);\n if (existing) {\n existing.applications.push(id);\n } else {\n pathsByApplicationId.set(path, {\n applications: [id],\n matcher: pathToRegexp(path),\n applicationId: id,\n });\n }\n }\n }\n }\n }\n const entries = Array.from(pathsByApplicationId.entries());\n\n for (const [path, { applications: ids, matcher, applicationId }] of entries) {\n if (ids.length > 1) {\n errors.push(\n `Duplicate path \"${path}\" for applications \"${ids.join(', ')}\"`,\n );\n }\n\n for (const [\n matchPath,\n { applications: matchIds, applicationId: matchApplicationId },\n ] of entries) {\n if (path === matchPath) {\n // we're comparing to ourselves, so skip\n continue;\n }\n\n if (applicationId === matchApplicationId) {\n // we're comparing to paths within our own application, which are allowed to overlap, so skip\n continue;\n }\n\n if (matcher.test(matchPath)) {\n const source = `\"${path}\" of application${ids.length > 0 ? 's' : ''} ${ids.join(', ')}`;\n const destination = `\"${matchPath}\" of application${matchIds.length > 0 ? 's' : ''} ${matchIds.join(', ')}`;\n\n errors.push(\n `Overlapping path detected between ${source} and ${destination}`,\n );\n }\n }\n }\n\n if (errors.length) {\n throw new MicrofrontendError(\n `Invalid paths: ${errors.join(', ')}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,\n {\n type: 'config',\n subtype: 'conflicting_paths',\n },\n );\n }\n};\n\n// From https://github.com/pillarjs/path-to-regexp/blob/b0778f5e8e6c6e9ee4e2f5b34e877cc5229f8036/src/index.ts#L143\nconst PATH_DEFAULT_PATTERN = '[^\\\\/#\\\\?]+?';\n\nfunction validatePathExpression(path: string): string | undefined {\n try {\n const tokens = parsePathRegexp(path);\n if (/(?<!\\\\)\\{/.test(path)) {\n return `Optional paths are not supported: ${path}`;\n }\n if (/(?<!\\\\|\\()\\?/.test(path)) {\n return `Optional paths are not supported: ${path}`;\n }\n if (/\\/[^/]*(?<!\\\\):[^/]*(?<!\\\\):[^/]*/.test(path)) {\n return `Only one wildcard is allowed per path segment: ${path}`;\n }\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token === undefined) {\n return `token ${i} in ${path} is undefined, this shouldn't happen`;\n }\n if (typeof token !== 'string') {\n if (!token.name) {\n return `Only named wildcards are allowed: ${path} (hint: add \":path\" to the wildcard)`;\n }\n if (\n token.pattern !== PATH_DEFAULT_PATTERN &&\n // Allows (a|b|c) and ((?!a|b|c).*) regex\n // Only limited regex is supported for now, due to performance considerations\n !/^(?<allowed>[\\w]+(?:\\|[^:|()]+)+)$|^\\(\\?!(?<disallowed>[\\w]+(?:\\|[^:|()]+)*)\\)\\.\\*$/.test(\n token.pattern,\n )\n ) {\n return `Path ${path} cannot use unsupported regular expression wildcard`;\n }\n if (token.modifier && i !== tokens.length - 1) {\n return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path}. Modifiers are only allowed in the last path component`;\n }\n }\n }\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return `Path ${path} could not be parsed into regexp: ${message}`;\n }\n return undefined;\n}\n\n/**\n * Validate all paths in an application - ensures paths are the correct format\n */\nexport const validateAppPaths = (\n name: string,\n app: ChildApplicationConfig,\n): void => {\n // validate routes\n for (const group of app.routing) {\n for (const p of group.paths) {\n if (p === '/') {\n continue;\n }\n if (p.endsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must not end with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n\n if (!p.startsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must start with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n }\n }\n};\n\n/**\n * Make sure only one `Application` defines routing\n * */\nexport const validateConfigDefaultApplication = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n const applicationsWithoutRouting = Object.entries(\n applicationConfigsById,\n ).filter(([, app]) => isDefaultApp(app));\n const numApplicationsWithoutRouting = applicationsWithoutRouting.reduce(\n (acc) => {\n return acc + 1;\n },\n 0,\n );\n\n if (numApplicationsWithoutRouting === 0) {\n throw new MicrofrontendError(\n 'No default application found. At least one application needs to be the default by omitting routing.',\n { type: 'config', subtype: 'no_default_application' },\n );\n }\n\n if (numApplicationsWithoutRouting > 1) {\n const applicationNamesMissingRouting = applicationsWithoutRouting.map(\n ([name]) => name,\n );\n throw new MicrofrontendError(\n `All applications except for the default app must contain the \"routing\" field. Applications that are missing routing: ${LIST_FORMATTER.format(applicationNamesMissingRouting)}.`,\n { type: 'config', subtype: 'multiple_default_applications' },\n );\n }\n};\n\n// TODO: Remove this after 4 May 2025 when the new schema has been fully in use for 30 days and thus we can delete the deprecated fields.\nexport const validateDeprecatedFields = (config: Config): void => {\n const errors = [];\n\n for (const [applicationId, application] of Object.entries(\n config.applications,\n )) {\n if (application.development?.localPort) {\n errors.push(\n `Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`,\n );\n }\n if (application.projectId) {\n // This will be an error in the next release\n }\n }\n\n if (errors.length) {\n throw new MicrofrontendError(\n `Microfrontends configuration file errors:\\n- ${errors.join('\\n- ')}`,\n {\n type: 'config',\n subtype: 'depcrecated_field',\n },\n );\n }\n};\n","const PREFIX = 'vc-ap';\n\nexport function generateAssetPrefixFromName({\n name,\n}: {\n name: string;\n}): string {\n if (!name) {\n throw new Error('Name is required to generate an asset prefix');\n }\n\n return `${PREFIX}-${name}`;\n}\n","export function generatePortFromName({\n name,\n minPort = 3000,\n maxPort = 8000,\n}: {\n name: string;\n minPort?: number;\n maxPort?: number;\n}): number {\n if (!name) {\n throw new Error('Name is required to generate a port');\n }\n\n // hash the name\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n // eslint-disable-next-line no-bitwise\n hash = (hash << 5) - hash + name.charCodeAt(i);\n // Convert to 32-bit\n // eslint-disable-next-line no-bitwise\n hash |= 0;\n }\n hash = Math.abs(hash);\n\n // Map the hash to the port range\n const range = maxPort - minPort;\n const port = minPort + (hash % range);\n\n return port;\n}\n","import type {\n HostConfig as RemoteHostConfigSchema,\n LocalHostConfig as LocalHostConfigSchema,\n} from '../../../bin/types';\nimport { generatePortFromName } from './utils/generate-port';\n\ninterface HostOptions {\n isLocal?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: string;\n port?: number;\n local: boolean | undefined;\n\n constructor(\n hostConfig: RemoteHostConfigSchema | string,\n options?: HostOptions,\n ) {\n if (typeof hostConfig === 'string') {\n ({\n protocol: this.protocol,\n host: this.host,\n port: this.port,\n } = Host.parseUrl(hostConfig));\n } else {\n const { protocol = 'https', host, port } = hostConfig;\n this.protocol = protocol;\n this.host = host;\n this.port = port;\n }\n this.local = options?.isLocal;\n }\n\n protected static parseUrl(\n url: string,\n defaultProtocol = 'https',\n ): {\n protocol: Host['protocol'];\n host: string;\n port?: number;\n } {\n let hostToParse = url;\n if (!/^https?:\\/\\//.exec(hostToParse)) {\n hostToParse = `${defaultProtocol}://${hostToParse}`;\n }\n const parsed = new URL(hostToParse);\n if (!parsed.hostname) {\n throw new Error(Host.getMicrofrontendsError(url, 'requires a host'));\n }\n if (parsed.hash) {\n throw new Error(\n Host.getMicrofrontendsError(url, 'cannot have a fragment'),\n );\n }\n if (parsed.username || parsed.password) {\n throw new Error(\n Host.getMicrofrontendsError(\n url,\n 'cannot have authentication credentials (username and/or password)',\n ),\n );\n }\n if (parsed.pathname !== '/') {\n throw new Error(Host.getMicrofrontendsError(url, 'cannot have a path'));\n }\n if (parsed.search) {\n throw new Error(\n Host.getMicrofrontendsError(url, 'cannot have query parameters'),\n );\n }\n const protocol = parsed.protocol.slice(0, -1) as Host['protocol'];\n return {\n protocol,\n host: parsed.hostname,\n port: parsed.port ? Number.parseInt(parsed.port) : undefined,\n };\n }\n\n private static getMicrofrontendsError(url: string, message: string): string {\n return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;\n }\n\n isLocal(): boolean {\n return this.local || this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n toString(): string {\n const url = this.toUrl();\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(): URL {\n const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ''}`;\n return new URL(url);\n }\n}\n\n/**\n * A Host subclass with defaults for locally running applications\n */\nexport class LocalHost extends Host {\n constructor({\n appName,\n localPort,\n local,\n }: {\n appName: string;\n localPort?: number;\n local?: string | number | LocalHostConfigSchema;\n }) {\n if (localPort && local) {\n throw new Error(\n `Microfrontends configuration error: '${appName}' has both the 'development.local' and 'development.localPort' fields set. Please remove the 'development.localPort' field and ensure the 'development.local' field has the correct port.`,\n );\n }\n let protocol: RemoteHostConfigSchema['protocol'];\n let host: string | undefined;\n let port: number | undefined;\n if (localPort) {\n port = localPort;\n } else if (typeof local === 'number') {\n port = local;\n } else if (typeof local === 'string') {\n if (/^\\d+$/.test(local)) {\n port = Number.parseInt(local);\n } else {\n const parsed = Host.parseUrl(local, 'http');\n protocol = parsed.protocol;\n host = parsed.host;\n port = parsed.port;\n }\n } else if (local) {\n protocol = local.protocol;\n host = local.host;\n port = local.port;\n }\n // set defaults for local\n super({\n protocol: protocol ?? 'http',\n host: host ?? 'localhost',\n port: port ?? generatePortFromName({ name: appName }),\n });\n }\n}\n","export function generateAutomationBypassEnvVarName({\n name,\n}: {\n name: string;\n}): string {\n return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, '_')}`;\n}\n","import type {\n Application as ApplicationConfig,\n DefaultApplication as DefaultApplicationConfig,\n ChildApplication as ChildApplicationConfig,\n PathGroup,\n} from '../../schema/types';\nimport type { ApplicationOverrideConfig } from '../../overrides';\nimport { validateAppPaths } from './validation';\nimport { generateAssetPrefixFromName } from './utils/generate-asset-prefix';\nimport { Host, LocalHost } from './host';\nimport { generateAutomationBypassEnvVarName } from './utils/generate-automation-bypass-env-var-name';\n\nexport class Application {\n readonly default: boolean;\n name: string;\n development: {\n local: LocalHost;\n fallback?: Host;\n };\n fallback?: Host;\n projectId?: string;\n packageName?: string;\n overrides?: {\n environment?: Host;\n };\n readonly serialized: ApplicationConfig;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n isDefault,\n }: {\n app: ApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n isDefault?: boolean;\n },\n ) {\n this.name = name;\n this.development = {\n local: new LocalHost({\n appName: name,\n localPort: app.development?.localPort,\n local: app.development?.local,\n }),\n fallback: app.development?.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n if (app.development?.fallback) {\n this.fallback = new Host(app.development.fallback);\n }\n this.projectId = app.projectId;\n this.packageName = app.packageName;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n this.default = isDefault ?? false;\n this.serialized = app;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n getAssetPrefix(): string {\n return generateAssetPrefixFromName({ name: this.name });\n }\n\n getAutomationBypassEnvVarName(): string {\n return generateAutomationBypassEnvVarName({ name: this.name });\n }\n\n serialize(): ApplicationConfig {\n return this.serialized;\n }\n}\n\nexport class DefaultApplication extends Application {\n readonly default = true;\n fallback: Host;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: DefaultApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n super(name, {\n app,\n overrides,\n isDefault: true,\n });\n\n this.fallback = new Host(app.development.fallback);\n }\n\n getAssetPrefix(): string {\n return '';\n }\n}\n\nexport class ChildApplication extends Application {\n readonly default = false;\n routing: PathGroup[];\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: ChildApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n // validate\n ChildApplication.validate(name, app);\n\n super(name, {\n app,\n overrides,\n isDefault: false,\n });\n\n this.routing = app.routing;\n }\n\n static validate(name: string, app: ChildApplicationConfig): void {\n // validate routes\n validateAppPaths(name, app);\n }\n}\n","export const DEFAULT_LOCAL_PROXY_PORT = 3024;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,oBAA6B;AAC7B,IAAAA,yBAA6B;;;ACJtB,SAAS,oBAA6B;AAC3C,QAAM,YAAY,QAAQ,IAAI,cAAc,mBAAmB;AAE/D,SAAO,YAAY,QAAQ,QAAQ,IAAI,wBAAwB;AACjE;;;ACJA,0BAAsB;;;AC6Ef,IAAM,qBAAN,cAEG,MAAM;AAAA,EAKd,YAAY,SAAiB,MAAqC;AAChE,UAAM,SAAS,EAAE,OAAO,MAAM,MAAM,CAAC;AACrC,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM,UAAU;AAC9B,SAAK,OAAO,MAAM,QAAS;AAC3B,SAAK,UAAU,MAAM;AACrB,UAAM,kBAAkB,MAAM,kBAAkB;AAAA,EAClD;AAAA,EAEA,UAAmB;AACjB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YAAqB;AACnB,WAAO,CAAC,KAAK,QAAQ;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QACL,UACA,MAC4C;AAC5C,QAAI,MAAM,UAAU;AAClB,YAAM,MAAM,mBAAmB,eAAe,UAAU,KAAK,QAAQ;AACrE,UAAI,KAAK;AACP,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QACE,SAAS,QAAQ;AAAA,MACf;AAAA,IACF,GACA;AACA,aAAO,IAAI,mBAAmB,SAAS,SAAS;AAAA,QAC9C,MAAM;AAAA,QACN,SAAS;AAAA,QACT,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAGA,WAAO,I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B,YAAY;AAAA,UACxH;AAAA,QACF;AACA,mBAAW,QAAQ,UAAU,OAAO;AAClC,gBAAM,cAAU,qCAAa,IAAI;AACjC,sBAAY,KAAK;AAAA,YACf,KAAK;AAAA,YACL,IAAI,eAAe;AAAA,cACjB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AASA,eAAsB,4BAA4B;AAAA,EAChD;AAAA,EACA;AACF,GAGkC;AAChC,QAAM,WAAW,QAAQ,QAAQ;AACjC,QAAM,cAAc,4BAA4B;AAAA,IAC9C;AAAA,IACA;AAAA,EACF,CAAC;AAED,aAAW,SAAS,aAAa;AAC/B,QACE,OAAO,MAAM,QAAQ,WACjB,aAAa,MAAM,MACnB,MAAM,IAAI,KAAK,QAAQ,GAC3B;AAEA,YAAM,WAAW,MAAM,MAAM,GAAG,OAAO;AACvC,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":["import_path_to_regexp","import_path_to_regexp","parsePathRegexp"]}
|
package/dist/next/middleware.js
CHANGED
|
@@ -235,8 +235,7 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
235
235
|
if (isDefaultApp(app)) {
|
|
236
236
|
continue;
|
|
237
237
|
}
|
|
238
|
-
const
|
|
239
|
-
for (const pathMatch of childApp.routing) {
|
|
238
|
+
for (const pathMatch of app.routing) {
|
|
240
239
|
for (const path of pathMatch.paths) {
|
|
241
240
|
const maybeError = validatePathExpression(path);
|
|
242
241
|
if (maybeError) {
|
|
@@ -384,64 +383,15 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
384
383
|
};
|
|
385
384
|
var validateDeprecatedFields = (config) => {
|
|
386
385
|
const errors = [];
|
|
387
|
-
if (config.options?.vercel) {
|
|
388
|
-
errors.push(
|
|
389
|
-
`Configuration cannot contain deprecated field 'options.vercel'. Use 'options.disableOverrides' instead.`
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
if (config.options?.localProxy) {
|
|
393
|
-
errors.push(
|
|
394
|
-
`Configuration cannot contain deprecated field 'options.localProxy'. Use 'options.localProxyPort' instead.`
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
386
|
for (const [applicationId, application] of Object.entries(
|
|
398
387
|
config.applications
|
|
399
388
|
)) {
|
|
400
|
-
if (application.vercel) {
|
|
401
|
-
errors.push(
|
|
402
|
-
`Application '${applicationId}' cannot contain deprecated field 'vercel'. Use 'projectId' instead.`
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
if (application.production) {
|
|
406
|
-
errors.push(
|
|
407
|
-
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
389
|
if (application.development?.localPort) {
|
|
411
390
|
errors.push(
|
|
412
391
|
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
413
392
|
);
|
|
414
393
|
}
|
|
415
|
-
if (application.
|
|
416
|
-
const fallback = application.development.fallback;
|
|
417
|
-
let asString = fallback.host;
|
|
418
|
-
if (fallback.protocol) {
|
|
419
|
-
asString = `${fallback.protocol}://${asString}`;
|
|
420
|
-
}
|
|
421
|
-
if (fallback.port) {
|
|
422
|
-
asString = `${asString}:${fallback.port}`;
|
|
423
|
-
}
|
|
424
|
-
errors.push(
|
|
425
|
-
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
429
|
-
const local = application.development.local;
|
|
430
|
-
let asString;
|
|
431
|
-
if (local.port && !local.protocol && !local.host) {
|
|
432
|
-
asString = String(local.port);
|
|
433
|
-
} else {
|
|
434
|
-
asString = local.host ?? "localhost";
|
|
435
|
-
if (local.protocol) {
|
|
436
|
-
asString = `${local.protocol}://${asString}`;
|
|
437
|
-
}
|
|
438
|
-
if (local.port) {
|
|
439
|
-
asString = `${asString}:${local.port}`;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
errors.push(
|
|
443
|
-
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
444
|
-
);
|
|
394
|
+
if (application.projectId) {
|
|
445
395
|
}
|
|
446
396
|
}
|
|
447
397
|
if (errors.length) {
|
|
@@ -596,6 +546,13 @@ var LocalHost = class extends Host {
|
|
|
596
546
|
}
|
|
597
547
|
};
|
|
598
548
|
|
|
549
|
+
// src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts
|
|
550
|
+
function generateAutomationBypassEnvVarName({
|
|
551
|
+
name
|
|
552
|
+
}) {
|
|
553
|
+
return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
554
|
+
}
|
|
555
|
+
|
|
599
556
|
// src/config/microfrontends-config/isomorphic/application.ts
|
|
600
557
|
var Application = class {
|
|
601
558
|
constructor(name, {
|
|
@@ -614,10 +571,8 @@ var Application = class {
|
|
|
614
571
|
};
|
|
615
572
|
if (app.development?.fallback) {
|
|
616
573
|
this.fallback = new Host(app.development.fallback);
|
|
617
|
-
} else if (app.production) {
|
|
618
|
-
this.fallback = new Host(app.production);
|
|
619
574
|
}
|
|
620
|
-
this.projectId = app.projectId
|
|
575
|
+
this.projectId = app.projectId;
|
|
621
576
|
this.packageName = app.packageName;
|
|
622
577
|
this.overrides = overrides?.environment ? {
|
|
623
578
|
environment: new Host(overrides.environment)
|
|
@@ -631,6 +586,9 @@ var Application = class {
|
|
|
631
586
|
getAssetPrefix() {
|
|
632
587
|
return generateAssetPrefixFromName({ name: this.name });
|
|
633
588
|
}
|
|
589
|
+
getAutomationBypassEnvVarName() {
|
|
590
|
+
return generateAutomationBypassEnvVarName({ name: this.name });
|
|
591
|
+
}
|
|
634
592
|
serialize() {
|
|
635
593
|
return this.serialized;
|
|
636
594
|
}
|
|
@@ -646,16 +604,7 @@ var DefaultApplication = class extends Application {
|
|
|
646
604
|
isDefault: true
|
|
647
605
|
});
|
|
648
606
|
this.default = true;
|
|
649
|
-
|
|
650
|
-
if (fallbackHost === void 0) {
|
|
651
|
-
throw new Error(
|
|
652
|
-
"`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
this.fallback = new Host(fallbackHost);
|
|
656
|
-
if (app.production) {
|
|
657
|
-
this.production = new Host(app.production);
|
|
658
|
-
}
|
|
607
|
+
this.fallback = new Host(app.development.fallback);
|
|
659
608
|
}
|
|
660
609
|
getAssetPrefix() {
|
|
661
610
|
return "";
|
|
@@ -692,7 +641,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
692
641
|
}) {
|
|
693
642
|
this.childApplications = {};
|
|
694
643
|
MicrofrontendConfigIsomorphic.validate(config, opts);
|
|
695
|
-
const disableOverrides = config.options?.disableOverrides ??
|
|
644
|
+
const disableOverrides = config.options?.disableOverrides ?? false;
|
|
696
645
|
this.overrides = overrides && !disableOverrides ? overrides : void 0;
|
|
697
646
|
let defaultApplication;
|
|
698
647
|
for (const [appId, appConfig] of Object.entries(config.applications)) {
|
|
@@ -745,7 +694,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
745
694
|
});
|
|
746
695
|
}
|
|
747
696
|
isOverridesDisabled() {
|
|
748
|
-
return this.options?.
|
|
697
|
+
return this.options?.disableOverrides ?? false;
|
|
749
698
|
}
|
|
750
699
|
getConfig() {
|
|
751
700
|
return this.config;
|
|
@@ -783,6 +732,14 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
783
732
|
}
|
|
784
733
|
return app;
|
|
785
734
|
}
|
|
735
|
+
hasApplication(name) {
|
|
736
|
+
try {
|
|
737
|
+
this.getApplication(name);
|
|
738
|
+
return true;
|
|
739
|
+
} catch {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
786
743
|
getApplicationByProjectId(projectId) {
|
|
787
744
|
if (this.defaultApplication.projectId === projectId) {
|
|
788
745
|
return this.defaultApplication;
|
|
@@ -801,7 +758,7 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
801
758
|
* Returns the configured port for the local proxy
|
|
802
759
|
*/
|
|
803
760
|
getLocalProxyPort() {
|
|
804
|
-
return this.config.options?.localProxyPort ??
|
|
761
|
+
return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;
|
|
805
762
|
}
|
|
806
763
|
/**
|
|
807
764
|
* Serializes the class back to the Schema type.
|