@openshift-console/dynamic-plugin-sdk-webpack
Version:
Provides webpack ConsoleRemotePlugin used to build all dynamic plugin assets.
139 lines (138 loc) • 6.02 kB
TypeScript
import { EncodedExtension } from '@openshift/dynamic-plugin-sdk-webpack';
import * as webpack from 'webpack';
import { ConsolePluginBuildMetadata } from '../build-types';
import { ValidationResult } from '../validation/ValidationResult';
export declare const validateConsoleExtensionsFileSchema: (extensions: EncodedExtension[], description?: string) => ValidationResult;
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.
*
* 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 `transformImports` filter, that module will have its imports
* transformed 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 pulls in all of its code.
*/
sharedDynamicModuleSettings: Partial<{
/**
* Paths to `node_modules` directories to search when parsing 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[];
/**
* Attempt to parse dynamic modules for these packages.
*
* Each package listed here should include a `dist/dynamic` directory containing `package.json`
* files that refer to specific modules of that package.
*
* If not specified, the following packages will be included:
* - `@patternfly/react-core`
* - `@patternfly/react-icons`
* - `@patternfly/react-table`
*/
packageSpecs: Record<string, Partial<{
/** @default 'dist/esm/index.js' */
indexModule: string;
/** @default 'module' */
resolutionField: string;
}>>;
/**
* Import transformations will be applied to modules that match this filter.
*
* If not specified, the following conditions must be all true for a module to be matched:
* - request ends with one of `.js`, `.jsx`, `.ts`, `.tsx`
* - request does not contain `node_modules` path elements (i.e. not a vendor module request),
* _except_ for `@openshift-console/*` packages
*/
transformImports: (moduleRequest: string) => boolean;
}>;
}>;
/**
* Generates Console dynamic plugin remote container and related assets.
*
* Refer to `frontend/packages/console-dynamic-plugin-sdk/src/shared-modules.ts` for details on
* Console application vs. dynamic plugins shared module configuration.
*
* @see {@link sharedPluginModules}
* @see {@link getSharedModuleMetadata}
*/
export declare class ConsoleRemotePlugin implements webpack.WebpackPluginInstance {
private readonly adaptedOptions;
private readonly baseDir;
private readonly pkg;
private readonly sharedDynamicModuleMaps;
constructor(options?: ConsoleRemotePluginOptions);
apply(compiler: webpack.Compiler): void;
}