@vercel/microfrontends 0.13.0 → 0.14.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/README.md +3 -3
- package/dist/bin/cli.cjs +85 -60
- package/dist/config/client.d.ts +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js.map +1 -1
- package/dist/{index-83133f2d.d.ts → index-bf67a461.d.ts} +3 -10
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.d.ts +1 -1
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +0 -29
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +0 -29
- package/dist/next/middleware.js.map +1 -1
- package/dist/{types-a995174e.d.ts → types-a29d224a.d.ts} +1 -7
- package/dist/{types-15b7f215.d.ts → types-cfe3308b.d.ts} +1 -1
- package/dist/types-fc30696d.d.ts +11 -0
- package/dist/utils/mfe-port.cjs +70 -56
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +67 -53
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/v2/config.cjs +0 -14
- package/dist/v2/config.cjs.map +1 -1
- package/dist/v2/config.d.ts +4 -3
- package/dist/v2/config.js +0 -14
- package/dist/v2/config.js.map +1 -1
- package/dist/v2/microfrontends/server.cjs +68 -54
- package/dist/v2/microfrontends/server.cjs.map +1 -1
- package/dist/v2/microfrontends/server.d.ts +6 -5
- package/dist/v2/microfrontends/server.js +65 -51
- package/dist/v2/microfrontends/server.js.map +1 -1
- package/dist/v2/microfrontends.cjs +0 -14
- package/dist/v2/microfrontends.cjs.map +1 -1
- package/dist/v2/microfrontends.d.ts +4 -3
- package/dist/v2/microfrontends.js +0 -14
- package/dist/v2/microfrontends.js.map +1 -1
- package/dist/v2/next/client.cjs +1 -1
- package/dist/v2/next/client.cjs.map +1 -1
- package/dist/v2/next/client.js +1 -1
- package/dist/v2/next/client.js.map +1 -1
- package/dist/v2/next/config.cjs +106 -60
- package/dist/v2/next/config.cjs.map +1 -1
- package/dist/v2/next/config.js +103 -57
- package/dist/v2/next/config.js.map +1 -1
- package/dist/v2/next/endpoints.cjs.map +1 -1
- package/dist/v2/next/endpoints.d.ts +13 -2
- package/dist/v2/next/endpoints.js.map +1 -1
- package/dist/v2/next/middleware.cjs +10 -54
- package/dist/v2/next/middleware.cjs.map +1 -1
- package/dist/v2/next/middleware.d.ts +7 -2
- package/dist/v2/next/middleware.js +10 -54
- package/dist/v2/next/middleware.js.map +1 -1
- package/dist/v2/next/testing.cjs +992 -0
- package/dist/v2/next/testing.cjs.map +1 -0
- package/dist/v2/next/testing.d.ts +55 -0
- package/dist/v2/next/testing.js +961 -0
- package/dist/v2/next/testing.js.map +1 -0
- package/dist/v2/overrides.d.ts +3 -3
- package/dist/v2/routing.cjs +19 -0
- package/dist/v2/routing.cjs.map +1 -0
- package/dist/v2/routing.d.ts +26 -0
- package/dist/v2/routing.js +1 -0
- package/dist/v2/routing.js.map +1 -0
- package/dist/v2/schema.cjs.map +1 -1
- package/dist/v2/schema.d.ts +1 -1
- package/dist/validation.cjs +0 -4
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +0 -6
- package/dist/validation.js +0 -4
- package/dist/validation.js.map +1 -1
- package/package.json +20 -5
- package/schema/schema-v2.json +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/middleware/middleware.ts","../../src/config/edge/microfrontend-config.ts","../../src/config/errors.ts","../../src/routing/url.ts","../../src/config/overrides/config.ts","../../src/config/common/host.ts","../../src/config/common/application.ts","../../src/config/common/microfrontend-config.ts","../../src/routing/get-domain-for-current-environment.ts"],"sourcesContent":["/// <reference types=\"@edge-runtime/types\" />\n\nimport type { NextRequest } from 'next/server';\nimport { NextResponse } from 'next/server';\nimport { pathToRegexp } from 'path-to-regexp';\nimport { MicrofrontendConfigEdge } from '../../config/edge/microfrontend-config';\nimport { getDomainForCurrentEnvironment } from '../../routing/get-domain-for-current-environment';\nimport type { Application } from '../../config/common/application';\nimport type { HostConfig } from '../../config/schema';\nimport type {\n MicrofrontendsMiddleware,\n MicrofrontendsMiddlewareHandler,\n} from './types';\n\ninterface GetHandlerParams {\n application: Application;\n flagFn?: () => Promise<boolean>;\n pattern: RegExp;\n}\n\ninterface InternalRouting {\n routing: HostConfig;\n}\n\nasync function verifyPreviewDomain(\n req: NextRequest,\n rewriteDomain: string,\n): Promise<boolean> {\n const jwtCookie = req.cookies.get('_vercel_jwt')?.value;\n const deploymentProtectionBypassHeader = req.headers.get(\n 'x-vercel-protection-bypass',\n );\n\n // We make a `HEAD` request with `x-vercel-micro-frontends-check: 1` which will get handled in the proxy without reaching the deployment\n const previewResponse = await fetch(rewriteDomain, {\n method: 'HEAD',\n headers: {\n 'x-vercel-micro-frontends-check': '1',\n ...(jwtCookie ? { cookie: `_vercel_jwt=${jwtCookie}` } : {}),\n ...(deploymentProtectionBypassHeader\n ? {\n 'x-vercel-protection-bypass': deploymentProtectionBypassHeader,\n }\n : {}),\n },\n });\n\n const vercelError = previewResponse.headers.get('x-vercel-error');\n return !(\n previewResponse.status === 404 &&\n (vercelError === 'DEPLOYMENT_NOT_FOUND' || vercelError === 'NOT_FOUND')\n );\n}\n\nfunction microfrontendInternalRoutingHandler({\n config,\n}: { config: MicrofrontendConfigEdge }): MicrofrontendsMiddlewareHandler {\n return async (req: NextRequest): Promise<NextResponse> => {\n const payload: Record<string, InternalRouting> = Object.fromEntries(\n await Promise.all(\n config.getAllApplications().map(async (application) => {\n let rewriteDomain = getDomainForCurrentEnvironment(application, {\n ignoreOverride: true,\n });\n const isPreviewDomainAvailable = await verifyPreviewDomain(\n req,\n rewriteDomain,\n );\n\n if (!isPreviewDomainAvailable) {\n rewriteDomain = application.production.toString();\n }\n\n const url = new URL(rewriteDomain);\n return [application.name, { routing: { host: url.host } }] as const;\n }),\n ),\n );\n\n return NextResponse.json(payload);\n };\n}\n\nfunction getHandler({\n application,\n flagFn,\n pattern,\n}: GetHandlerParams): MicrofrontendsMiddlewareHandler {\n return async (req: NextRequest): Promise<NextResponse | undefined> => {\n const pathname = req.nextUrl.pathname;\n const search = req.nextUrl.search;\n\n // If this header is present, it means the proxy handled the routing.\n // Eventually the middleware should use proxy logic for all deployed envs (all except local)\n const proxyRouting = req.headers.get('X-Vercel-Mfe-Proxy') === '1';\n\n let rewriteDomain = proxyRouting\n ? null\n : getDomainForCurrentEnvironment(application);\n const patchedHeaders = new Headers(req.headers);\n\n const responseCallbacks: ((response: NextResponse) => void)[] = [];\n const onRewrite: (response: NextResponse) => NextResponse = (response) => {\n for (const callback of responseCallbacks) {\n callback(response);\n }\n\n return response;\n };\n\n // If this is a preview environment, we check the domain to make sure the project was deployed\n if (process.env.VERCEL_ENV === 'preview' && rewriteDomain) {\n const zoneFallbackCookieName = `__zone_${application.name}_production_fallback`;\n const assetPrefix = application.routing?.assetPrefix;\n\n if (\n assetPrefix &&\n pathname.startsWith(`/${assetPrefix}`) &&\n req.cookies.get(zoneFallbackCookieName)?.value === '1'\n ) {\n // If this is an asset request and we have the cookie, we can safely route to production without fetching\n rewriteDomain = application.production.toString();\n } else {\n try {\n let deploymentFound: boolean;\n if (req.headers.get('x-vercel-skip-deployment-existence-check')) {\n deploymentFound = true;\n } else {\n deploymentFound = await verifyPreviewDomain(req, rewriteDomain);\n }\n\n if (!deploymentFound) {\n // If the deployment is not found, we rewrite to the production domain\n rewriteDomain = application.production.toString();\n\n // We set a 1 minute cookie for the application to avoid checking again for every request\n responseCallbacks.push((response) => {\n response.cookies.set(zoneFallbackCookieName, '1', {\n httpOnly: true,\n sameSite: 'lax',\n secure: true,\n maxAge: 60, // 1 minute\n });\n });\n\n // When routing to a production url, we need to enable the toolbar manually,\n // since production deployments rely on the extension to do that, but the extension can't match the top-level domain\n try {\n const existingCookie = patchedHeaders.get('cookie');\n\n // If the request doesn't contain the toolbar cookie, we add it to support the middleware injection\n if (!existingCookie?.includes('__vercel_toolbar')) {\n patchedHeaders.set(\n 'cookie',\n [`__vercel_toolbar=1`, existingCookie].join('; '),\n );\n\n // We also return a `set-cookie` header to set the cookie locally, to support the Next.js injection which checks the document\n responseCallbacks.push((response) => {\n response.cookies.set('__vercel_toolbar', '1', {\n httpOnly: false,\n sameSite: 'lax',\n secure: true,\n maxAge: 29030400,\n });\n });\n }\n } catch (error) {\n // Do Nothing\n }\n } else if (req.cookies.get(zoneFallbackCookieName)?.value === '1') {\n // If the preview exists and we have the fallback cookie, we make sure to clear the cookie to route subsequent assets to the preview\n responseCallbacks.push((response) => {\n response.cookies.set(zoneFallbackCookieName, '', {\n httpOnly: true,\n sameSite: 'lax',\n secure: true,\n maxAge: 0,\n });\n });\n }\n } catch {\n // Do Nothing\n }\n }\n }\n\n const isFlagEnabled = async (): Promise<boolean> =>\n flagFn ? flagFn() : true;\n\n // If the pattern doesn't match, we don't need to execute the flag\n if (pattern.test(pathname) && (await isFlagEnabled())) {\n if (proxyRouting) {\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 return onRewrite(\n NextResponse.next({\n request: {\n headers,\n },\n headers: {\n // temporary, can delete when proxyRouting flag is removed\n 'x-vercel-mfe-middleware-sent-proxy': application.name,\n },\n }),\n );\n }\n return onRewrite(\n NextResponse.rewrite(`${rewriteDomain}${pathname}${search}`, {\n request: {\n headers: patchedHeaders,\n },\n }),\n );\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 microfrontends for the provided configuration.\n *\n * @param config - The microfrontends 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 config = MicrofrontendConfigEdge.fromEnv({\n cookies: request.cookies.getAll(),\n });\n const middlewares: MicrofrontendsMiddleware[] = [];\n\n middlewares.push({\n src: '/.well-known/vercel/microfrontend-routing',\n fn: microfrontendInternalRoutingHandler({ config }),\n });\n\n for (const application of config.getAllApplications()) {\n if (application.name === process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION) {\n continue;\n }\n if (application.routing) {\n if (\n process.env.VERCEL_ENV === 'preview' &&\n application.routing.assetPrefix\n ) {\n const pattern = pathToRegexp(\n `/${application.routing.assetPrefix}/:path+`,\n );\n middlewares.push({\n src: pattern,\n fn: getHandler({\n application,\n pattern,\n }),\n });\n }\n for (const pathGroup of application.routing.matches) {\n if (process.env.VERCEL_ENV === 'preview' || pathGroup.options?.flag) {\n const flagName = pathGroup.options?.flag;\n // biome-ignore lint/suspicious/noImplicitAnyLet: Ignored using `--suppress`\n let flagFn;\n if (flagName) {\n 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 }\n for (const path of pathGroup.paths) {\n const pattern = pathToRegexp(path);\n middlewares.push({\n src: pattern,\n fn: getHandler({\n application,\n flagFn,\n pattern,\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 microfrontends 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: 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","/// <reference types=\"@edge-runtime/types\" />\n\nimport { parse } from 'jsonc-parser';\nimport { MicrofrontendConfigCommon } from '../common/microfrontend-config';\nimport type { Config } from '../schema';\nimport { Overrides } from '../overrides';\n\n/**\n * Edge Runtime does not support ajv validation, or fs access.\n * This version of the MicrofrontendConfig does not validate the config shape,\n * and requires the config to be set on the environment.\n *\n * It should be used for Next.js middleware which runs in the Edge Runtime.\n */\nexport class MicrofrontendConfigEdge extends MicrofrontendConfigCommon {\n static fromEnv({\n cookies,\n }: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfigEdge {\n return new MicrofrontendConfigCommon({\n config: parse(MicrofrontendConfigCommon.getConfigFromEnv()) as Config,\n overrides: Overrides.parseOverrides(cookies),\n });\n }\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'zone'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\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 zone:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\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 | '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 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);\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","// NOTE: This is copied from https://github.com/vercel/api/blob/main/packages/util-func/src/url-safe-string.ts.\n// See https://linear.app/vercel/issue/FDRTN-199/spike-move-preview-domain-generation-logic-into-build-and-deploy\n// for cleaning this up before release.\n\ninterface Options {\n joinString?: string;\n lowercaseOnly?: boolean;\n maxLen?: number;\n regexRemovePattern?: RegExp;\n trimWhitespace?: boolean;\n}\n\n/**\n * This function allows to convert single string to URL-safe tags to use for routing,\n * SEO purposes, etc. It is taken from https://www.npmjs.com/package/url-safe-string\n * and implemented here to be typed and skip the dependency.\n */\nfunction buildUrlSafeString(givenOpts: Options = {}): {\n generate: (...args: string[]) => string;\n} {\n const options = {\n joinString: '-',\n lowercaseOnly: true,\n maxLen: 100,\n regexRemovePattern: /(?:(?!(?:[a-z0-9])).)/gi,\n trimWhitespace: true,\n ...givenOpts,\n };\n\n return {\n generate: (...args: string[]) => {\n const reJoinString = new RegExp(`${options.joinString}+`, 'g');\n\n // biome-ignore lint/suspicious/noImplicitAnyLet: Ignored using `--suppress`\n let tag;\n\n if (args.length === 0) {\n throw new Error('generate method must be passed at least one argument');\n }\n\n // Validate, trim all arguments:\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (typeof arg !== 'string')\n throw new Error('all supplied arguments must be Strings');\n\n if (options.trimWhitespace) {\n args[i] = arg.trim();\n }\n }\n\n // Join strings and convert whitespace between words to join string\n tag = args.join(options.joinString);\n tag = tag.replace(/\\s/g, options.joinString);\n if (options.lowercaseOnly) tag = tag.toLowerCase();\n // Regex away anything \"unsafe\", but ignore the join string!\n tag = tag.replace(options.regexRemovePattern, (match) => {\n if (match === options.joinString) return match;\n\n return '';\n });\n\n // Truncate in excess of maxLen\n if (tag.length > options.maxLen) tag = tag.substring(0, options.maxLen);\n\n // Remove any duplicates of the join string using this pattern: /<join string>+/g\n tag = tag.replace(reJoinString, options.joinString);\n\n return tag;\n },\n };\n}\n\n/**\n * Export a preconfigured version for convenience.\n */\nexport const urlSafeString = buildUrlSafeString().generate;\n\nexport function makeUrlSafe(name: string): string {\n return urlSafeString(name.replace(/\\//g, '-'))\n .replace(/^-*/g, '')\n .replace(/-*$/g, '');\n}\n","import { makeUrlSafe } from '../../routing/url';\nimport type { MicrofrontendConfig } from '../microfrontend-config';\nimport type { OverridesConfig } from './types';\n\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\n\nexport class Overrides {\n config: OverridesConfig;\n\n constructor(config: OverridesConfig) {\n this.config = config;\n }\n\n static overrideEnvCookiePrefix = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n\n static getAppEnvOverrideCookieName(zone: string): string {\n return `${Overrides.overrideEnvCookiePrefix}${zone}`;\n }\n\n static isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n }\n\n static getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n }): { zone: string; host: string } | undefined {\n if (!Overrides.isOverrideCookie(cookie) || !cookie.value) return;\n return {\n zone: cookie.name.replace(Overrides.overrideEnvCookiePrefix, ''),\n host: cookie.value,\n };\n }\n\n static parseOverrides(\n cookies: { name: string; value?: string | null }[],\n ): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = Overrides.getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.zone] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n }\n\n static validOverrideDomainsForZone(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n ): string[] {\n const projectName = microfrontendConfig.getZone(zone).vercel?.projectName;\n if (!projectName) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n const parsedProjectName = makeUrlSafe(projectName);\n const previewDeploymentSuffix =\n microfrontendConfig.options?.vercel?.previewDeploymentSuffix;\n const teamSlug = microfrontendConfig.options?.vercel?.teamSlug;\n if (!teamSlug && !previewDeploymentSuffix) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n\n const suffix = previewDeploymentSuffix\n ? `.${previewDeploymentSuffix}`\n : `-${teamSlug}.vercel.app`;\n\n // <project-name>-git-<branch-name>-<scope-slug>.vercel.app\n // <project-name>-git-<branch-name>.<custom-suffix>\n return [\n `${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,\n microfrontendConfig.getZone(zone).production.host,\n ];\n }\n\n static validateOverrideDomain(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n domain: string,\n ): boolean {\n return new RegExp(\n `^${Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(\n '|',\n )}$`,\n ).test(domain);\n }\n\n serialize(): OverridesConfig {\n return this.config;\n }\n}\n","import type { HostConfig } from '../schema';\n\ninterface HostDisplayOptions {\n includeDefaultPort?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: HostConfig['host'];\n port: number;\n serialized: HostConfig;\n\n constructor({ protocol, host, port }: HostConfig) {\n this.protocol = protocol || 'https';\n this.host = host;\n this.port = Host.getPort({ port, protocol: this.protocol });\n this.serialized = {\n protocol,\n host,\n ...(port ? { port } : undefined),\n };\n }\n\n isLocal(): boolean {\n return this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n static getPort({\n protocol,\n port,\n }: { protocol: HostConfig['protocol']; port?: HostConfig['port'] }): number {\n if (!port) {\n if (protocol === 'http') {\n return 80;\n }\n return 443;\n }\n\n return port;\n }\n\n isDefaultPort(): boolean {\n return this.port === Host.getPort({ protocol: this.protocol });\n }\n\n toString(opts: HostDisplayOptions = {}): string {\n const url = this.toUrl(opts);\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(opts: HostDisplayOptions = {}): URL {\n const { includeDefaultPort } = opts;\n const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? '' : `:${this.port}`}`;\n\n return new URL(url);\n }\n\n serialize(): HostConfig {\n return this.serialized;\n }\n}\n","import type { ApplicationConfig, Routing, Vercel } from '../schema';\nimport type { ApplicationOverrideConfig } from '../overrides';\nimport { MicrofrontendError } from '../errors';\nimport { Host } from './host';\n\nexport class Application {\n default: boolean;\n routing?: Routing;\n name: string;\n development: {\n local: Host;\n fallback?: Host;\n };\n production: Host;\n vercel?: Vercel;\n overrides?: {\n environment?: Host;\n };\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: { app: ApplicationConfig; overrides?: ApplicationOverrideConfig },\n ) {\n // validate\n Application.validate(name, app);\n\n this.name = name;\n this.default = app.default;\n this.routing = app.routing;\n this.development = {\n local: new Host(app.development.local),\n fallback: app.development.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n this.production = new Host(app.production);\n this.vercel = app.vercel;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n static validate(name: string, app: ApplicationConfig): void {\n // validate assetPrefix\n if (\n app.routing?.assetPrefix?.startsWith('/') ||\n app.routing?.assetPrefix?.endsWith('/')\n ) {\n throw new MicrofrontendError(\n `Invalid assetPrefix for application \"${name}\". Must not start or end with a slash.`,\n { type: 'zone', subtype: 'invalid_asset_prefix' },\n );\n }\n\n // validate routes\n for (const group of app.routing?.matches ?? []) {\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: 'zone', 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: 'zone', subtype: 'invalid_path' },\n );\n }\n }\n }\n }\n\n serialize(): ApplicationConfig {\n if (this.routing === undefined || this.default) {\n return {\n default: true,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n\n return {\n default: false,\n routing: this.routing,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n}\n","import type { ApplicationConfig, Config, Options } from '../schema';\nimport { MicrofrontendError } from '../errors';\nimport type { OverridesConfig } from '../overrides';\nimport { Overrides } from '../overrides/config';\nimport { Application } from './application';\n\nconst SUPPORTED_VERSIONS = ['1'];\nconst DEFAULT_LOCAL_PROXY_PORT = 3024;\n\n/**\n * A class to manage the microfrontends configuration.\n *\n * This class should not be used directly. Instead, use the `MicrofrontendConfig` or `MicrofrontendConfigEdgeRuntime` classes.\n */\nexport class MicrofrontendConfigCommon {\n config: Config;\n name?: string;\n zones: Record<string, Application> = {};\n version: string;\n overrides?: Overrides;\n options?: Options;\n $schema: string | undefined;\n\n constructor({\n config,\n overrides,\n }: { config: Config; overrides?: OverridesConfig }) {\n if (!SUPPORTED_VERSIONS.includes(config.version)) {\n throw new MicrofrontendError(\n `Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(\n ', ',\n )}`,\n { type: 'config', subtype: 'unsupported_version' },\n );\n }\n const disableOverrides = config.options?.vercel?.disableOverrides ?? false;\n\n this.overrides =\n overrides && !disableOverrides ? new Overrides(overrides) : undefined;\n\n // create zones\n for (const [zoneName, zoneConfig] of Object.entries(config.applications)) {\n this.zones[zoneName] = new Application(zoneName, {\n app: zoneConfig,\n overrides: !disableOverrides\n ? this.overrides?.config.applications[zoneName]\n : undefined,\n });\n }\n\n this.config = config;\n this.name = config.name;\n this.version = config.version;\n this.options = config.options;\n this.$schema = config.$schema;\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n protected static getConfigFromEnv(): 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\n static fromEnv(_: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfigCommon | Promise<MicrofrontendConfigCommon> {\n throw new Error('Not implemented');\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getAllApplications(): Application[] {\n return Object.values(this.zones);\n }\n\n getZone(name: string): Application {\n const zone = this.zones[name];\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n getApplicationByProjectId(projectId: string): Application | undefined {\n return Object.values(this.zones).find(\n (zone) => zone.vercel?.projectId === projectId,\n );\n }\n\n getDefaultZone(): Application {\n const zone = Object.values(this.zones).find((z) => z.default);\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find default zone in microfrontends configuration`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return this.config.options?.localProxy?.port ?? 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 const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n $schema: this.$schema,\n name: this.name,\n version: this.version,\n options: this.options,\n applications,\n };\n }\n\n serialize(): { config: Config; overrides?: OverridesConfig } {\n const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n config: {\n name: this.name,\n version: this.version,\n applications,\n options: this.options,\n $schema: this.$schema,\n },\n overrides: this.overrides?.serialize(),\n };\n }\n\n write(_: string): void {\n throw new MicrofrontendError(\n `Writing to file to disk requires using an instance of \"MicrofrontendConfig\".`,\n { type: 'config', subtype: 'unsupported_operation' },\n );\n }\n}\n","/// <reference types=\"@edge-runtime/types\" />\n\nimport type { Application } from '../config/common/application';\n\nfunction debugDomains(zone: string, env: string, domain: string): void {\n if (process.env.MFE_DEBUG === 'true') {\n const indent = ' '.repeat(4);\n const header = 'domains (zone (env) -> domain)';\n const separator = '⎯'.repeat(header.length);\n const line = `${indent} 1. ${zone} (${env}) -> ${domain}`;\n\n // eslint-disable-next-line no-console\n console.log(`${indent}${header}\\n${indent}${separator}\\n${line}\\n`);\n }\n}\n\n/**\n * Returns the Vercel domain for the given application based on the current\n * environment (local, preview, production).\n */\nexport function getDomainForCurrentEnvironment(\n zone: Application,\n opts: { ignoreOverride?: boolean } = {},\n): string {\n if (!opts.ignoreOverride && zone.overrides?.environment) {\n return zone.overrides.environment.toString();\n }\n const zoneName = zone.name;\n if (!process.env.VERCEL_ENV || process.env.VERCEL_ENV === 'development') {\n // TODO(mknichel): Convert this back to the local development domain once\n // there is local development proxy support.\n const domain =\n process.env.NODE_ENV === 'test'\n ? zone.development.local.toString()\n : zone.production.toString();\n debugDomains(zoneName, 'development', domain);\n return domain;\n } else if (process.env.VERCEL_ENV === 'production') {\n const domain = zone.production.toString();\n debugDomains(zoneName, 'production', domain);\n return domain;\n } else if (process.env.VERCEL_ENV === 'preview') {\n const MFE_PREVIEW_DOMAINS = JSON.parse(\n process.env.MFE_PREVIEW_DOMAINS ?? '{}',\n ) as Record<string, string>;\n if (MFE_PREVIEW_DOMAINS[zoneName]) {\n debugDomains(zoneName, 'preview', MFE_PREVIEW_DOMAINS[zoneName]);\n return MFE_PREVIEW_DOMAINS[zoneName];\n }\n\n throw new Error(\n `Could not find preview domain for application \"${zoneName}\"`,\n );\n }\n // TODO(mknichel): Add support in this function for custom environments.\n // Custom Vercel environments may have an arbitrary string for `VERCEL_ENV`.\n debugDomains(zoneName, process.env.VERCEL_ENV, zone.production.toString());\n return zone.production.toString();\n}\n"],"mappings":";AAGA,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;;;ACF7B,SAAS,aAAa;;;ACuEf,IAAM,qBAAN,cAEG,MAAM;AAAA,EAKd,YAAY,SAAiB,MAAqC;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAS,6BAAM,WAAU;AAC9B,SAAK,QAAO,6BAAM,SAAS;AAC3B,SAAK,UAAU,6BAAM;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,6BAAM,UAAU;AAClB,YAAM,MAAM,mBAAmB,eAAe,UAAU,KAAK,QAAQ;AACrE,UAAI,KAAK;AACP,eAAO;AAAA,MACT;A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ACA;AAAA,cACF,CAAC;AAAA,YACH,CAAC;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AASA,eAAsB,4BACpB,SACA,YAC+B;AAC/B,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":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/next/middleware/middleware.ts","../../src/config/edge/microfrontend-config.ts","../../src/config/errors.ts","../../src/routing/url.ts","../../src/config/overrides/config.ts","../../src/config/common/host.ts","../../src/config/common/application.ts","../../src/config/common/microfrontend-config.ts","../../src/routing/get-domain-for-current-environment.ts"],"sourcesContent":["/// <reference types=\"@edge-runtime/types\" />\n\nimport type { NextRequest } from 'next/server';\nimport { NextResponse } from 'next/server';\nimport { pathToRegexp } from 'path-to-regexp';\nimport { MicrofrontendConfigEdge } from '../../config/edge/microfrontend-config';\nimport { getDomainForCurrentEnvironment } from '../../routing/get-domain-for-current-environment';\nimport type { Application } from '../../config/common/application';\nimport type {\n MicrofrontendsMiddleware,\n MicrofrontendsMiddlewareHandler,\n} from './types';\n\ninterface GetHandlerParams {\n application: Application;\n flagFn?: () => Promise<boolean>;\n pattern: RegExp;\n}\n\nasync function verifyPreviewDomain(\n req: NextRequest,\n rewriteDomain: string,\n): Promise<boolean> {\n const jwtCookie = req.cookies.get('_vercel_jwt')?.value;\n const deploymentProtectionBypassHeader = req.headers.get(\n 'x-vercel-protection-bypass',\n );\n\n // We make a `HEAD` request with `x-vercel-micro-frontends-check: 1` which will get handled in the proxy without reaching the deployment\n const previewResponse = await fetch(rewriteDomain, {\n method: 'HEAD',\n headers: {\n 'x-vercel-micro-frontends-check': '1',\n ...(jwtCookie ? { cookie: `_vercel_jwt=${jwtCookie}` } : {}),\n ...(deploymentProtectionBypassHeader\n ? {\n 'x-vercel-protection-bypass': deploymentProtectionBypassHeader,\n }\n : {}),\n },\n });\n\n const vercelError = previewResponse.headers.get('x-vercel-error');\n return !(\n previewResponse.status === 404 &&\n (vercelError === 'DEPLOYMENT_NOT_FOUND' || vercelError === 'NOT_FOUND')\n );\n}\n\nfunction getHandler({\n application,\n flagFn,\n pattern,\n}: GetHandlerParams): MicrofrontendsMiddlewareHandler {\n return async (req: NextRequest): Promise<NextResponse | undefined> => {\n const pathname = req.nextUrl.pathname;\n const search = req.nextUrl.search;\n\n // If this header is present, it means the proxy handled the routing.\n // Eventually the middleware should use proxy logic for all deployed envs (all except local)\n const proxyRouting = req.headers.get('X-Vercel-Mfe-Proxy') === '1';\n\n let rewriteDomain = proxyRouting\n ? null\n : getDomainForCurrentEnvironment(application);\n const patchedHeaders = new Headers(req.headers);\n\n const responseCallbacks: ((response: NextResponse) => void)[] = [];\n const onRewrite: (response: NextResponse) => NextResponse = (response) => {\n for (const callback of responseCallbacks) {\n callback(response);\n }\n\n return response;\n };\n\n // If this is a preview environment, we check the domain to make sure the project was deployed\n if (process.env.VERCEL_ENV === 'preview' && rewriteDomain) {\n const zoneFallbackCookieName = `__zone_${application.name}_production_fallback`;\n const assetPrefix = application.routing?.assetPrefix;\n\n if (\n assetPrefix &&\n pathname.startsWith(`/${assetPrefix}`) &&\n req.cookies.get(zoneFallbackCookieName)?.value === '1'\n ) {\n // If this is an asset request and we have the cookie, we can safely route to production without fetching\n rewriteDomain = application.production.toString();\n } else {\n try {\n let deploymentFound: boolean;\n if (req.headers.get('x-vercel-skip-deployment-existence-check')) {\n deploymentFound = true;\n } else {\n deploymentFound = await verifyPreviewDomain(req, rewriteDomain);\n }\n\n if (!deploymentFound) {\n // If the deployment is not found, we rewrite to the production domain\n rewriteDomain = application.production.toString();\n\n // We set a 1 minute cookie for the application to avoid checking again for every request\n responseCallbacks.push((response) => {\n response.cookies.set(zoneFallbackCookieName, '1', {\n httpOnly: true,\n sameSite: 'lax',\n secure: true,\n maxAge: 60, // 1 minute\n });\n });\n\n // When routing to a production url, we need to enable the toolbar manually,\n // since production deployments rely on the extension to do that, but the extension can't match the top-level domain\n try {\n const existingCookie = patchedHeaders.get('cookie');\n\n // If the request doesn't contain the toolbar cookie, we add it to support the middleware injection\n if (!existingCookie?.includes('__vercel_toolbar')) {\n patchedHeaders.set(\n 'cookie',\n [`__vercel_toolbar=1`, existingCookie].join('; '),\n );\n\n // We also return a `set-cookie` header to set the cookie locally, to support the Next.js injection which checks the document\n responseCallbacks.push((response) => {\n response.cookies.set('__vercel_toolbar', '1', {\n httpOnly: false,\n sameSite: 'lax',\n secure: true,\n maxAge: 29030400,\n });\n });\n }\n } catch (error) {\n // Do Nothing\n }\n } else if (req.cookies.get(zoneFallbackCookieName)?.value === '1') {\n // If the preview exists and we have the fallback cookie, we make sure to clear the cookie to route subsequent assets to the preview\n responseCallbacks.push((response) => {\n response.cookies.set(zoneFallbackCookieName, '', {\n httpOnly: true,\n sameSite: 'lax',\n secure: true,\n maxAge: 0,\n });\n });\n }\n } catch {\n // Do Nothing\n }\n }\n }\n\n const isFlagEnabled = async (): Promise<boolean> =>\n flagFn ? flagFn() : true;\n\n // If the pattern doesn't match, we don't need to execute the flag\n if (pattern.test(pathname) && (await isFlagEnabled())) {\n if (proxyRouting) {\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 return onRewrite(\n NextResponse.next({\n request: {\n headers,\n },\n headers: {\n // temporary, can delete when proxyRouting flag is removed\n 'x-vercel-mfe-middleware-sent-proxy': application.name,\n },\n }),\n );\n }\n return onRewrite(\n NextResponse.rewrite(`${rewriteDomain}${pathname}${search}`, {\n request: {\n headers: patchedHeaders,\n },\n }),\n );\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 microfrontends for the provided configuration.\n *\n * @param config - The microfrontends 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 config = MicrofrontendConfigEdge.fromEnv({\n cookies: request.cookies.getAll(),\n });\n const middlewares: MicrofrontendsMiddleware[] = [];\n\n for (const application of config.getAllApplications()) {\n if (application.name === process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION) {\n continue;\n }\n if (application.routing) {\n if (\n process.env.VERCEL_ENV === 'preview' &&\n application.routing.assetPrefix\n ) {\n const pattern = pathToRegexp(\n `/${application.routing.assetPrefix}/:path+`,\n );\n middlewares.push({\n src: pattern,\n fn: getHandler({\n application,\n pattern,\n }),\n });\n }\n for (const pathGroup of application.routing.matches) {\n if (process.env.VERCEL_ENV === 'preview' || pathGroup.options?.flag) {\n const flagName = pathGroup.options?.flag;\n // biome-ignore lint/suspicious/noImplicitAnyLet: Ignored using `--suppress`\n let flagFn;\n if (flagName) {\n 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 }\n for (const path of pathGroup.paths) {\n const pattern = pathToRegexp(path);\n middlewares.push({\n src: pattern,\n fn: getHandler({\n application,\n flagFn,\n pattern,\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 microfrontends 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: 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","/// <reference types=\"@edge-runtime/types\" />\n\nimport { parse } from 'jsonc-parser';\nimport { MicrofrontendConfigCommon } from '../common/microfrontend-config';\nimport type { Config } from '../schema';\nimport { Overrides } from '../overrides';\n\n/**\n * Edge Runtime does not support ajv validation, or fs access.\n * This version of the MicrofrontendConfig does not validate the config shape,\n * and requires the config to be set on the environment.\n *\n * It should be used for Next.js middleware which runs in the Edge Runtime.\n */\nexport class MicrofrontendConfigEdge extends MicrofrontendConfigCommon {\n static fromEnv({\n cookies,\n }: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfigEdge {\n return new MicrofrontendConfigCommon({\n config: parse(MicrofrontendConfigCommon.getConfigFromEnv()) as Config,\n overrides: Overrides.parseOverrides(cookies),\n });\n }\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'zone'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\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 zone:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\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 | '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 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);\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","// NOTE: This is copied from https://github.com/vercel/api/blob/main/packages/util-func/src/url-safe-string.ts.\n// See https://linear.app/vercel/issue/FDRTN-199/spike-move-preview-domain-generation-logic-into-build-and-deploy\n// for cleaning this up before release.\n\ninterface Options {\n joinString?: string;\n lowercaseOnly?: boolean;\n maxLen?: number;\n regexRemovePattern?: RegExp;\n trimWhitespace?: boolean;\n}\n\n/**\n * This function allows to convert single string to URL-safe tags to use for routing,\n * SEO purposes, etc. It is taken from https://www.npmjs.com/package/url-safe-string\n * and implemented here to be typed and skip the dependency.\n */\nfunction buildUrlSafeString(givenOpts: Options = {}): {\n generate: (...args: string[]) => string;\n} {\n const options = {\n joinString: '-',\n lowercaseOnly: true,\n maxLen: 100,\n regexRemovePattern: /(?:(?!(?:[a-z0-9])).)/gi,\n trimWhitespace: true,\n ...givenOpts,\n };\n\n return {\n generate: (...args: string[]) => {\n const reJoinString = new RegExp(`${options.joinString}+`, 'g');\n\n // biome-ignore lint/suspicious/noImplicitAnyLet: Ignored using `--suppress`\n let tag;\n\n if (args.length === 0) {\n throw new Error('generate method must be passed at least one argument');\n }\n\n // Validate, trim all arguments:\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (typeof arg !== 'string')\n throw new Error('all supplied arguments must be Strings');\n\n if (options.trimWhitespace) {\n args[i] = arg.trim();\n }\n }\n\n // Join strings and convert whitespace between words to join string\n tag = args.join(options.joinString);\n tag = tag.replace(/\\s/g, options.joinString);\n if (options.lowercaseOnly) tag = tag.toLowerCase();\n // Regex away anything \"unsafe\", but ignore the join string!\n tag = tag.replace(options.regexRemovePattern, (match) => {\n if (match === options.joinString) return match;\n\n return '';\n });\n\n // Truncate in excess of maxLen\n if (tag.length > options.maxLen) tag = tag.substring(0, options.maxLen);\n\n // Remove any duplicates of the join string using this pattern: /<join string>+/g\n tag = tag.replace(reJoinString, options.joinString);\n\n return tag;\n },\n };\n}\n\n/**\n * Export a preconfigured version for convenience.\n */\nexport const urlSafeString = buildUrlSafeString().generate;\n\nexport function makeUrlSafe(name: string): string {\n return urlSafeString(name.replace(/\\//g, '-'))\n .replace(/^-*/g, '')\n .replace(/-*$/g, '');\n}\n","import { makeUrlSafe } from '../../routing/url';\nimport type { MicrofrontendConfig } from '../microfrontend-config';\nimport type { OverridesConfig } from './types';\n\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\n\nexport class Overrides {\n config: OverridesConfig;\n\n constructor(config: OverridesConfig) {\n this.config = config;\n }\n\n static overrideEnvCookiePrefix = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n\n static getAppEnvOverrideCookieName(zone: string): string {\n return `${Overrides.overrideEnvCookiePrefix}${zone}`;\n }\n\n static isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n }\n\n static getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n }): { zone: string; host: string } | undefined {\n if (!Overrides.isOverrideCookie(cookie) || !cookie.value) return;\n return {\n zone: cookie.name.replace(Overrides.overrideEnvCookiePrefix, ''),\n host: cookie.value,\n };\n }\n\n static parseOverrides(\n cookies: { name: string; value?: string | null }[],\n ): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = Overrides.getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.zone] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n }\n\n static validOverrideDomainsForZone(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n ): string[] {\n const projectName = microfrontendConfig.getZone(zone).vercel?.projectName;\n if (!projectName) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n const parsedProjectName = makeUrlSafe(projectName);\n const previewDeploymentSuffix =\n microfrontendConfig.options?.vercel?.previewDeploymentSuffix;\n const teamSlug = microfrontendConfig.options?.vercel?.teamSlug;\n if (!teamSlug && !previewDeploymentSuffix) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n\n const suffix = previewDeploymentSuffix\n ? `.${previewDeploymentSuffix}`\n : `-${teamSlug}.vercel.app`;\n\n // <project-name>-git-<branch-name>-<scope-slug>.vercel.app\n // <project-name>-git-<branch-name>.<custom-suffix>\n return [\n `${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,\n microfrontendConfig.getZone(zone).production.host,\n ];\n }\n\n static validateOverrideDomain(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n domain: string,\n ): boolean {\n return new RegExp(\n `^${Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(\n '|',\n )}$`,\n ).test(domain);\n }\n\n serialize(): OverridesConfig {\n return this.config;\n }\n}\n","import type { HostConfig } from '../schema';\n\ninterface HostDisplayOptions {\n includeDefaultPort?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: HostConfig['host'];\n port: number;\n serialized: HostConfig;\n\n constructor({ protocol, host, port }: HostConfig) {\n this.protocol = protocol || 'https';\n this.host = host;\n this.port = Host.getPort({ port, protocol: this.protocol });\n this.serialized = {\n protocol,\n host,\n ...(port ? { port } : undefined),\n };\n }\n\n isLocal(): boolean {\n return this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n static getPort({\n protocol,\n port,\n }: { protocol: HostConfig['protocol']; port?: HostConfig['port'] }): number {\n if (!port) {\n if (protocol === 'http') {\n return 80;\n }\n return 443;\n }\n\n return port;\n }\n\n isDefaultPort(): boolean {\n return this.port === Host.getPort({ protocol: this.protocol });\n }\n\n toString(opts: HostDisplayOptions = {}): string {\n const url = this.toUrl(opts);\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(opts: HostDisplayOptions = {}): URL {\n const { includeDefaultPort } = opts;\n const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? '' : `:${this.port}`}`;\n\n return new URL(url);\n }\n\n serialize(): HostConfig {\n return this.serialized;\n }\n}\n","import type { ApplicationConfig, Routing, Vercel } from '../schema';\nimport type { ApplicationOverrideConfig } from '../overrides';\nimport { MicrofrontendError } from '../errors';\nimport { Host } from './host';\n\nexport class Application {\n default: boolean;\n routing?: Routing;\n name: string;\n development: {\n local: Host;\n fallback?: Host;\n };\n production: Host;\n vercel?: Vercel;\n overrides?: {\n environment?: Host;\n };\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: { app: ApplicationConfig; overrides?: ApplicationOverrideConfig },\n ) {\n // validate\n Application.validate(name, app);\n\n this.name = name;\n this.default = app.default;\n this.routing = app.routing;\n this.development = {\n local: new Host(app.development.local),\n fallback: app.development.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n this.production = new Host(app.production);\n this.vercel = app.vercel;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n static validate(name: string, app: ApplicationConfig): void {\n // validate assetPrefix\n if (\n app.routing?.assetPrefix?.startsWith('/') ||\n app.routing?.assetPrefix?.endsWith('/')\n ) {\n throw new MicrofrontendError(\n `Invalid assetPrefix for application \"${name}\". Must not start or end with a slash.`,\n { type: 'zone', subtype: 'invalid_asset_prefix' },\n );\n }\n\n // validate routes\n for (const group of app.routing?.matches ?? []) {\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: 'zone', 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: 'zone', subtype: 'invalid_path' },\n );\n }\n }\n }\n }\n\n serialize(): ApplicationConfig {\n if (this.routing === undefined || this.default) {\n return {\n default: true,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n\n return {\n default: false,\n routing: this.routing,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n}\n","import type { ApplicationConfig, Config, Options } from '../schema';\nimport { MicrofrontendError } from '../errors';\nimport type { OverridesConfig } from '../overrides';\nimport { Overrides } from '../overrides/config';\nimport { Application } from './application';\n\nconst SUPPORTED_VERSIONS = ['1'];\nconst DEFAULT_LOCAL_PROXY_PORT = 3024;\n\n/**\n * A class to manage the microfrontends configuration.\n *\n * This class should not be used directly. Instead, use the `MicrofrontendConfig` or `MicrofrontendConfigEdgeRuntime` classes.\n */\nexport class MicrofrontendConfigCommon {\n config: Config;\n name?: string;\n zones: Record<string, Application> = {};\n version: string;\n overrides?: Overrides;\n options?: Options;\n $schema: string | undefined;\n\n constructor({\n config,\n overrides,\n }: { config: Config; overrides?: OverridesConfig }) {\n if (!SUPPORTED_VERSIONS.includes(config.version)) {\n throw new MicrofrontendError(\n `Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(\n ', ',\n )}`,\n { type: 'config', subtype: 'unsupported_version' },\n );\n }\n const disableOverrides = config.options?.vercel?.disableOverrides ?? false;\n\n this.overrides =\n overrides && !disableOverrides ? new Overrides(overrides) : undefined;\n\n // create zones\n for (const [zoneName, zoneConfig] of Object.entries(config.applications)) {\n this.zones[zoneName] = new Application(zoneName, {\n app: zoneConfig,\n overrides: !disableOverrides\n ? this.overrides?.config.applications[zoneName]\n : undefined,\n });\n }\n\n this.config = config;\n this.name = config.name;\n this.version = config.version;\n this.options = config.options;\n this.$schema = config.$schema;\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n protected static getConfigFromEnv(): 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\n static fromEnv(_: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfigCommon | Promise<MicrofrontendConfigCommon> {\n throw new Error('Not implemented');\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getAllApplications(): Application[] {\n return Object.values(this.zones);\n }\n\n getZone(name: string): Application {\n const zone = this.zones[name];\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n getApplicationByProjectId(projectId: string): Application | undefined {\n return Object.values(this.zones).find(\n (zone) => zone.vercel?.projectId === projectId,\n );\n }\n\n getDefaultZone(): Application {\n const zone = Object.values(this.zones).find((z) => z.default);\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find default zone in microfrontends configuration`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return this.config.options?.localProxy?.port ?? 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 const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n $schema: this.$schema,\n name: this.name,\n version: this.version,\n options: this.options,\n applications,\n };\n }\n\n serialize(): { config: Config; overrides?: OverridesConfig } {\n const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n config: {\n name: this.name,\n version: this.version,\n applications,\n options: this.options,\n $schema: this.$schema,\n },\n overrides: this.overrides?.serialize(),\n };\n }\n\n write(_: string): void {\n throw new MicrofrontendError(\n `Writing to file to disk requires using an instance of \"MicrofrontendConfig\".`,\n { type: 'config', subtype: 'unsupported_operation' },\n );\n }\n}\n","/// <reference types=\"@edge-runtime/types\" />\n\nimport type { Application } from '../config/common/application';\n\nfunction debugDomains(zone: string, env: string, domain: string): void {\n if (process.env.MFE_DEBUG === 'true') {\n const indent = ' '.repeat(4);\n const header = 'domains (zone (env) -> domain)';\n const separator = '⎯'.repeat(header.length);\n const line = `${indent} 1. ${zone} (${env}) -> ${domain}`;\n\n // eslint-disable-next-line no-console\n console.log(`${indent}${header}\\n${indent}${separator}\\n${line}\\n`);\n }\n}\n\n/**\n * Returns the Vercel domain for the given application based on the current\n * environment (local, preview, production).\n */\nexport function getDomainForCurrentEnvironment(\n zone: Application,\n opts: { ignoreOverride?: boolean } = {},\n): string {\n if (!opts.ignoreOverride && zone.overrides?.environment) {\n return zone.overrides.environment.toString();\n }\n const zoneName = zone.name;\n if (!process.env.VERCEL_ENV || process.env.VERCEL_ENV === 'development') {\n // TODO(mknichel): Convert this back to the local development domain once\n // there is local development proxy support.\n const domain =\n process.env.NODE_ENV === 'test'\n ? zone.development.local.toString()\n : zone.production.toString();\n debugDomains(zoneName, 'development', domain);\n return domain;\n } else if (process.env.VERCEL_ENV === 'production') {\n const domain = zone.production.toString();\n debugDomains(zoneName, 'production', domain);\n return domain;\n } else if (process.env.VERCEL_ENV === 'preview') {\n const MFE_PREVIEW_DOMAINS = JSON.parse(\n process.env.MFE_PREVIEW_DOMAINS ?? '{}',\n ) as Record<string, string>;\n if (MFE_PREVIEW_DOMAINS[zoneName]) {\n debugDomains(zoneName, 'preview', MFE_PREVIEW_DOMAINS[zoneName]);\n return MFE_PREVIEW_DOMAINS[zoneName];\n }\n\n throw new Error(\n `Could not find preview domain for application \"${zoneName}\"`,\n );\n }\n // TODO(mknichel): Add support in this function for custom environments.\n // Custom Vercel environments may have an arbitrary string for `VERCEL_ENV`.\n debugDomains(zoneName, process.env.VERCEL_ENV, zone.production.toString());\n return zone.production.toString();\n}\n"],"mappings":";AAGA,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;;;ACF7B,SAAS,aAAa;;;ACuEf,IAAM,qBAAN,cAEG,MAAM;AAAA,EAKd,YAAY,SAAiB,MAAqC;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAS,6BAAM,WAAU;AAC9B,SAAK,QAAO,6BAAM,SAAS;AAC3B,SAAK,UAAU,6BAAM;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;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
|
|
109
109
|
projectId: string;
|
|
110
110
|
}
|
|
111
111
|
interface VercelOptions {
|
|
112
|
-
/**
|
|
113
|
-
* If your team uses a custom Preview Deployment Suffix, please specify it here.
|
|
114
|
-
* See https://vercel.com/docs/deployments/preview-deployment-suffix.
|
|
115
|
-
* The default is `vercel.app`.
|
|
116
|
-
*/
|
|
117
|
-
previewDeploymentSuffix?: string;
|
|
118
112
|
/**
|
|
119
113
|
* Team slug for the Vercel team
|
|
120
114
|
*/
|
|
@@ -145,4 +139,4 @@ interface LocalProxyOptions {
|
|
|
145
139
|
port?: number;
|
|
146
140
|
}
|
|
147
141
|
|
|
148
|
-
export {
|
|
142
|
+
export { Application as A, Config as C, DefaultApplication as D, HostConfig as H, LocalHostConfig as L, MainConfig as M, PathGroup as P, Vercel as V, ChildConfig as a, ChildApplication as b, ApplicationId as c };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { c as ApplicationId, P as PathGroup } from './types-a29d224a.js';
|
|
2
|
+
|
|
3
|
+
interface ClientApplication {
|
|
4
|
+
routing?: PathGroup[];
|
|
5
|
+
default?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ClientConfig {
|
|
8
|
+
applications: Record<ApplicationId, ClientApplication>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { ClientConfig as C };
|
package/dist/utils/mfe-port.cjs
CHANGED
|
@@ -33,8 +33,8 @@ __export(mfe_port_exports, {
|
|
|
33
33
|
mfePort: () => mfePort
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(mfe_port_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
37
|
+
var import_node_fs10 = __toESM(require("fs"), 1);
|
|
38
38
|
|
|
39
39
|
// src/config/types.ts
|
|
40
40
|
var isDefaultApplicationConfig = (app) => app.default && typeof app.routing === "undefined";
|
|
@@ -1180,8 +1180,8 @@ var MicrofrontendConfig = class extends MicrofrontendConfigCommon {
|
|
|
1180
1180
|
};
|
|
1181
1181
|
|
|
1182
1182
|
// src/config-v2/microfrontends/server/index.ts
|
|
1183
|
-
var
|
|
1184
|
-
var
|
|
1183
|
+
var import_node_fs9 = __toESM(require("fs"), 1);
|
|
1184
|
+
var import_node_path10 = require("path");
|
|
1185
1185
|
|
|
1186
1186
|
// src/config-v2/overrides/constants.ts
|
|
1187
1187
|
var OVERRIDES_COOKIE_PREFIX2 = "vercel-micro-frontends-override";
|
|
@@ -1528,19 +1528,6 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
|
|
|
1528
1528
|
);
|
|
1529
1529
|
}
|
|
1530
1530
|
};
|
|
1531
|
-
var validateConfigOptions = (options) => {
|
|
1532
|
-
var _a;
|
|
1533
|
-
if ((_a = options == null ? void 0 : options.vercel) == null ? void 0 : _a.previewDeploymentSuffix) {
|
|
1534
|
-
if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
|
|
1535
|
-
options.vercel.previewDeploymentSuffix
|
|
1536
|
-
)) {
|
|
1537
|
-
throw new MicrofrontendError2(
|
|
1538
|
-
`Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
|
|
1539
|
-
{ type: "config", subtype: "invalid_preview_deployment_suffix" }
|
|
1540
|
-
);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
};
|
|
1544
1531
|
|
|
1545
1532
|
// src/config-v2/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
|
|
1546
1533
|
var PREFIX = "vc-ap";
|
|
@@ -1759,7 +1746,6 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
1759
1746
|
validateConfigPaths(c.applications);
|
|
1760
1747
|
validateConfigDefaultApplication(c.applications);
|
|
1761
1748
|
}
|
|
1762
|
-
validateConfigOptions(c.options);
|
|
1763
1749
|
return c;
|
|
1764
1750
|
}
|
|
1765
1751
|
static fromEnv({
|
|
@@ -2035,29 +2021,39 @@ function findPackagePath(opts) {
|
|
|
2035
2021
|
// src/config-v2/microfrontends/utils/find-default-package.ts
|
|
2036
2022
|
var import_node_path6 = require("path");
|
|
2037
2023
|
var import_node_fs5 = require("fs");
|
|
2024
|
+
var import_jsonc_parser3 = require("jsonc-parser");
|
|
2038
2025
|
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
2026
|
+
|
|
2027
|
+
// src/config-v2/constants.ts
|
|
2028
|
+
var CONFIGURATION_FILENAMES = [
|
|
2029
|
+
"microfrontends.jsonc",
|
|
2030
|
+
"microfrontends.json"
|
|
2031
|
+
];
|
|
2032
|
+
|
|
2033
|
+
// src/config-v2/microfrontends/utils/find-default-package.ts
|
|
2039
2034
|
var configCache2 = {};
|
|
2040
2035
|
function findDefaultMicrofrontendsPackages({
|
|
2041
2036
|
repositoryRoot,
|
|
2042
2037
|
applicationName
|
|
2043
2038
|
}) {
|
|
2044
2039
|
try {
|
|
2045
|
-
const microfrontendsJsonPaths = import_fast_glob2.default.globSync(
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2040
|
+
const microfrontendsJsonPaths = import_fast_glob2.default.globSync(
|
|
2041
|
+
`**/{${CONFIGURATION_FILENAMES.join(",")}}`,
|
|
2042
|
+
{
|
|
2043
|
+
cwd: repositoryRoot,
|
|
2044
|
+
absolute: true,
|
|
2045
|
+
onlyFiles: true,
|
|
2046
|
+
followSymbolicLinks: false,
|
|
2047
|
+
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
2048
|
+
}
|
|
2049
|
+
);
|
|
2052
2050
|
const matchingPaths = [];
|
|
2053
2051
|
for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
|
|
2054
2052
|
const microfrontendsJsonContent = (0, import_node_fs5.readFileSync)(
|
|
2055
2053
|
microfrontendsJsonPath,
|
|
2056
2054
|
"utf-8"
|
|
2057
2055
|
);
|
|
2058
|
-
const microfrontendsJson =
|
|
2059
|
-
microfrontendsJsonContent
|
|
2060
|
-
);
|
|
2056
|
+
const microfrontendsJson = (0, import_jsonc_parser3.parse)(microfrontendsJsonContent);
|
|
2061
2057
|
if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
|
|
2062
2058
|
matchingPaths.push(microfrontendsJsonPath);
|
|
2063
2059
|
}
|
|
@@ -2087,7 +2083,7 @@ function findDefaultMicrofrontendsPackage(opts) {
|
|
|
2087
2083
|
const result = findDefaultMicrofrontendsPackages(opts);
|
|
2088
2084
|
if (!result) {
|
|
2089
2085
|
throw new Error(
|
|
2090
|
-
`Error trying to resolve the main microfrontends
|
|
2086
|
+
`Error trying to resolve the main microfrontends configuration`
|
|
2091
2087
|
);
|
|
2092
2088
|
}
|
|
2093
2089
|
configCache2[cacheKey] = result;
|
|
@@ -2139,8 +2135,21 @@ function findPackageRoot(startDir) {
|
|
|
2139
2135
|
);
|
|
2140
2136
|
}
|
|
2141
2137
|
|
|
2138
|
+
// src/config-v2/microfrontends/utils/find-config.ts
|
|
2139
|
+
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
2140
|
+
var import_node_path9 = require("path");
|
|
2141
|
+
function findConfig({ dir }) {
|
|
2142
|
+
for (const filename of CONFIGURATION_FILENAMES) {
|
|
2143
|
+
const maybeConfig = (0, import_node_path9.join)(dir, filename);
|
|
2144
|
+
if (import_node_fs8.default.existsSync(maybeConfig)) {
|
|
2145
|
+
return maybeConfig;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
return null;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2142
2151
|
// src/config-v2/microfrontends/server/validation.ts
|
|
2143
|
-
var
|
|
2152
|
+
var import_jsonc_parser4 = require("jsonc-parser");
|
|
2144
2153
|
var import_ajv2 = require("ajv");
|
|
2145
2154
|
|
|
2146
2155
|
// schema/schema-v2.json
|
|
@@ -2201,10 +2210,6 @@ var schema_v2_default = {
|
|
|
2201
2210
|
VercelOptions: {
|
|
2202
2211
|
type: "object",
|
|
2203
2212
|
properties: {
|
|
2204
|
-
previewDeploymentSuffix: {
|
|
2205
|
-
type: "string",
|
|
2206
|
-
description: "If your team uses a custom Preview Deployment Suffix, please specify it here. See https://vercel.com/docs/deployments/preview-deployment-suffix. The default is `vercel.app`."
|
|
2207
|
-
},
|
|
2208
2213
|
teamSlug: {
|
|
2209
2214
|
type: "string",
|
|
2210
2215
|
description: "Team slug for the Vercel team"
|
|
@@ -2398,7 +2403,7 @@ var SCHEMA2 = schema_v2_default;
|
|
|
2398
2403
|
|
|
2399
2404
|
// src/config-v2/microfrontends/server/validation.ts
|
|
2400
2405
|
function validateSchema2(configString) {
|
|
2401
|
-
const parsedConfig = (0,
|
|
2406
|
+
const parsedConfig = (0, import_jsonc_parser4.parse)(configString);
|
|
2402
2407
|
const ajv = new import_ajv2.Ajv();
|
|
2403
2408
|
const validate = ajv.compile(SCHEMA2);
|
|
2404
2409
|
const isValid = validate(parsedConfig);
|
|
@@ -2420,8 +2425,8 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2420
2425
|
pretty: true
|
|
2421
2426
|
}) {
|
|
2422
2427
|
const outputPath = getOutputFilePath();
|
|
2423
|
-
|
|
2424
|
-
|
|
2428
|
+
import_node_fs9.default.mkdirSync((0, import_node_path10.dirname)(outputPath), { recursive: true });
|
|
2429
|
+
import_node_fs9.default.writeFileSync(
|
|
2425
2430
|
outputPath,
|
|
2426
2431
|
JSON.stringify(
|
|
2427
2432
|
this.config.toSchemaJson(),
|
|
@@ -2484,8 +2489,8 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2484
2489
|
return config;
|
|
2485
2490
|
}
|
|
2486
2491
|
/**
|
|
2487
|
-
* Looks up the configuration by inferring the package root and looking for a microfrontends
|
|
2488
|
-
* it will look for a package in the repository with a microfrontends
|
|
2492
|
+
* Looks up the configuration by inferring the package root and looking for a microfrontends config file. If a file is not found,
|
|
2493
|
+
* it will look for a package in the repository with a microfrontends file that contains the current application
|
|
2489
2494
|
* and use that configuration.
|
|
2490
2495
|
*
|
|
2491
2496
|
* This can return either a Child or Main configuration.
|
|
@@ -2507,16 +2512,16 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2507
2512
|
}
|
|
2508
2513
|
try {
|
|
2509
2514
|
const packageRoot = findPackageRoot(directory);
|
|
2510
|
-
const packageJsonPath = (0,
|
|
2515
|
+
const packageJsonPath = (0, import_node_path10.join)(packageRoot, "package.json");
|
|
2511
2516
|
const packageJson = JSON.parse(
|
|
2512
|
-
|
|
2517
|
+
import_node_fs9.default.readFileSync(packageJsonPath, "utf-8")
|
|
2513
2518
|
);
|
|
2514
2519
|
if (!packageJson.name) {
|
|
2515
2520
|
throw new Error(`No name found in package.json at ${packageJsonPath}`);
|
|
2516
2521
|
}
|
|
2517
2522
|
const configMeta = meta ?? { fromApp: packageJson.name };
|
|
2518
|
-
const maybeConfig = (
|
|
2519
|
-
if (
|
|
2523
|
+
const maybeConfig = findConfig({ dir: packageRoot });
|
|
2524
|
+
if (maybeConfig) {
|
|
2520
2525
|
return MicrofrontendsServer.fromFile({
|
|
2521
2526
|
filePath: maybeConfig,
|
|
2522
2527
|
cookies,
|
|
@@ -2531,12 +2536,15 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2531
2536
|
repositoryRoot,
|
|
2532
2537
|
applicationName: packageJson.name
|
|
2533
2538
|
});
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2539
|
+
const maybeConfigFromDefault = findConfig({ dir: defaultPackage });
|
|
2540
|
+
if (maybeConfigFromDefault) {
|
|
2541
|
+
return MicrofrontendsServer.fromFile({
|
|
2542
|
+
filePath: maybeConfigFromDefault,
|
|
2543
|
+
cookies,
|
|
2544
|
+
meta: configMeta,
|
|
2545
|
+
options
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2540
2548
|
}
|
|
2541
2549
|
throw new Error("Unable to infer");
|
|
2542
2550
|
} catch (e) {
|
|
@@ -2556,7 +2564,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2556
2564
|
options
|
|
2557
2565
|
}) {
|
|
2558
2566
|
try {
|
|
2559
|
-
const configJson =
|
|
2567
|
+
const configJson = import_node_fs9.default.readFileSync(filePath, "utf-8");
|
|
2560
2568
|
const config = MicrofrontendsServer.validate(configJson);
|
|
2561
2569
|
if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
|
|
2562
2570
|
const repositoryRoot = findRepositoryRoot();
|
|
@@ -2572,9 +2580,15 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2572
2580
|
{ type: "config", subtype: "not_found" }
|
|
2573
2581
|
);
|
|
2574
2582
|
}
|
|
2575
|
-
const
|
|
2583
|
+
const maybeConfig = findConfig({ dir: packagePath });
|
|
2584
|
+
if (!maybeConfig) {
|
|
2585
|
+
throw new MicrofrontendError2(
|
|
2586
|
+
`Could not find microfrontends configuration in ${packagePath}`,
|
|
2587
|
+
{ type: "config", subtype: "not_found" }
|
|
2588
|
+
);
|
|
2589
|
+
}
|
|
2576
2590
|
return MicrofrontendsServer.fromMainConfigFile({
|
|
2577
|
-
filePath:
|
|
2591
|
+
filePath: maybeConfig,
|
|
2578
2592
|
overrides: cookies ? parseOverrides(cookies) : void 0
|
|
2579
2593
|
});
|
|
2580
2594
|
}
|
|
@@ -2598,7 +2612,7 @@ var MicrofrontendsServer = class extends Microfrontends {
|
|
|
2598
2612
|
overrides
|
|
2599
2613
|
}) {
|
|
2600
2614
|
try {
|
|
2601
|
-
const config =
|
|
2615
|
+
const config = import_node_fs9.default.readFileSync(filePath, "utf-8");
|
|
2602
2616
|
const validatedConfig = MicrofrontendsServer.validate(config);
|
|
2603
2617
|
if (!isMainConfig(validatedConfig)) {
|
|
2604
2618
|
throw new MicrofrontendError2(
|
|
@@ -2647,8 +2661,8 @@ function mfePort(packageDir) {
|
|
|
2647
2661
|
};
|
|
2648
2662
|
}
|
|
2649
2663
|
function getPackageJson(packageDir) {
|
|
2650
|
-
const filePath =
|
|
2651
|
-
return JSON.parse(
|
|
2664
|
+
const filePath = import_node_path11.default.join(packageDir, "package.json");
|
|
2665
|
+
return JSON.parse(import_node_fs10.default.readFileSync(filePath, "utf-8"));
|
|
2652
2666
|
}
|
|
2653
2667
|
function loadV2({
|
|
2654
2668
|
packageDir,
|
|
@@ -2672,7 +2686,7 @@ function loadV1({
|
|
|
2672
2686
|
packageDir,
|
|
2673
2687
|
appName
|
|
2674
2688
|
}) {
|
|
2675
|
-
const filePath =
|
|
2689
|
+
const filePath = import_node_path11.default.join(packageDir, "micro-frontends.jsonc");
|
|
2676
2690
|
let config;
|
|
2677
2691
|
try {
|
|
2678
2692
|
config = MicrofrontendConfig.fromFile({ filePath });
|