File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,11 @@ function isValidChunkAsset(chunkAsset) {
171171 return chunkAsset . scriptType && ! HOT_UPDATE_REGEXP . test ( chunkAsset . filename )
172172}
173173
174+ const JS_FILE = / \. j s $ /
175+ function checkIfChunkIncludesJs ( chunkInfo ) {
176+ return chunkInfo . files . some ( file => JS_FILE . test ( file . split ( '?' ) [ 0 ] ) )
177+ }
178+
174179class ChunkExtractor {
175180 constructor ( {
176181 statsFile,
@@ -201,6 +206,12 @@ class ChunkExtractor {
201206 return chunkGroup
202207 }
203208
209+ getChunkInfo ( chunkId ) {
210+ const chunkInfo = this . stats . chunks . find ( chunk => chunk . id === chunkId )
211+ invariant ( chunkInfo , `cannot find chunk (chunkId: ${ chunkId } ) in stats` )
212+ return chunkInfo
213+ }
214+
204215 createChunkAsset ( { filename, chunk, type, linkType } ) {
205216 const resolvedFilename =
206217 typeof filename === 'object' && filename . name ? filename . name : filename
@@ -269,7 +280,17 @@ class ChunkExtractor {
269280 getChunkDependencies ( chunks ) {
270281 const one = chunk => {
271282 const chunkGroup = this . getChunkGroup ( chunk )
272- return chunkGroup . chunks
283+
284+ // ignore chunk that only contains css files.
285+ return chunkGroup . chunks . filter ( chunkId => {
286+ const chunkInfo = this . getChunkInfo ( chunkId )
287+
288+ if ( ! chunkInfo ) {
289+ return false
290+ }
291+
292+ return checkIfChunkIncludesJs ( chunkInfo )
293+ } )
273294 }
274295
275296 if ( Array . isArray ( chunks ) ) {
Original file line number Diff line number Diff line change @@ -22,12 +22,19 @@ class LoadablePlugin {
2222 hash : true ,
2323 publicPath : true ,
2424 assets : true ,
25- chunks : false ,
25+ chunks : true ,
2626 modules : false ,
2727 source : false ,
2828 errorDetails : false ,
2929 timings : false ,
3030 } )
31+
32+ stats . chunks = stats . chunks . map ( chunk => ( {
33+ ...chunk ,
34+ modules : [ ] , // in case modules array is big
35+ origins : [ ] , // in case origins array is big
36+ } ) )
37+
3138 const result = JSON . stringify ( stats , null , 2 )
3239
3340 if ( this . opts . writeToDisk ) {
You can’t perform that action at this time.
0 commit comments