diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index 9d1a484bc28..230ad119808 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -229,7 +229,7 @@ export const BannerPlugin: { new (args: BannerPluginArgument): { name: BuiltinPluginName; _args: [args: BannerPluginArgument]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -716,6 +716,7 @@ export class Compilation { runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>; seal: liteTapable.SyncHook<[], void>; afterSeal: liteTapable.AsyncSeriesHook<[], void>; + needAdditionalPass: liteTapable.SyncBailHook<[], boolean>; }>; // (undocumented) inputFileSystem: InputFileSystem | null; @@ -737,6 +738,8 @@ export class Compilation { get namedChunkGroups(): ReadonlyMap>; get namedChunks(): ReadonlyMap>; // (undocumented) + needAdditionalPass: boolean; + // (undocumented) options: RspackOptionsNormalized; // (undocumented) outputOptions: OutputNormalized; @@ -869,6 +872,7 @@ export class Compiler { afterCompile: liteTapable.AsyncSeriesHook<[Compilation]>; finishMake: liteTapable.AsyncSeriesHook<[Compilation]>; entryOption: liteTapable.SyncBailHook<[string, EntryNormalized], any>; + additionalPass: liteTapable.AsyncSeriesHook<[]>; }; // (undocumented) idle: boolean; @@ -1162,7 +1166,7 @@ export const ContextReplacementPlugin: { new (resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): { name: BuiltinPluginName; _args: [resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1173,7 +1177,7 @@ export const CopyRspackPlugin: { new (copy: CopyRspackPluginOptions): { name: BuiltinPluginName; _args: [copy: CopyRspackPluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1305,7 +1309,7 @@ export const DefinePlugin: { new (define: DefinePluginOptions): { name: BuiltinPluginName; _args: [define: DefinePluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1552,7 +1556,7 @@ const ElectronTargetPlugin: { new (context?: string | undefined): { name: BuiltinPluginName; _args: [context?: string | undefined]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1563,7 +1567,7 @@ const EnableChunkLoadingPlugin: { new (type: string): { name: BuiltinPluginName; _args: [type: string]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1596,7 +1600,7 @@ const EnableWasmLoadingPlugin: { new (type: string): { name: BuiltinPluginName; _args: [type: string]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1688,7 +1692,7 @@ export const EntryPlugin: { new (context: string, entry: string, options?: string | EntryOptions | undefined): { name: BuiltinPluginName; _args: [context: string, entry: string, options?: string | EntryOptions | undefined]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1853,7 +1857,7 @@ export const EvalDevToolModulePlugin: { new (options: EvalDevToolModulePluginOptions): { name: BuiltinPluginName; _args: [options: EvalDevToolModulePluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -1866,7 +1870,7 @@ export const EvalSourceMapDevToolPlugin: { new (options: SourceMapDevToolPluginOptions): { name: BuiltinPluginName; _args: [options: SourceMapDevToolPluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -2080,7 +2084,7 @@ const FetchCompileAsyncWasmPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -2283,7 +2287,7 @@ const HtmlRspackPluginImpl: { new (c?: HtmlRspackPluginOptions | undefined): { name: BuiltinPluginName; _args: [c?: HtmlRspackPluginOptions | undefined]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler): BuiltinPlugin; apply(compiler: Compiler): void; }; @@ -2346,7 +2350,7 @@ export const IgnorePlugin: { new (options: IgnorePluginOptions): { name: BuiltinPluginName; _args: [options: IgnorePluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3187,7 +3191,7 @@ export const LightningCssMinimizerRspackPlugin: { new (options?: LightningCssMinimizerRspackPluginOptions | undefined): { name: BuiltinPluginName; _args: [options?: LightningCssMinimizerRspackPluginOptions | undefined]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3224,7 +3228,7 @@ const LimitChunkCountPlugin: { new (options: LimitChunkCountOptions): { name: BuiltinPluginName; _args: [options: LimitChunkCountOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3883,7 +3887,7 @@ const NodeTargetPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -3906,7 +3910,7 @@ export const NoEmitOnErrorsPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4515,7 +4519,7 @@ export const ProgressPlugin: { new (progress?: ProgressPluginArgument): { name: BuiltinPluginName; _args: [progress?: ProgressPluginArgument]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4529,7 +4533,7 @@ export const ProvidePlugin: { new (provide: ProvidePluginOptions): { name: BuiltinPluginName; _args: [provide: ProvidePluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -4834,7 +4838,7 @@ const RemoveDuplicateModulesPlugin: { new (): { name: BuiltinPluginName; _args: []; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -9613,7 +9617,7 @@ const RuntimeChunkPlugin: { new (options: RawRuntimeChunkOptions): { name: BuiltinPluginName; _args: [options: RawRuntimeChunkOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -9907,7 +9911,7 @@ export const SourceMapDevToolPlugin: { new (options: SourceMapDevToolPluginOptions): { name: BuiltinPluginName; _args: [options: SourceMapDevToolPluginOptions]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; @@ -10211,7 +10215,7 @@ export const SwcJsMinimizerRspackPlugin: { new (options?: SwcJsMinimizerRspackPluginOptions | undefined): { name: BuiltinPluginName; _args: [options?: SwcJsMinimizerRspackPluginOptions | undefined]; - affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined; + affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined; raw(compiler: Compiler_2): BuiltinPlugin; apply(compiler: Compiler_2): void; }; diff --git a/packages/rspack/src/Compilation.ts b/packages/rspack/src/Compilation.ts index 1c8bfd5d901..bc450c5a807 100644 --- a/packages/rspack/src/Compilation.ts +++ b/packages/rspack/src/Compilation.ts @@ -237,6 +237,7 @@ export class Compilation { runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>; seal: liteTapable.SyncHook<[], void>; afterSeal: liteTapable.AsyncSeriesHook<[], void>; + needAdditionalPass: liteTapable.SyncBailHook<[], boolean>; }>; name?: string; startTime?: number; @@ -271,6 +272,8 @@ export class Compilation { } >; + needAdditionalPass: boolean; + constructor(compiler: Compiler, inner: JsCompilation) { this.#inner = inner; this.#shutdown = false; @@ -373,7 +376,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si ), runtimeModule: new liteTapable.SyncHook(["module", "chunk"]), seal: new liteTapable.SyncHook([]), - afterSeal: new liteTapable.AsyncSeriesHook([]) + afterSeal: new liteTapable.AsyncSeriesHook([]), + needAdditionalPass: new liteTapable.SyncBailHook([]) }; this.compiler = compiler; this.resolverFactory = compiler.resolverFactory; @@ -383,6 +387,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si this.logging = new Map(); this.childrenCounters = {}; this.children = []; + this.needAdditionalPass = false; this.chunkGraph = ChunkGraph.__from_binding(inner.chunkGraph); this.moduleGraph = ModuleGraph.__from_binding(inner.moduleGraph); diff --git a/packages/rspack/src/Compiler.ts b/packages/rspack/src/Compiler.ts index a8104352740..db6ee11d4f5 100644 --- a/packages/rspack/src/Compiler.ts +++ b/packages/rspack/src/Compiler.ts @@ -133,6 +133,7 @@ class Compiler { afterCompile: liteTapable.AsyncSeriesHook<[Compilation]>; finishMake: liteTapable.AsyncSeriesHook<[Compilation]>; entryOption: liteTapable.SyncBailHook<[string, EntryNormalized], any>; + additionalPass: liteTapable.AsyncSeriesHook<[]>; }; webpack: typeof rspack; @@ -221,7 +222,8 @@ class Compiler { beforeCompile: new liteTapable.AsyncSeriesHook(["params"]), afterCompile: new liteTapable.AsyncSeriesHook(["compilation"]), finishMake: new liteTapable.AsyncSeriesHook(["compilation"]), - entryOption: new liteTapable.SyncBailHook(["context", "entry"]) + entryOption: new liteTapable.SyncBailHook(["context", "entry"]), + additionalPass: new liteTapable.AsyncSeriesHook([]) }; this.webpack = rspack; @@ -430,20 +432,62 @@ class Compiler { } const startTime = Date.now(); this.running = true; - const doRun = () => { - const finalCallback = (err: Error | null, stats?: Stats) => { - this.idle = true; - this.cache.beginIdle(); - this.idle = true; - this.running = false; + + const finalCallback = (err: Error | null, stats?: Stats) => { + this.idle = true; + this.cache.beginIdle(); + this.idle = true; + this.running = false; + if (err) { + this.hooks.failed.call(err); + } + if (callback) { + callback(err, stats); + } + this.hooks.afterDone.call(stats!); + }; + + const onCompiled = ( + err: Error | null, + _compilation: Compilation | undefined + ) => { + if (err) { + return finalCallback(err); + } + + const compilation = _compilation!; + + if (compilation.hooks.needAdditionalPass.call()) { + compilation.needAdditionalPass = true; + + compilation.startTime = startTime; + compilation.endTime = Date.now(); + const stats = new Stats(compilation); + this.hooks.done.callAsync(stats, err => { + if (err) { + return finalCallback(err); + } + + this.hooks.additionalPass.callAsync(err => { + if (err) return finalCallback(err); + this.compile(onCompiled); + }); + }); + return; + } + + compilation.startTime = startTime; + compilation.endTime = Date.now(); + const stats = new Stats(compilation); + this.hooks.done.callAsync(stats, err => { if (err) { - this.hooks.failed.call(err); - } - if (callback) { - callback(err, stats); + return finalCallback(err); } - this.hooks.afterDone.call(stats!); - }; + return finalCallback(null, stats); + }); + }; + + const run = () => { this.hooks.beforeRun.callAsync(this, err => { if (err) { return finalCallback(err); @@ -452,21 +496,7 @@ class Compiler { if (err) { return finalCallback(err); } - - this.compile(err => { - if (err) { - return finalCallback(err); - } - this.#compilation!.startTime = startTime; - this.#compilation!.endTime = Date.now(); - const stats = new Stats(this.#compilation!); - this.hooks.done.callAsync(stats, err => { - if (err) { - return finalCallback(err); - } - return finalCallback(null, stats); - }); - }); + this.compile(onCompiled); }); }); }; @@ -474,12 +504,11 @@ class Compiler { if (this.idle) { this.cache.endIdle(err => { if (err) return callback(err); - this.idle = false; - doRun(); + run(); }); } else { - doRun(); + run(); } } diff --git a/packages/rspack/src/Watching.ts b/packages/rspack/src/Watching.ts index e96d4bc6b21..df337c575a8 100644 --- a/packages/rspack/src/Watching.ts +++ b/packages/rspack/src/Watching.ts @@ -266,18 +266,40 @@ export class Watching { this.invalid = false; this.#invalidReported = false; this.compiler.hooks.watchRun.callAsync(this.compiler, err => { - if (err) return this._done(err, null); + if (err) return this._done(err); const canRebuild = !this.#initial && (modifiedFiles?.size || deleteFiles?.size); - const onCompile = (err: Error | null) => { - if (err) return this._done(err, null); - // if (this.invalid) return this._done(null); + const onCompiled = ( + err: Error | null, + _compilation: Compilation | undefined + ) => { + if (err) return this._done(err); + + const compilation = _compilation!; + + const needAdditionalPass = compilation.hooks.needAdditionalPass.call(); + if (needAdditionalPass) { + compilation.needAdditionalPass = true; + + compilation.startTime = this.startTime; + compilation.endTime = Date.now(); + const stats = new Stats(compilation); + this.compiler.hooks.done.callAsync(stats, err => { + if (err) return this._done(err, compilation); + + this.compiler.hooks.additionalPass.callAsync(err => { + if (err) return this._done(err, compilation); + this.compiler.compile(onCompiled); + }); + }); + return; + } this._done(null, this.compiler._lastCompilation!); }; - this.compiler.compile(onCompile); + this.compiler.compile(onCompiled); if (!canRebuild) { this.#initial = false; } @@ -288,9 +310,7 @@ export class Watching { * The reason why this is _done instead of #done, is that in Webpack, * it will rewrite this function to another function */ - private _done(error: Error, compilation: null): void; - private _done(error: null, compilation: Compilation): void; - private _done(error: Error | null, compilation: Compilation | null) { + private _done(error: Error | null, compilation?: Compilation) { this.running = false; let stats: undefined | Stats = undefined; diff --git a/tests/webpack-test/configCases/additional-pass/simple/test.filter.js b/tests/webpack-test/configCases/additional-pass/simple/test.filter.js deleted file mode 100644 index f15c07392d5..00000000000 --- a/tests/webpack-test/configCases/additional-pass/simple/test.filter.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => { return 'https://github.com/web-infra-dev/rspack/issues/8485' }