@@ -213,8 +213,9 @@ class ModuleConcatenationPlugin {
213213 const failureCache = new Map ( ) ;
214214
215215 // try to add all imports
216- for ( const imp of this . getImports ( currentRoot ) ) {
217- const problem = this . tryToAdd (
216+ for ( const imp of this . _getImports ( compilation , currentRoot ) ) {
217+ const problem = this . _tryToAdd (
218+ compilation ,
218219 currentConfiguration ,
219220 imp ,
220221 possibleInners ,
@@ -245,9 +246,15 @@ class ModuleConcatenationPlugin {
245246 for ( const concatConfiguration of concatConfigurations ) {
246247 if ( usedModules . has ( concatConfiguration . rootModule ) ) continue ;
247248 const modules = concatConfiguration . getModules ( ) ;
249+ const rootModule = concatConfiguration . rootModule ;
248250 const newModule = new ConcatenatedModule (
249- concatConfiguration . rootModule ,
250- modules
251+ rootModule ,
252+ Array . from ( modules ) ,
253+ ConcatenatedModule . createConcatenationList (
254+ rootModule ,
255+ modules ,
256+ compilation
257+ )
251258 ) ;
252259 for ( const warning of concatConfiguration . getWarningsSorted ( ) ) {
253260 newModule . optimizationBailout . push ( requestShortener => {
@@ -320,15 +327,16 @@ class ModuleConcatenationPlugin {
320327 ) ;
321328 }
322329
323- getImports ( module ) {
330+ _getImports ( compilation , module ) {
324331 return new Set (
325332 module . dependencies
326333
327334 // Get reference info only for harmony Dependencies
328- . map (
329- dep =>
330- dep instanceof HarmonyImportDependency ? dep . getReference ( ) : null
331- )
335+ . map ( dep => {
336+ if ( ! ( dep instanceof HarmonyImportDependency ) ) return null ;
337+ if ( ! compilation ) return dep . getReference ( ) ;
338+ return compilation . getDependencyReference ( module , dep ) ;
339+ } )
332340
333341 // Reference is valid and has a module
334342 // Dependencies are simple enough to concat them
@@ -345,7 +353,7 @@ class ModuleConcatenationPlugin {
345353 ) ;
346354 }
347355
348- tryToAdd ( config , module , possibleModules , failureCache ) {
356+ _tryToAdd ( compilation , config , module , possibleModules , failureCache ) {
349357 const cacheEntry = failureCache . get ( module ) ;
350358 if ( cacheEntry ) {
351359 return cacheEntry ;
@@ -383,7 +391,8 @@ class ModuleConcatenationPlugin {
383391 )
384392 continue ;
385393
386- const problem = this . tryToAdd (
394+ const problem = this . _tryToAdd (
395+ compilation ,
387396 testConfig ,
388397 reason . module ,
389398 possibleModules ,
@@ -399,8 +408,14 @@ class ModuleConcatenationPlugin {
399408 config . set ( testConfig ) ;
400409
401410 // Eagerly try to add imports too if possible
402- for ( const imp of this . getImports ( module ) ) {
403- const problem = this . tryToAdd ( config , imp , possibleModules , failureCache ) ;
411+ for ( const imp of this . _getImports ( compilation , module ) ) {
412+ const problem = this . _tryToAdd (
413+ compilation ,
414+ config ,
415+ imp ,
416+ possibleModules ,
417+ failureCache
418+ ) ;
404419 if ( problem ) {
405420 config . addWarning ( imp , problem ) ;
406421 }
@@ -451,7 +466,7 @@ class ConcatConfiguration {
451466 }
452467
453468 getModules ( ) {
454- return this . modules . asArray ( ) ;
469+ return this . modules . asSet ( ) ;
455470 }
456471
457472 clone ( ) {
0 commit comments