@@ -101,15 +101,15 @@ export function extractFunctionEntries(
101
101
* @param root the root of the dependency tree
102
102
* @param rootDeps array of top level root dependencies to whitelist
103
103
*/
104
- export const flatDep = ( root : DependencyMap , rootDepsFilter : string [ ] ) : string [ ] => {
104
+ export const flatDep = ( root : DependencyMap , rootDepsFilter : string [ ] , excludes : '*' | string [ ] ) : string [ ] => {
105
105
const flattenedDependencies = new Set < string > ( ) ;
106
106
107
107
/**
108
108
*
109
109
* @param deps the current tree
110
110
* @param filter the dependencies to get from this tree
111
111
*/
112
- const recursiveFind = ( deps : DependencyMap | undefined , filter ?: string [ ] ) => {
112
+ const recursiveFind = ( deps : DependencyMap | undefined , filter ?: string [ ] , excludes ?: '*' | string [ ] ) => {
113
113
if ( ! deps ) return ;
114
114
115
115
Object . entries ( deps ) . forEach ( ( [ depName , details ] ) => {
@@ -120,7 +120,7 @@ export const flatDep = (root: DependencyMap, rootDepsFilter: string[]): string[]
120
120
121
121
if ( details . isRootDep || filter ) {
122
122
// We already have this root dep and it's dependencies - skip this iteration
123
- if ( flattenedDependencies . has ( depName ) ) {
123
+ if ( flattenedDependencies . has ( depName ) || ( excludes && excludes != '*' && excludes . includes ( depName ) ) ) {
124
124
return ;
125
125
}
126
126
@@ -139,7 +139,7 @@ export const flatDep = (root: DependencyMap, rootDepsFilter: string[]): string[]
139
139
} ) ;
140
140
} ;
141
141
142
- recursiveFind ( root , rootDepsFilter ) ;
142
+ recursiveFind ( root , rootDepsFilter , excludes ) ;
143
143
144
144
return Array . from ( flattenedDependencies ) ;
145
145
} ;
0 commit comments