@@ -81,11 +81,10 @@ export class RspackRscClientPlugin {
8181
8282 const addClientReferencesChunks = (
8383 compilation : Rspack . Compilation ,
84- entryModule : Rspack . Module ,
8584 callback : ( err : any | null ) => void ,
8685 ) => {
8786 const promises = [ ] ;
88- [ ...this . clientReferencesMap . keys ( ) ] . forEach ( ( resourcePath , index ) => {
87+ [ ...this . clientReferencesMap . keys ( ) ] . forEach ( resourcePath => {
8988 const entries = compilation . entries . entries ( ) ;
9089
9190 for ( const [ entryName , entry ] of entries ) {
@@ -159,47 +158,44 @@ export class RspackRscClientPlugin {
159158
160159 for ( const entryModule of entryModules ) {
161160 if ( entryModule ) {
162- addClientReferencesChunks ( compilation , entryModule , callback ) ;
161+ addClientReferencesChunks ( compilation , callback ) ;
163162 }
164163 }
165164 } ,
166165 ) ;
167166
168- compiler . hooks . compilation . tap (
169- RspackRscClientPlugin . name ,
170- ( compilation , { normalModuleFactory } ) => {
171- class EntryNameRuntimeModule extends RuntimeModule {
172- private entryName : string ;
173- constructor ( entryName : string ) {
174- super ( 'entry-name' , 10 ) ; // Set a higher stage to ensure priority execution
175- this . entryName = entryName ;
176- }
167+ compiler . hooks . compilation . tap ( RspackRscClientPlugin . name , compilation => {
168+ class EntryNameRuntimeModule extends RuntimeModule {
169+ private entryName : string ;
170+ constructor ( entryName : string ) {
171+ super ( 'entry-name' , 10 ) ; // Set a higher stage to ensure priority execution
172+ this . entryName = entryName ;
173+ }
177174
178- generate ( ) {
179- return `window.__MODERN_JS_ENTRY_NAME="${ this . entryName } ";` ;
180- }
175+ generate ( ) {
176+ return `window.__MODERN_JS_ENTRY_NAME="${ this . entryName } ";` ;
181177 }
178+ }
182179
183- compilation . hooks . runtimeRequirementInTree
184- . for ( RuntimeGlobals . ensureChunk )
185- . tap ( RspackRscClientPlugin . name , ( chunk , set ) => {
186- Array . from ( compilation . entrypoints . entries ( ) ) . forEach (
187- ( [ entryName , entrypoint ] ) => {
188- if ( entrypoint . chunks . includes ( chunk ) ) {
189- compilation . addRuntimeModule (
190- chunk ,
191- new EntryNameRuntimeModule ( entryName ) ,
192- ) ;
193- }
194- } ,
195- ) ;
196- } ) ;
197- } ,
198- ) ;
180+ compilation . hooks . runtimeRequirementInTree
181+ . for ( RuntimeGlobals . ensureChunk )
182+ . tap ( RspackRscClientPlugin . name , chunk => {
183+ Array . from ( compilation . entrypoints . entries ( ) ) . forEach (
184+ ( [ entryName , entrypoint ] ) => {
185+ if ( entrypoint . chunks . includes ( chunk ) ) {
186+ compilation . addRuntimeModule (
187+ chunk ,
188+ new EntryNameRuntimeModule ( entryName ) ,
189+ ) ;
190+ }
191+ } ,
192+ ) ;
193+ } ) ;
194+ } ) ;
199195
200196 compiler . hooks . thisCompilation . tap (
201197 RspackRscClientPlugin . name ,
202- ( compilation , { normalModuleFactory } ) => {
198+ compilation => {
203199 this . styles = sharedData . get ( 'styles' ) as Set < string > ;
204200 this . clientReferencesMap = sharedData . get (
205201 'clientReferencesMap' ,
0 commit comments