/** * HeftRspackPlugin is a Heft plugin that integrates the Rspack bundler into the Heft build process. * * @packageDocumentation */ import type { AsyncParallelHook } from 'tapable'; import type { AsyncSeriesBailHook } from 'tapable'; import type { AsyncSeriesHook } from 'tapable'; import type { AsyncSeriesWaterfallHook } from 'tapable'; import type { HeftConfiguration } from '@rushstack/heft'; import type { IHeftTaskSession } from '@rushstack/heft'; import { rspackCore } from '@rspack/core'; import type * as TRspack from '@rspack/core'; import type * as TRspackDevServer from '@rspack/dev-server'; /** * @beta */ export declare type IRspackConfiguration = TRspack.Configuration | TRspack.Configuration[]; /** * The environment passed into the Rspack configuration function. Loosely based * on the default Rspack environment options, specified here: * https://rspack.rs/plugins/webpack/environment-plugin#options * * @beta */ export declare interface IRspackConfigurationFnEnvironment { /** * Whether or not the run is in production mode. Synonym of * {@link IRspackConfigurationFnEnvironment.production}. */ prod: boolean; /** * Whether or not the run is in production mode. Synonym of * {@link IRspackConfigurationFnEnvironment.prod}. */ production: boolean; /** * The task session provided to the plugin. */ taskSession: IHeftTaskSession; /** * The Heft configuration provided to the plugin. */ heftConfiguration: HeftConfiguration; /** * The resolved Rspack package. */ rspack: RspackCoreImport; } /** * @beta */ export declare interface IRspackConfigurationWithDevServer extends TRspack.Configuration { devServer?: TRspackDevServer.Configuration; } /** * @beta */ export declare interface IRspackPluginAccessor { /** * Hooks that are called at various points in the Rspack plugin lifecycle. */ readonly hooks: IRspackPluginAccessorHooks; /** * Parameters that are provided by the Rspack plugin. */ readonly parameters: IRspackPluginAccessorParameters; } /** * @beta */ export declare interface IRspackPluginAccessorHooks { /** * A hook that allows for loading custom configurations used by the Rspack * plugin. If a tap returns a value other than `undefined` before stage {@link STAGE_LOAD_LOCAL_CONFIG}, * it will suppress loading from the Rspack config file. To provide a fallback behavior in the * absence of a local config file, tap this hook with a `stage` value greater than {@link STAGE_LOAD_LOCAL_CONFIG}. * * @remarks * Tapable event handlers can return `false` instead of `undefined` to suppress * other handlers from creating a configuration object, and prevent Rspack from running. */ readonly onLoadConfiguration: AsyncSeriesBailHook<[], IRspackConfiguration | undefined | false>; /** * A hook that allows for modification of the loaded configuration used by the Rspack * plugin. If no configuration was loaded, this hook will not be called. */ readonly onConfigure: AsyncSeriesHook<[IRspackConfiguration], never>; /** * A hook that provides the finalized configuration that will be used by Rspack. * If no configuration was loaded, this hook will not be called. */ readonly onAfterConfigure: AsyncParallelHook<[IRspackConfiguration], never>; /** * A hook that provides the stats output from Rspack. If no configuration is loaded, * this hook will not be called. */ readonly onEmitStats: AsyncParallelHook<[TRspack.Stats | TRspack.MultiStats], never>; /** * A hook that allows for customization of the file watcher options. If not running in watch mode, this hook will not be called. */ readonly onGetWatchOptions: AsyncSeriesWaterfallHook<[ Parameters[0], Readonly ], never>; } /** * @beta */ export declare interface IRspackPluginAccessorParameters { /** * Whether or not serve mode was enabled by passing the `--serve` flag. */ readonly isServeMode: boolean; } /** * @beta */ export declare const PluginName: 'rspack-plugin'; /** * @beta */ export declare type RspackCoreImport = rspackCore; /** * The stage in the `onLoadConfiguration` hook at which the config will be loaded from the local * rspack config file. * @beta */ export declare const STAGE_LOAD_LOCAL_CONFIG: 1000; export { }