@@ -254,6 +254,7 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
254
254
// SETTING THIS TO TRUE INSURES ALL CHUNKS ARE HANDLED:
255
255
var shouldExtract = true ; //!!(options.allChunks || chunk.isInitial());
256
256
257
+ chunk . sortModules ( ) ;
257
258
async . forEach ( getChunkModulesArray ( chunk ) , function ( module , callback ) {
258
259
var meta = module [ NS ] ;
259
260
if ( meta && ( ! meta . options . id || meta . options . id === id ) ) {
@@ -312,16 +313,14 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
312
313
// add the css files to assets and the files array corresponding to its chunks
313
314
compilation . plugin ( "additional-assets" , function ( callback ) {
314
315
extractedChunks . forEach ( function ( extractedChunk ) {
315
- var extractedChunkModules = getChunkModulesArray ( extractedChunk ) ;
316
-
317
- if ( extractedChunkModules . length ) {
318
- extractedChunkModules . sort ( function ( a , b ) {
319
- if ( ! options . ignoreOrder && isInvalidOrder ( a , b ) ) {
320
- compilation . errors . push ( new OrderUndefinedError ( a . getOriginalModule ( ) ) ) ;
321
- compilation . errors . push ( new OrderUndefinedError ( b . getOriginalModule ( ) ) ) ;
322
- }
323
- return getOrder ( a , b ) ;
324
- } ) ;
316
+ if ( extractedChunk . getNumberOfModules ( ) ) {
317
+ extractedChunk . sortModules ( ( a , b ) => {
318
+ if ( ! options . ignoreOrder && isInvalidOrder ( a , b ) ) {
319
+ compilation . errors . push ( new OrderUndefinedError ( a . getOriginalModule ( ) ) ) ;
320
+ compilation . errors . push ( new OrderUndefinedError ( b . getOriginalModule ( ) ) ) ;
321
+ }
322
+ return getOrder ( a , b ) ;
323
+ } ) ;
325
324
326
325
var stylesheet = this . renderExtractedChunk ( extractedChunk ) ;
327
326
var chunk = extractedChunk . originalChunk ;
0 commit comments