@@ -483,29 +483,27 @@ module.exports = cls => class Reifier extends cls {
483
483
484
484
process . emit ( 'time' , 'reify:trashOmits' )
485
485
486
- const filterTop = node => {
486
+ const omitNodes = this . idealTree . inventory . filter ( ( node ) => {
487
+ const { top } = node
487
488
// if the top is not the root or workspace filter it out
488
- if ( ! node . isProjectRoot && ! node . isWorkspace ) {
489
+ if ( ! top . isProjectRoot && ! top . isWorkspace ) {
489
490
return false
490
491
}
491
- // if we have no filter set, then include it by default
492
- if ( ! this . diff ?. filterSet ?. size ) {
493
- return true
492
+ // if there is a non-empty filter set, and our top node is not in it then
493
+ // it should be filtered out
494
+ if ( this . diff ?. filterSet ?. size && ! this . diff . filterSet . has ( top ) ) {
495
+ return false
494
496
}
495
- // otherwise include based on if the top node is in our filter set
496
- return this . diff . filterSet . has ( node )
497
- }
498
-
499
- const filter = node =>
500
- filterTop ( node . top ) &&
501
- (
502
- node . peer && this [ _omitPeer ] ||
503
- node . dev && this [ _omitDev ] ||
504
- node . optional && this [ _omitOptional ] ||
505
- node . devOptional && this [ _omitOptional ] && this [ _omitDev ]
506
- )
497
+ // then filter based on the dep type and which omit flags were set
498
+ return (
499
+ node . peer && this [ _omitPeer ] ||
500
+ node . dev && this [ _omitDev ] ||
501
+ node . optional && this [ _omitOptional ] ||
502
+ node . devOptional && this [ _omitOptional ] && this [ _omitDev ]
503
+ )
504
+ } )
507
505
508
- for ( const node of this . idealTree . inventory . filter ( filter ) ) {
506
+ for ( const node of omitNodes ) {
509
507
this [ _addNodeToTrashList ] ( node )
510
508
}
511
509
0 commit comments