diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index 97e23e02b..24710016f 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -321,29 +321,27 @@ class ModuleConcatenationPlugin { } getImports(module) { - return Array.from( - new Set( - module.dependencies + return new Set( + module.dependencies - // Only harmony Dependencies - .filter(dep => dep instanceof HarmonyImportDependency) + // Get reference info only for harmony Dependencies + .map( + dep => + dep instanceof HarmonyImportDependency ? dep.getReference() : null + ) - // Get reference info for this dependency - .map(dep => dep.getReference()) + // Reference is valid and has a module + // Dependencies are simple enough to concat them + .filter( + ref => + ref && + ref.module && + (Array.isArray(ref.importedNames) || + Array.isArray(ref.module.buildMeta.providedExports)) + ) - // Reference is valid and has a module - .filter(ref => ref && ref.module) - - // Dependencies are simple enough to concat them - .filter( - ref => - Array.isArray(ref.importedNames) || - Array.isArray(ref.module.buildMeta.providedExports) - ) - - // Take the imported module - .map(ref => ref.module) - ) + // Take the imported module + .map(ref => ref.module) ); }