import { Bundle } from '../common' ; import { filterById } from './filter_by_id' ; export function focusBundles ( filters , bundles ) { if ( ! filters . length ) { return [ ... bundles ] ; } const queue = new Set < Bundle > ( filterById ( filters , bundles ) ) ; const focused = [ ] ; for ( const bundle of queue ) { focused . push ( bundle ) ; const { explicit , implicit } = bundle . readBundleDeps ( ) ; const depIds = [ ... explicit , ... implicit ] ; if ( depIds . length ) { for ( const dep of filterById ( depIds , bundles ) ) { queue . add ( dep ) ; } } } return focused ; }