private List < JSModule > makeWeakModule ( List < JSModule > modulesInDepOrder ) { boolean hasWeakModule = false ; for ( JSModule module : modulesInDepOrder ) { if ( module . getName ( ) . equals ( JSModule . WEAK_MODULE_NAME ) ) { hasWeakModule = true ; Set < JSModule > allOtherModules = new HashSet <> ( modulesInDepOrder ) ; allOtherModules . remove ( module ) ; checkState ( module . getAllDependencies ( ) . containsAll ( allOtherModules ) , "A weak module already exists but it does not depend on every other module." ) ; checkState ( module . getAllDependencies ( ) . size ( ) == allOtherModules . size ( ) , "The weak module cannot have extra dependencies." ) ; break ; } } if ( hasWeakModule ) { // All weak files (and only weak files) should be in the weak module. for ( JSModule module : modulesInDepOrder ) { for ( CompilerInput input : module . getInputs ( ) ) { if ( module . getName ( ) . equals ( JSModule . WEAK_MODULE_NAME ) ) { checkState ( input . getSourceFile ( ) . isWeak ( ) , "A weak module already exists but strong sources were found in it." ) ; } else { checkState ( ! input . getSourceFile ( ) . isWeak ( ) , "A weak module already exists but weak sources were found in other modules." ) ; } } } } else { JSModule weakModule = new JSModule ( JSModule . WEAK_MODULE_NAME ) ; for ( JSModule module : modulesInDepOrder ) { weakModule . addDependency ( module ) ; } modulesInDepOrder = new ArrayList <> ( modulesInDepOrder ) ; modulesInDepOrder . add ( weakModule ) ; } return modulesInDepOrder ; }
If a weak module doesn t already exist creates a weak module depending on every other module .