import type { ChainIdentifier } from '@modern-js/utils/chain-id'; import type { Stats, MultiStats } from './stats'; import { NodeEnv, PromiseOrNot } from './utils'; import { BuilderTarget } from './builder'; import { BundlerChain } from './bundlerConfig'; import { mergeBuilderConfig } from '../mergeBuilderConfig'; import type { WebpackPluginInstance } from 'webpack'; export type OnBeforeBuildFn = (params: { bundlerConfigs?: BundlerConfig[]; }) => PromiseOrNot; export type OnAfterBuildFn = (params: { stats?: Stats | MultiStats; }) => PromiseOrNot; export type OnDevCompileDoneFn = (params: { isFirstCompile: boolean; }) => PromiseOrNot; export type OnBeforeStartDevServerFn = () => PromiseOrNot; export type OnAfterStartDevServerFn = (params: { port: number; }) => PromiseOrNot; export type OnBeforeCreateCompilerFn = (params: { bundlerConfigs: BundlerConfig[]; }) => PromiseOrNot; export type OnAfterCreateCompilerFn = (params: { compiler: Compiler; }) => PromiseOrNot; export type OnExitFn = () => void; export type ModifyBuilderConfigUtils = { /** Merge multiple builder config objects into one. */ mergeBuilderConfig: typeof mergeBuilderConfig; }; export type ModifyBuilderConfigFn = (config: BuilderConfig, utils: ModifyBuilderConfigUtils) => PromiseOrNot; export type ModifyChainUtils = { env: NodeEnv; isProd: boolean; target: BuilderTarget; isServer: boolean; isServiceWorker: boolean; isWebWorker: boolean; CHAIN_ID: ChainIdentifier; getCompiledPath: (name: string) => string; HtmlPlugin: any; /** * @private should only used in builder */ webpack: typeof import('webpack'); }; export type ModifyBundlerChainUtils = ModifyChainUtils & { bundler: { BannerPlugin: WebpackPluginInstance; DefinePlugin: WebpackPluginInstance; ProvidePlugin: WebpackPluginInstance; }; }; /** The intersection of webpack-chain and rspack-chain */ export type ModifyBundlerChainFn = (chain: BundlerChain, utils: ModifyBundlerChainUtils) => PromiseOrNot; export type CreateAsyncHook any> = { tap: (cb: Callback) => void; call: (...args: Parameters) => Promise>; };