@@ -23,12 +23,6 @@ function doesExceedLimit(limit, actualSize) {
2323 return limit < actualSize ;
2424}
2525
26- function isAssetJsFile ( assetFilename ) {
27- var jsRegex = / \. j s ( $ | \? ) / i;
28-
29- return jsRegex . test ( assetFilename ) ;
30- }
31-
3226EmittedAssetSizeLimitPlugin . prototype . apply = function ( compiler ) {
3327 if ( ! this . hints ) {
3428 return ;
@@ -38,67 +32,41 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
3832 var hints = this . hints ;
3933 var shouldErrorOnHint = this . errorOnHint ;
4034
41- compiler . plugin ( "emit" , function ( compilation , callback ) {
35+ compiler . plugin ( "after- emit" , function ( compilation , callback ) {
4236 var warnings = [ ] ;
43- var assetsByFile = { } ;
4437 var assetsOverSizeLimit = [ ] ;
45- var entrypointsOverSizeLimit = [ ] ;
4638
47- var assets = Object . keys ( compilation . assets ) . map ( function ( asset ) {
39+ Object . keys ( compilation . assets ) . forEach ( function ( asset ) {
4840 var obj = {
4941 name : asset ,
50- size : compilation . assets [ asset ] . size ( ) ,
51- chunks : [ ] ,
52- chunkNames : [ ] ,
53- emitted : compilation . assets [ asset ] . emitted
42+ size : compilation . assets [ asset ] . size ( )
5443 } ;
5544
5645 if ( doesExceedLimit ( sizeLimit , obj . size ) ) {
5746 obj . isOverSizeLimit = true ;
5847 assetsOverSizeLimit . push ( obj ) ;
5948 compilation . assets [ asset ] . isOverSizeLimit = true ;
6049 }
61-
62- assetsByFile [ asset ] = obj ;
63- return obj ;
64- } ) . filter ( function ( asset ) {
65- return asset . emitted ;
66- } ) ;
67-
68- compilation . chunks . forEach ( function ( chunk ) {
69- chunk . files . forEach ( function ( asset ) {
70- if ( assetsByFile [ asset ] ) {
71- chunk . ids . forEach ( function ( id ) {
72- assetsByFile [ asset ] . chunks . push ( id ) ;
73- } ) ;
74- if ( chunk . name ) {
75- assetsByFile [ asset ] . chunkNames . push ( chunk . name ) ;
76- }
77- }
78- } ) ;
7950 } ) ;
8051
8152 var hasAsyncChunks = compilation . chunks . filter ( function ( chunk ) {
8253 return ! chunk . isInitial ( ) ;
8354 } ) . length > 0 ;
8455
8556 var entrypointsOverLimit = Object . keys ( compilation . entrypoints )
86- . map ( function ( key ) {
87- return compilation . entrypoints [ key ]
88- } )
57+ . map ( function ( key ) { return compilation . entrypoints [ key ] } )
8958 . filter ( function ( entry ) {
90- return doesExceedLimit ( entrypointSizeLimit , entry . getSize ( ) )
91- } )
59+ return doesExceedLimit ( entrypointSizeLimit , entry . getSize ( compilation ) )
60+ } ) ;
9261
9362 // 1. Individual Chunk: Size < 250kb
9463 // 2. Collective Initial Chunks [entrypoint] (Each Set?): Size < 250kb
9564 // 3. No Async Chunks
9665 // if !1, then 2, if !2 return
97- if ( assetsOverSizeLimit . length ) {
66+ if ( assetsOverSizeLimit . length > 0 ) {
9867 warnings . push (
9968 new AssetsOverSizeLimitWarning (
10069 assetsOverSizeLimit ,
101- compilation ,
10270 sizeLimit
10371 )
10472 ) ;
@@ -115,10 +83,10 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
11583 warnings . push ( new NoAsyncChunksWarning ( ) ) ;
11684 }
11785 } else {
118- if ( entrypointsOverSizeLimit . legnth ) {
86+ if ( entrypointsOverLimit . legnth > 0 ) {
11987 warnings . push (
12088 new EntrypointsOverSizeLimitWarning (
121- entrypointsOverSizeLimit ,
89+ entrypointsOverLimit ,
12290 compilation ,
12391 entrypointSizeLimit
12492 )
@@ -130,7 +98,7 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
13098 }
13199 }
132100
133- if ( warnings . length ) {
101+ if ( warnings . length > 0 ) {
134102 if ( shouldErrorOnHint ) {
135103 Array . prototype . push . apply ( compilation . errors , warnings ) ;
136104 } else {
0 commit comments