@@ -148,14 +148,6 @@ class Module extends DependenciesBlock {
148148 return this . reasons . length > 0 && this . reasons . every ( r => r . dependency && r . dependency . optional ) ;
149149 }
150150
151- forEachChunk ( fn ) {
152- this . _chunks . forEach ( fn ) ;
153- }
154-
155- mapChunks ( fn ) {
156- return Array . from ( this . _chunks , fn ) ;
157- }
158-
159151 getChunks ( ) {
160152 return Array . from ( this . _chunks ) ;
161153 }
@@ -302,6 +294,22 @@ class Module extends DependenciesBlock {
302294 }
303295}
304296
297+ // TODO remove in webpack 5
298+ Object . defineProperty ( Module . prototype , "forEachChunk" , {
299+ configurable : false ,
300+ value : util . deprecate ( function ( fn ) {
301+ this . _chunks . forEach ( fn ) ;
302+ } , "Module.forEachChunk: Use for(const chunk of module.chunksIterable) instead" )
303+ } ) ;
304+
305+ // TODO remove in webpack 5
306+ Object . defineProperty ( Module . prototype , "mapChunks" , {
307+ configurable : false ,
308+ value : util . deprecate ( function ( fn ) {
309+ return Array . from ( this . _chunks , fn ) ;
310+ } , "Module.mapChunks: Use Array.from(module.chunksIterable, fn) instead" )
311+ } ) ;
312+
305313Object . defineProperty ( Module . prototype , "entry" , {
306314 configurable : false ,
307315 get ( ) {
@@ -316,7 +324,7 @@ Object.defineProperty(Module.prototype, "chunks", {
316324 configurable : false ,
317325 get : util . deprecate ( function ( ) {
318326 return this . _chunks . getFromCache ( getFrozenArray ) ;
319- } , "Module.chunks: Use Module.forEachChunk/mapChunks /getNumberOfChunks/isInChunk/addChunk/removeChunk instead" ) ,
327+ } , "Module.chunks: Use Module.chunksIterable /getNumberOfChunks/isInChunk/addChunk/removeChunk instead" ) ,
320328 set ( ) {
321329 throw new Error ( "Readonly. Use Module.addChunk/removeChunk to modify chunks." ) ;
322330 }
0 commit comments