import { Configuration, Compiler, ResolveOptions, RuleSetRule } from '@rspack/core'; import * as https from 'https'; // The compiler type of Rspack / webpack are mismatch, // so we use a loose type here to allow using webpack plugins. interface PluginInstance { apply: (compiler: any) => void; [index: string]: any; } declare namespace __Config { class Chained { batch(handler: (chained: this) => void): this; end(): Parent; } class TypedChainedMap extends Chained { clear(): this; delete(key: string): this; has(key: string): boolean; get(key: T): OptionsType[T]; getOrCompute( key: T, compute: () => OptionsType[T], ): OptionsType[T]; set(key: T, value: OptionsType[T]): this; merge(obj: Partial): this; entries(): OptionsType; values(): [OptionsType[T]][]; when( condition: boolean, trueBrancher: (obj: this) => void, falseBrancher?: (obj: this) => void, ): this; } class ChainedMap extends TypedChainedMap {} class TypedChainedSet extends Chained { add(value: Value): this; prepend(value: Value): this; clear(): this; delete(key: string): this; has(key: string): boolean; merge(arr: Value[]): this; values(): Value[]; when( condition: boolean, trueBrancher: (obj: this) => void, falseBrancher?: (obj: this) => void, ): this; } class ChainedSet extends TypedChainedSet {} } type RspackConfig = Required; declare class Config extends __Config.ChainedMap { entryPoints: Config.TypedChainedMap< Config, { [key: string]: Config.EntryPoint } >; output: Config.Output; module: Config.Module; node: Config.ChainedMap & ((value: boolean) => this); optimization: Config.Optimization; performance: Config.Performance & ((value: boolean) => this); plugins: Config.Plugins; resolve: Config.Resolve; resolveLoader: Config.ResolveLoader; devServer: Config.DevServer; context(value: RspackConfig['context']): this; mode(value: RspackConfig['mode']): this; devtool(value: Config.DevTool): this; target(value: RspackConfig['target']): this; watch(value: RspackConfig['watch']): this; watchOptions(value: RspackConfig['watchOptions']): this; externals(value: RspackConfig['externals']): this; externalsType(value: RspackConfig['externalsType']): this; externalsPresets(value: RspackConfig['externalsPresets']): this; stats(value: RspackConfig['stats']): this; experiments(value: RspackConfig['experiments']): this; amd(value: RspackConfig['amd']): this; bail(value: RspackConfig['bail']): this; // TODO: Rspack does not support cache yet cache(value: any): this; // cache(value: RspackConfig['cache']): this; dependencies(value: RspackConfig['dependencies']): this; ignoreWarnings(value: RspackConfig['ignoreWarnings']): this; loader(value: RspackConfig['loader']): this; parallelism(value: RspackConfig['parallelism']): this; profile(value: RspackConfig['profile']): this; recordsPath(value: RspackConfig['recordsPath']): this; recordsInputPath(value: RspackConfig['recordsInputPath']): this; recordsOutputPath(value: RspackConfig['recordsOutputPath']): this; name(value: RspackConfig['name']): this; infrastructureLogging(value: RspackConfig['infrastructureLogging']): this; snapshot(value: RspackConfig['snapshot']): this; entry(name: string): Config.EntryPoint; plugin(name: string): Config.Plugin; toConfig(): Configuration; } declare namespace Config { class Chained extends __Config.Chained {} class TypedChainedMap extends __Config.TypedChainedMap< Parent, OptionsType > {} class ChainedMap extends __Config.TypedChainedMap {} class TypedChainedSet extends __Config.TypedChainedSet< Parent, Value > {} class ChainedSet extends __Config.TypedChainedSet {} class Plugins< Parent, PluginType extends PluginInstance, > extends TypedChainedMap< Parent, { [key: string]: Plugin } > {} class Plugin extends ChainedMap implements Orderable { init

>( value: ( plugin: P, args: P extends PluginClass ? ConstructorParameters

: any[], ) => PluginType, ): this; use

>( plugin: P, args?: P extends PluginClass ? ConstructorParameters

: any[], ): this; tap

>( f: (args: ConstructorParameters

) => ConstructorParameters

, ): this; // Orderable before(name: string): this; after(name: string): this; } type RspackEntry = NonNullable; type WepackEntryObject = Exclude< RspackEntry, string | string[] | Function >[string]; class EntryPoint extends TypedChainedSet {} type RspackModule = Required>; class Module extends ChainedMap { rules: TypedChainedMap; generator: ChainedMap; parser: ChainedMap; rule(name: string): Rule; noParse(value: RspackModule['noParse']): this; unsafeCache(value: RspackModule['unsafeCache']): this; wrappedContextCritical(value: RspackModule['wrappedContextCritical']): this; exprContextRegExp(value: RspackModule['exprContextRegExp']): this; wrappedContextRecursive( value: RspackModule['wrappedContextRecursive'], ): this; strictExportPresence(value: RspackModule['strictExportPresence']): this; wrappedContextRegExp(value: RspackModule['wrappedContextRegExp']): this; } type RspackOutput = Required>; class Output extends ChainedMap { auxiliaryComment(value: RspackOutput['auxiliaryComment']): this; charset(value: RspackOutput['charset']): this; chunkFilename(value: RspackOutput['chunkFilename']): this; chunkLoadTimeout(value: RspackOutput['chunkLoadTimeout']): this; chunkLoadingGlobal(value: RspackOutput['chunkLoadingGlobal']): this; chunkLoading(value: RspackOutput['chunkLoading']): this; chunkFormat(value: RspackOutput['chunkFormat']): this; enabledChunkLoadingTypes( value: RspackOutput['enabledChunkLoadingTypes'], ): this; crossOriginLoading(value: RspackOutput['crossOriginLoading']): this; devtoolFallbackModuleFilenameTemplate( value: RspackOutput['devtoolFallbackModuleFilenameTemplate'], ): this; devtoolModuleFilenameTemplate( value: RspackOutput['devtoolModuleFilenameTemplate'], ): this; devtoolNamespace(value: RspackOutput['devtoolNamespace']): this; filename(value: RspackOutput['filename']): this; assetModuleFilename(value: RspackOutput['assetModuleFilename']): this; globalObject(value: RspackOutput['globalObject']): this; uniqueName(value: RspackOutput['uniqueName']): this; hashDigest(value: RspackOutput['hashDigest']): this; hashDigestLength(value: RspackOutput['hashDigestLength']): this; hashFunction(value: RspackOutput['hashFunction']): this; hashSalt(value: RspackOutput['hashSalt']): this; hotUpdateChunkFilename(value: RspackOutput['hotUpdateChunkFilename']): this; hotUpdateGlobal(value: RspackOutput['hotUpdateGlobal']): this; hotUpdateMainFilename(value: RspackOutput['hotUpdateMainFilename']): this; library(value: RspackOutput['library']): this; libraryExport(value: RspackOutput['libraryExport']): this; libraryTarget(value: RspackOutput['libraryTarget']): this; importFunctionName(value: RspackOutput['importFunctionName']): this; path(value: RspackOutput['path']): this; pathinfo(value: RspackOutput['pathinfo']): this; publicPath(value: RspackOutput['publicPath']): this; scriptType(value: RspackOutput['scriptType']): this; sourceMapFilename(value: RspackOutput['sourceMapFilename']): this; sourcePrefix(value: RspackOutput['sourcePrefix']): this; strictModuleErrorHandling( value: RspackOutput['strictModuleErrorHandling'], ): this; strictModuleExceptionHandling( value: RspackOutput['strictModuleExceptionHandling'], ): this; umdNamedDefine(value: RspackOutput['umdNamedDefine']): this; workerChunkLoading(value: RspackOutput['workerChunkLoading']): this; enabledLibraryTypes(value: RspackOutput['enabledLibraryTypes']): this; environment(value: RspackOutput['environment']): this; compareBeforeEmit(value: RspackOutput['compareBeforeEmit']): this; wasmLoading(value: RspackOutput['wasmLoading']): this; enabledWasmLoadingTypes( value: RspackOutput['enabledWasmLoadingTypes'], ): this; iife(value: RspackOutput['iife']): this; module(value: RspackOutput['module']): this; clean(value: RspackOutput['clean']): this; } // await for @types/webpack-dev-server update do v4 to remove all any class DevServer extends ChainedMap { allowedHosts: TypedChainedSet; after(value: (app: any, server: any, compiler: Compiler) => void): this; before(value: (app: any, server: any, compiler: Compiler) => void): this; bonjour(value: boolean): this; clientLogLevel( value: | 'silent' | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'none' | 'warning', ): this; compress(value: boolean): this; contentBase(value: boolean | string | string[]): this; contentBasePublicPath(value: string): this; disableHostCheck(value: boolean): this; filename(value: string): this; headers(value: { [header: string]: string }): this; historyApiFallback(value: boolean | any): this; host(value: string): this; hot(value: boolean): this; hotOnly(value: boolean): this; http2(value: boolean): this; https(value: boolean | https.ServerOptions): this; index(value: string): this; injectClient(value: boolean | ((compiler: Compiler) => boolean)): this; injectHot(value: boolean | ((compiler: Compiler) => boolean)): this; inline(value: boolean): this; lazy(value: boolean): this; liveReload(value: boolean): this; mimeTypes(value: Object): this; noInfo(value: boolean): this; onListening(value: (server: any) => void): this; open(value: boolean): this; openPage(value: string | string[]): this; overlay(value: boolean | { warnings?: boolean; errors?: boolean }): this; pfx(value: string): this; pfxPassphrase(value: string): this; port(value: number): this; progress(value: boolean): this; proxy(value: any): this; public(value: string): this; publicPath(publicPath: string): this; quiet(value: boolean): this; serveIndex(value: boolean): this; setup(value: (expressApp: any) => void): this; socket(value: string): this; sockHost(value: string): this; sockPath(value: string): this; sockPort(value: number): this; staticOptions(value: any): this; stats(value: Configuration['stats']): this; stdin(value: boolean): this; transportMode( value: | 'sockjs' | 'ws' | { server: 'ws'; client: object; } | { client: 'sockjs'; server: object; } | { client: object; server: object; }, ): this; useLocalIp(value: boolean): this; watchContentBase(value: boolean): this; watchOptions(value: Configuration['watchOptions']): this; writeToDisk(value: boolean): this; } type RspackPerformance = Exclude< Required>, false >; class Performance extends ChainedMap { hints(value: RspackPerformance['hints']): this; maxEntrypointSize(value: RspackPerformance['maxEntrypointSize']): this; maxAssetSize(value: RspackPerformance['maxAssetSize']): this; assetFilter(value: RspackPerformance['assetFilter']): this; } type RspackResolve = Required>; type ResolvePlugin = Exclude< NonNullable[number], '...' >; class Resolve extends ChainedMap { alias: TypedChainedMap; aliasFields: TypedChainedSet; conditionNames: TypedChainedSet< this, RspackResolve['conditionNames'][number] >; descriptionFiles: TypedChainedSet< this, RspackResolve['descriptionFiles'][number] >; extensions: TypedChainedSet; mainFields: TypedChainedSet; mainFiles: TypedChainedSet; exportsFields: TypedChainedSet< this, RspackResolve['exportsFields'][number] >; importsFields: TypedChainedSet< this, RspackResolve['importsFields'][number] >; restrictions: TypedChainedSet; roots: TypedChainedSet; modules: TypedChainedSet; plugins: TypedChainedMap< this, { [key: string]: Plugin } >; fallback: TypedChainedMap< this, { [key: string]: string | false | string[] } >; byDependency: TypedChainedMap; cachePredicate(value: RspackResolve['cachePredicate']): this; cacheWithContext(value: RspackResolve['cacheWithContext']): this; enforceExtension(value: RspackResolve['enforceExtension']): this; symlinks(value: RspackResolve['symlinks']): this; unsafeCache(value: RspackResolve['unsafeCache']): this; preferRelative(value: RspackResolve['preferRelative']): this; preferAbsolute(value: RspackResolve['preferAbsolute']): this; plugin(name: string): Plugin; } class RuleResolve extends Resolve { fullySpecified(value: boolean): this; } class ResolveLoader extends Resolve { modules: ChainedSet; moduleExtensions: ChainedSet; packageMains: ChainedSet; } type RspackRuleSet = Required; class Rule extends ChainedMap implements Orderable { uses: TypedChainedMap; include: TypedChainedSet; exclude: TypedChainedSet; rules: TypedChainedMap }>; oneOfs: TypedChainedMap }>; resolve: RuleResolve>; enforce(value: RspackRuleSet['enforce']): this; issuer(value: RspackRuleSet['issuer']): this; issuerLayer(value: RspackRuleSet['issuerLayer']): this; layer(value: RspackRuleSet['layer']): this; mimetype(value: RspackRuleSet['mimetype']): this; parser(value: RspackRuleSet['parser']): this; generator(value: RspackRuleSet['generator']): this; resource(value: RspackRuleSet['resource']): this; resourceQuery(value: RspackRuleSet['resourceQuery']): this; sideEffects(value: RspackRuleSet['sideEffects']): this; test(value: RspackRuleSet['test']): this; type(value: RspackRuleSet['type']): this; use(name: string): Use; rule(name: string): Rule; oneOf(name: string): Rule; pre(): this; post(): this; before(name: string): this; after(name: string): this; } type RspackOptimization = Required< NonNullable >; type SplitChunksObject = Exclude; class Optimization extends ChainedMap { minimizer(name: string): Config.Plugin; splitChunks: TypedChainedMap & ((value: SplitChunksObject | false) => this); minimize(value: RspackOptimization['minimize']): this; runtimeChunk(value: RspackOptimization['runtimeChunk']): this; emitOnErrors(value: RspackOptimization['emitOnErrors']): this; moduleIds(value: RspackOptimization['moduleIds']): this; chunkIds(value: RspackOptimization['chunkIds']): this; nodeEnv(value: RspackOptimization['nodeEnv']): this; mangleWasmImports(value: RspackOptimization['mangleWasmImports']): this; removeAvailableModules( value: RspackOptimization['removeAvailableModules'], ): this; removeEmptyChunks(value: RspackOptimization['removeEmptyChunks']): this; mergeDuplicateChunks( value: RspackOptimization['mergeDuplicateChunks'], ): this; flagIncludedChunks(value: RspackOptimization['flagIncludedChunks']): this; providedExports(value: RspackOptimization['providedExports']): this; usedExports(value: RspackOptimization['usedExports']): this; concatenateModules(value: RspackOptimization['concatenateModules']): this; sideEffects(value: RspackOptimization['sideEffects']): this; portableRecords(value: RspackOptimization['portableRecords']): this; mangleExports(value: RspackOptimization['mangleExports']): this; innerGraph(value: RspackOptimization['innerGraph']): this; realContentHash(value: RspackOptimization['realContentHash']): this; } interface RuntimeChunk { name: string | RuntimeChunkFunction; } type RuntimeChunkFunction = (entryPoint: EntryPoint) => string; interface SplitChunksOptions { [name: string]: any; } interface LoaderOptions { [name: string]: any; } class Use extends ChainedMap implements Orderable { loader(value: string): this; options(value: LoaderOptions): this; tap(f: (options: LoaderOptions) => LoaderOptions): this; // Orderable before(name: string): this; after(name: string): this; } type DevTool = | 'eval' | 'eval-cheap-source-map' | 'eval-cheap-module-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'inline-source-map' | 'eval-nosources-cheap-source-map' | 'eval-nosources-cheap-module-source-map' | 'eval-nosources-source-map' | 'inline-nosources-cheap-source-map' | 'inline-nosources-cheap-module-source-map' | 'inline-nosources-source-map' | 'nosources-cheap-source-map' | 'nosources-cheap-module-source-map' | 'nosources-source-map' | 'hidden-nosources-cheap-source-map' | 'hidden-nosources-cheap-module-source-map' | 'hidden-nosources-source-map' | 'hidden-cheap-source-map' | 'hidden-cheap-module-source-map' | 'hidden-source-map' | '@eval' | '@eval-cheap-source-map' | '@eval-cheap-module-source-map' | '@eval-source-map' | '@cheap-source-map' | '@cheap-module-source-map' | '@source-map' | '@inline-cheap-source-map' | '@inline-cheap-module-source-map' | '@inline-source-map' | '@eval-nosources-cheap-source-map' | '@eval-nosources-cheap-module-source-map' | '@eval-nosources-source-map' | '@inline-nosources-cheap-source-map' | '@inline-nosources-cheap-module-source-map' | '@inline-nosources-source-map' | '@nosources-cheap-source-map' | '@nosources-cheap-module-source-map' | '@nosources-source-map' | '@hidden-nosources-cheap-source-map' | '@hidden-nosources-cheap-module-source-map' | '@hidden-nosources-source-map' | '@hidden-cheap-source-map' | '@hidden-cheap-module-source-map' | '@hidden-source-map' | '#eval' | '#eval-cheap-source-map' | '#eval-cheap-module-source-map' | '#eval-source-map' | '#cheap-source-map' | '#cheap-module-source-map' | '#source-map' | '#inline-cheap-source-map' | '#inline-cheap-module-source-map' | '#inline-source-map' | '#eval-nosources-cheap-source-map' | '#eval-nosources-cheap-module-source-map' | '#eval-nosources-source-map' | '#inline-nosources-cheap-source-map' | '#inline-nosources-cheap-module-source-map' | '#inline-nosources-source-map' | '#nosources-cheap-source-map' | '#nosources-cheap-module-source-map' | '#nosources-source-map' | '#hidden-nosources-cheap-source-map' | '#hidden-nosources-cheap-module-source-map' | '#hidden-nosources-source-map' | '#hidden-cheap-source-map' | '#hidden-cheap-module-source-map' | '#hidden-source-map' | '#@eval' | '#@eval-cheap-source-map' | '#@eval-cheap-module-source-map' | '#@eval-source-map' | '#@cheap-source-map' | '#@cheap-module-source-map' | '#@source-map' | '#@inline-cheap-source-map' | '#@inline-cheap-module-source-map' | '#@inline-source-map' | '#@eval-nosources-cheap-source-map' | '#@eval-nosources-cheap-module-source-map' | '#@eval-nosources-source-map' | '#@inline-nosources-cheap-source-map' | '#@inline-nosources-cheap-module-source-map' | '#@inline-nosources-source-map' | '#@nosources-cheap-source-map' | '#@nosources-cheap-module-source-map' | '#@nosources-source-map' | '#@hidden-nosources-cheap-source-map' | '#@hidden-nosources-cheap-module-source-map' | '#@hidden-nosources-source-map' | '#@hidden-cheap-source-map' | '#@hidden-cheap-module-source-map' | '#@hidden-source-map' | boolean; interface PluginClass { new (...opts: any[]): PluginType; } interface Orderable { before(name: string): this; after(name: string): this; } } export { Config as default };