@module-federation/enhanced
Version:
This package provides enhanced features for module federation.
32 lines (31 loc) • 1.47 kB
TypeScript
import { Compiler, WebpackPluginInstance } from "webpack";
//#region src/wrapper/BaseWrapperPlugin.d.ts
/**
* Base Wrapper Plugin Class
*
* Why we need a Wrapper layer:
* 1. Prevent direct references to peer dependency webpack in CommonJS environment, which can lead to inconsistent instances
* 2. Ensure the FEDERATION_WEBPACK_PATH environment variable is set correctly, which is crucial for module federation to work properly
* 3. Provide unified plugin initialization logic, reducing code duplication
*
* Why we need to set FEDERATION_WEBPACK_PATH:
* In CommonJS environment, require('webpack') might get a different webpack version than the current compiler instance,
* which can cause module federation to malfunction. By setting FEDERATION_WEBPACK_PATH, we ensure all internal
* dependencies use the same webpack instance as the current compiler.
*/
declare abstract class BaseWrapperPlugin implements WebpackPluginInstance {
protected _options: any;
name: string;
protected pluginName: string;
protected coreModulePath: string;
constructor(options: any, pluginName: string, coreModulePath: string);
apply(compiler: Compiler): void;
/**
* Create core plugin instance
* Subclasses can override this method to customize instantiation logic
*/
protected createCorePluginInstance(CorePlugin: any, compiler: Compiler): void;
}
//#endregion
export { BaseWrapperPlugin as default };
//# sourceMappingURL=BaseWrapperPlugin.d.ts.map