import type { EncodedExtension } from '@openshift/dynamic-plugin-sdk-webpack'; import type { Compiler, WebpackPluginInstance } from 'webpack'; import type { ConsolePluginBuildMetadata } from '../build-types'; import { ValidationResult } from '../validation/ValidationResult'; import type { DynamicModulePackageSpecs } from './DynamicModuleImportPlugin'; export declare const validateConsoleExtensionsFileSchema: (extensions: EncodedExtension[], description?: string) => ValidationResult; /** * Default shared dynamic module package definitions. */ export declare const dynamicModulePackageSpecs: DynamicModulePackageSpecs; export declare const dynamicModuleImportTransformFilter: (moduleRequest: string) => boolean; export type ConsoleRemotePluginOptions = Partial<{ /** * Console dynamic plugin metadata. * * If not specified, plugin metadata will be parsed from `consolePlugin` object within * the `package.json` file. * * Plugin metadata should meet the following requirements: * * - `name` should be the same as `metadata.name` of the corresponding `ConsolePlugin` * resource on the cluster. * - `version` must be semver compliant. * - `dependencies` values must be valid semver ranges or `*` representing any version. * - `dependencies` and `optionalDependencies` keys must be mutually exclusive. * * Additional runtime environment specific `dependencies` available to Console plugins: * * - `@console/pluginAPI` - Console web application. This dependency is matched against * the Console release version, as provided by the Console operator. */ pluginMetadata: ConsolePluginBuildMetadata; /** * List of extensions contributed by the plugin. * * If not specified, extensions will be parsed from `console-extensions.json` file. */ extensions: EncodedExtension[]; /** * Validate extension objects using the `console-extensions.json` schema? * * @default true */ validateExtensionSchema: boolean; /** * Validate integrity of extensions contributed by the plugin? * * This option controls whether to use `ExtensionValidator` to check the following criteria: * - each exposed module must have at least one code reference * - each code reference must point to a valid webpack module export * * @default true */ validateExtensionIntegrity: boolean; /** * Validate Console provided shared module dependencies? * * Console provided shared modules can be reflected as `dependencies` within the manifest of * the `@openshift-console/dynamic-plugin-sdk` package. For each shared module where a fallback * version is not allowed, check that the version consumed by the plugin satisfies the expected * semver range as declared in the Console core SDK package manifest. * * @default true */ validateSharedModules: boolean; /** * Some vendor packages may support dynamic modules to be used with webpack module federation. * * If a module request matches the `moduleFilter`, code of that module will be modified so that * any _index_ imports for given vendor packages become imports for specific dynamic modules of * these vendor packages. * * For example, the following import: * ```ts * import { Alert, AlertProps, Wizard } from '@patternfly/react-core'; * ``` * will be transformed into: * ```ts * import { Alert } from '@patternfly/react-core/dist/dynamic/components/Alert'; * import { AlertProps } from '@patternfly/react-core/dist/dynamic/components/Alert'; * import { Wizard } from '@patternfly/react-core/dist/dynamic/components/Wizard'; * ``` * * Each dynamic module (such as `@patternfly/react-core/dist/dynamic/components/Alert`) will * be treated as a separate shared module at runtime. This approach allows for more efficient * federation of vendor package code, as opposed to sharing the whole vendor package index * (such as `@patternfly/react-core`) that would cause all of its code to be pulled into the * Console compilation and inflate the vendor bundle size. */ sharedDynamicModuleSettings: Partial<{ /** * Packages that support dynamic modules for use with webpack module federation. * * Each vendor package listed here should include a `dist/dynamic` directory containing * `package.json` files representing parts of that package to be shared separately between * the Console application and its plugins at runtime. * * If not specified, use a default list of PatternFly packages that support dynamic modules. */ packageSpecs: DynamicModulePackageSpecs; /** * Paths to `node_modules` directories to search when resolving dynamic modules. * * Paths listed here _must_ be absolute. * * If not specified, the list will contain a single entry: * ```ts * path.resolve(process.cwd(), 'node_modules') * ``` */ modulePaths: string[]; /** * Modules that match this filter will have their imports transformed. * * If not specified, the following conditions must be all true for a module to be matched: * - request ends with `.js`, `.jsx`, `.ts` or `.tsx` * - request does not contain `node_modules` path elements (i.e. not a vendor module request), * _except_ for `@openshift-console/*` packages */ moduleFilter: (moduleRequest: string) => boolean; /** * Skip transforming imports whose module specifier matches one of these prefixes. * * This option allows plugins to import parts of vendor packages that are not exposed directly * via package index but have to be imported from a specific path, for example: * ```ts * // Cannot import Tile from '@patternfly/react-core' index * import { Tile } from '@patternfly/react-core/deprecated'; * ``` * * Import prefixes specified here will be added to the default skip list. * * If not specified, no additional import prefixes will be added to the default skip list. */ skipImportPrefixes: string[]; }>; }>; /** * Generates Console dynamic plugin remote container and related assets. * * Refer to `console-dynamic-plugin-sdk/src/shared-modules.ts` for details on Console provided * shared modules and their configuration. * * @see {@link sharedPluginModules} * @see {@link getSharedModuleMetadata} */ export declare class ConsoleRemotePlugin implements WebpackPluginInstance { private readonly adaptedOptions; private readonly baseDir; private readonly pkg; private readonly dynamicModuleMaps; constructor(options?: ConsoleRemotePluginOptions); apply(compiler: Compiler): void; }