@@ -28,6 +28,8 @@ function formatSize(size) {
2828 } ;
2929}
3030
31+ // When using this we should always
32+ // compare byte size and then format later
3133function doesExceedLimit ( limit , actualSize ) {
3234 return limit < actualSize ;
3335}
@@ -63,7 +65,7 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
6365 emitted : compilation . assets [ asset ] . emitted
6466 } ;
6567
66- if ( formatSize ( obj . size ) . number > sizeLimit ) {
68+ if ( doesExceedLimit ( sizeLimit , obj . size ) ) {
6769 obj . isOverSizeLimit = true ;
6870 assetsOverSizeLimit . push ( obj ) ;
6971 }
@@ -111,6 +113,9 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
111113 } ) ;
112114
113115 files . forEach ( function ( file ) {
116+ if ( ! isAssetJsFile ( file ) ) {
117+ return ;
118+ }
114119 entrypoint . assets [ file ] = assetsByFile [ file ] ;
115120 entrypoint . size = entrypoint . size + assetsByFile [ file ] . size ;
116121 entrypoint . isOverSizeLimit = false ;
@@ -135,22 +140,29 @@ EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
135140 // 2. Collective Initial Chunks (Each Set?): Size < 200kb
136141 // 3. No Async Chunks
137142 // if !1, then 2, if !2 return
138- // if 1, then 2, then 3,
143+ // if 1, then 2, then 3,
139144
140145 if ( assetsOverSizeLimit . length ) {
141- warnings . push ( new AssetsOverSizeLimitWarning ( assetsOverSizeLimit , compilation , formatSize ) ) ;
142- warnings . push ( new EntrypointsOverSizeLimitWarning ( entrypointsOverSizeLimit , compilation , formatSize ) ) ;
146+ warnings . push ( new AssetsOverSizeLimitWarning ( assetsOverSizeLimit , compilation , formatSize , sizeLimit ) ) ;
147+ warnings . push ( new EntrypointsOverSizeLimitWarning ( entrypointsOverSizeLimit , compilation , formatSize , entrypointSizeLimit ) ) ;
148+
149+ if ( ! hasAsyncChunks ) {
150+ warnings . push ( new Error ( "webpack performance recommendations: \n" +
151+ "You can limit the size of your bundles by using System.import() or require.ensure to lazy load some parts of your application.\n" +
152+ "For more info visit https://webpack.github.io/docs/code-splitting.html"
153+ ) ) ;
154+ }
143155 } else {
144156 if ( entrypointsOverSizeLimit . legnth ) {
145- warnings . push ( new EntrypointsOverSizeLimitWarning ( entrypointsOverSizeLimit , compilation , formatSize ) ) ;
146- }
147- }
157+ warnings . push ( new EntrypointsOverSizeLimitWarning ( entrypointsOverSizeLimit , compilation , formatSize , entrypointSizeLimit ) ) ;
148158
149- if ( ! hasAsyncChunks ) {
150- warnings . push ( new Error ( "webpack performance recommendations: \n" +
151- "You can limit the size of your bundles by using System.import() or require.ensure to lazy load some parts of your application.\n" +
152- "For more info visit https://webpack.github.io/docs/code-splitting.html"
153- ) ) ;
159+ if ( ! hasAsyncChunks ) {
160+ warnings . push ( new Error ( "webpack performance recommendations: \n" +
161+ "You can limit the size of your bundles by using System.import() or require.ensure to lazy load some parts of your application.\n" +
162+ "For more info visit https://webpack.github.io/docs/code-splitting.html"
163+ ) ) ;
164+ }
165+ }
154166 }
155167
156168 if ( ! ! warnings . length ) {
0 commit comments