@@ -12,7 +12,6 @@ import {
12
12
type ExternalObject ,
13
13
type JsCompatSourceOwned ,
14
14
type JsCompilation ,
15
- type JsModule ,
16
15
type JsPathData ,
17
16
JsRspackSeverity ,
18
17
type JsRuntimeModule
@@ -53,7 +52,7 @@ import { LogType, Logger } from "./logging/Logger";
53
52
import { StatsFactory } from "./stats/StatsFactory" ;
54
53
import { StatsPrinter } from "./stats/StatsPrinter" ;
55
54
import { type AssetInfo , JsAssetInfo } from "./util/AssetInfo" ;
56
- import MergeCaller from "./util/MergeCaller " ;
55
+ import { AsyncTask } from "./util/AsyncTask " ;
57
56
import { createReadonlyMap } from "./util/createReadonlyMap" ;
58
57
import { createFakeCompilationDependencies } from "./util/fake" ;
59
58
import type { InputFileSystem } from "./util/fs" ;
@@ -1075,27 +1074,31 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1075
1074
) ;
1076
1075
}
1077
1076
1078
- #rebuildModuleCaller = ( ( compilation : Compilation ) =>
1079
- new MergeCaller (
1080
- ( args : Array < [ string , ( err : Error , m : Module ) => void ] > ) => {
1081
- compilation . #inner. rebuildModule (
1082
- args . map ( item => item [ 0 ] ) ,
1083
- ( err : Error , modules : JsModule [ ] ) => {
1084
- for ( const [ id , callback ] of args ) {
1085
- const m = modules . find ( item => item . moduleIdentifier === id ) ;
1086
- if ( m ) {
1087
- callback ( err , Module . __from_binding ( m ) ) ;
1088
- } else {
1089
- callback ( err || new Error ( "module no found" ) , null as any ) ;
1090
- }
1091
- }
1077
+ #rebuildModuleTask = new AsyncTask < string , Module > (
1078
+ ( moduleIdentifiers , doneWork ) => {
1079
+ this . #inner. rebuildModule (
1080
+ moduleIdentifiers ,
1081
+ ( err : Error | null , modules : binding . JsModule [ ] ) => {
1082
+ /*
1083
+ * TODO:
1084
+ * batch all call parameters, once a module is failed, we cannot know which module
1085
+ * is failed to rebuild, we have to make all modules failed, this should be improved
1086
+ * in the future
1087
+ */
1088
+ if ( err ) {
1089
+ doneWork ( new Array ( moduleIdentifiers . length ) . fill ( [ err , null ] ) ) ;
1090
+ } else {
1091
+ doneWork (
1092
+ modules . map ( jsModule => [ null , Module . __from_binding ( jsModule ) ] )
1093
+ ) ;
1092
1094
}
1093
- ) ;
1094
- }
1095
- ) ) ( this ) ;
1095
+ }
1096
+ ) ;
1097
+ }
1098
+ ) ;
1096
1099
1097
- rebuildModule ( m : Module , f : ( err : Error , m : Module ) => void ) {
1098
- this . #rebuildModuleCaller . push ( [ m . identifier ( ) , f ] ) ;
1100
+ rebuildModule ( m : Module , f : ( err : Error | null , m : Module | null ) => void ) {
1101
+ this . #rebuildModuleTask . exec ( m . identifier ( ) , f ) ;
1099
1102
}
1100
1103
1101
1104
addRuntimeModule ( chunk : Chunk , runtimeModule : RuntimeModule ) {
@@ -1248,7 +1251,7 @@ class AddIncludeDispatcher {
1248
1251
this . #cbs = [ ] ;
1249
1252
this . #inner( args , ( wholeErr , results ) => {
1250
1253
if ( this . #args. length !== 0 ) {
1251
- queueMicrotask ( this . #execute) ;
1254
+ queueMicrotask ( this . #execute. bind ( this ) ) ;
1252
1255
}
1253
1256
1254
1257
if ( wholeErr ) {
@@ -1281,7 +1284,7 @@ class AddIncludeDispatcher {
1281
1284
callback : ( err ?: null | WebpackError , module ?: Module ) => void
1282
1285
) {
1283
1286
if ( this . #args. length === 0 ) {
1284
- queueMicrotask ( this . #execute) ;
1287
+ queueMicrotask ( this . #execute. bind ( this ) ) ;
1285
1288
}
1286
1289
1287
1290
this . #args. push ( [ context , dependency , options as any ] ) ;
0 commit comments