@@ -57,6 +57,7 @@ export function getEntryPoints(
5757 }
5858
5959 const entryPoints = options . getValue ( "entryPoints" ) ;
60+ const exclude = options . getValue ( "exclude" ) ;
6061
6162 // May be set explicitly to be an empty array to only include a readme for a package
6263 // See #2264
@@ -70,15 +71,15 @@ export function getEntryPoints(
7071 case EntryPointStrategy . Resolve :
7172 result = getEntryPointsForPaths (
7273 logger ,
73- expandGlobs ( entryPoints , logger ) ,
74+ expandGlobs ( entryPoints , exclude , logger ) ,
7475 options ,
7576 ) ;
7677 break ;
7778
7879 case EntryPointStrategy . Expand :
7980 result = getExpandedEntryPointsForPaths (
8081 logger ,
81- expandGlobs ( entryPoints , logger ) ,
82+ expandGlobs ( entryPoints , exclude , logger ) ,
8283 options ,
8384 ) ;
8485 break ;
@@ -108,17 +109,23 @@ export function getWatchEntryPoints(
108109 let result : DocumentationEntryPoint [ ] | undefined ;
109110
110111 const entryPoints = options . getValue ( "entryPoints" ) ;
111- switch ( options . getValue ( "entryPointStrategy" ) ) {
112+ const exclude = options . getValue ( "exclude" ) ;
113+ const strategy = options . getValue ( "entryPointStrategy" ) ;
114+
115+ switch ( strategy ) {
112116 case EntryPointStrategy . Resolve :
113- result = getEntryPointsForPaths ( logger , entryPoints , options , [
114- program ,
115- ] ) ;
117+ result = getEntryPointsForPaths (
118+ logger ,
119+ expandGlobs ( entryPoints , exclude , logger ) ,
120+ options ,
121+ [ program ] ,
122+ ) ;
116123 break ;
117124
118125 case EntryPointStrategy . Expand :
119126 result = getExpandedEntryPointsForPaths (
120127 logger ,
121- entryPoints ,
128+ expandGlobs ( entryPoints , exclude , logger ) ,
122129 options ,
123130 [ program ] ,
124131 ) ;
@@ -129,6 +136,15 @@ export function getWatchEntryPoints(
129136 "Watch mode does not support 'packages' style entry points." ,
130137 ) ;
131138 break ;
139+
140+ case EntryPointStrategy . Merge :
141+ logger . error (
142+ "Watch mode does not support 'merge' style entry points." ,
143+ ) ;
144+ break ;
145+
146+ default :
147+ assertNever ( strategy ) ;
132148 }
133149
134150 if ( result && result . length === 0 ) {
@@ -228,30 +244,43 @@ export function getExpandedEntryPointsForPaths(
228244 ) ;
229245}
230246
231- function expandGlobs ( inputFiles : string [ ] , logger : Logger ) {
247+ function expandGlobs ( inputFiles : string [ ] , exclude : string [ ] , logger : Logger ) {
248+ const excludePatterns = createMinimatch ( exclude ) ;
249+
232250 const base = deriveRootDir ( inputFiles ) ;
233251 const result = inputFiles . flatMap ( ( entry ) => {
234252 const result = glob ( entry , base , {
235253 includeDirectories : true ,
236254 followSymlinks : true ,
237255 } ) ;
238256
257+ const filtered = result . filter (
258+ ( file ) => file === entry || ! matchesAny ( excludePatterns , file ) ,
259+ ) ;
260+
239261 if ( result . length === 0 ) {
240262 logger . warn (
241263 `The entrypoint glob ${ nicePath (
242264 entry ,
243265 ) } did not match any files.`,
244266 ) ;
267+ } else if ( filtered . length === 0 ) {
268+ logger . warn (
269+ `The entrypoint glob ${ nicePath (
270+ entry ,
271+ ) } did not match any files after applying exclude patterns.`,
272+ ) ;
245273 } else {
246274 logger . verbose (
247- `Expanded ${ nicePath ( entry ) } to:\n\t${ result
275+ `Expanded ${ nicePath ( entry ) } to:\n\t${ filtered
248276 . map ( nicePath )
249277 . join ( "\n\t" ) } `,
250278 ) ;
251279 }
252280
253- return result ;
281+ return filtered ;
254282 } ) ;
283+
255284 return result ;
256285}
257286
0 commit comments