@@ -13,7 +13,13 @@ import {
13
13
moduleFederationPlugin ,
14
14
RemoteEntryType ,
15
15
} from '@module-federation/sdk' ;
16
- import { Compilation , Compiler , StatsCompilation , StatsModule } from 'webpack' ;
16
+ import {
17
+ Compilation ,
18
+ Compiler ,
19
+ StatsCompilation ,
20
+ StatsModule ,
21
+ Chunk ,
22
+ } from 'webpack' ;
17
23
import {
18
24
isDev ,
19
25
getAssetsByChunk ,
@@ -86,8 +92,10 @@ class StatsManager {
86
92
const remoteEntryNameChunk = compilation . namedChunks . get ( name ) ;
87
93
88
94
assert ( remoteEntryNameChunk , 'Can not get remoteEntry chunk!' ) ;
89
- const files = Array . from ( remoteEntryNameChunk . files ) . filter (
90
- ( f ) => ! f . includes ( HOT_UPDATE_SUFFIX ) && ! f . endsWith ( '.css' ) ,
95
+ const files = Array . from (
96
+ remoteEntryNameChunk . files as Iterable < string > ,
97
+ ) . filter (
98
+ ( f : string ) => ! f . includes ( HOT_UPDATE_SUFFIX ) && ! f . endsWith ( '.css' ) ,
91
99
) ;
92
100
assert ( files . length > 0 , 'no files found for remoteEntry chunk' ) ;
93
101
assert (
@@ -209,25 +217,31 @@ class StatsManager {
209
217
const [ sharedModuleName , sharedModule ] = item ;
210
218
if ( ! manifestOverrideChunkIDMap [ sharedModuleName ] ) {
211
219
manifestOverrideChunkIDMap [ sharedModuleName ] = {
212
- async : new Set ( ) ,
213
- sync : new Set ( ) ,
220
+ async : new Set < string | number > ( ) ,
221
+ sync : new Set < string | number > ( ) ,
214
222
} ;
215
223
}
216
- sharedModule . chunks ! . forEach ( ( chunkID ) => {
224
+ sharedModule . chunks ! . forEach ( ( chunkID : string | number ) => {
217
225
const chunk = findChunk ( chunkID , compilation . chunks ) ;
218
226
219
227
manifestOverrideChunkIDMap [ sharedModuleName ] . sync . add ( chunkID ) ;
220
- Array . from ( chunk ! . getAllInitialChunks ( ) ) . forEach ( ( syncChunk ) => {
221
- syncChunk . id &&
222
- manifestOverrideChunkIDMap [ sharedModuleName ] . sync . add ( syncChunk . id ) ;
223
- } ) ;
228
+ Array . from ( chunk ! . getAllInitialChunks ( ) as Iterable < Chunk > ) . forEach (
229
+ ( syncChunk : Chunk ) => {
230
+ syncChunk . id &&
231
+ manifestOverrideChunkIDMap [ sharedModuleName ] . sync . add (
232
+ syncChunk . id ,
233
+ ) ;
234
+ } ,
235
+ ) ;
224
236
225
- Array . from ( chunk ! . getAllAsyncChunks ( ) ) . forEach ( ( asyncChunk ) => {
226
- asyncChunk . id &&
227
- manifestOverrideChunkIDMap [ sharedModuleName ] . async . add (
228
- asyncChunk . id ,
229
- ) ;
230
- } ) ;
237
+ Array . from ( chunk ! . getAllAsyncChunks ( ) as Iterable < Chunk > ) . forEach (
238
+ ( asyncChunk : Chunk ) => {
239
+ asyncChunk . id &&
240
+ manifestOverrideChunkIDMap [ sharedModuleName ] . async . add (
241
+ asyncChunk . id ,
242
+ ) ;
243
+ } ,
244
+ ) ;
231
245
} ) ;
232
246
} ) ;
233
247
0 commit comments