@@ -51,7 +51,14 @@ export function getAffectedGlobModules(
5151) : ModuleNode [ ] {
5252 const modules : ModuleNode [ ] = [ ]
5353 for ( const [ id , allGlobs ] of server . _importGlobMap ! ) {
54- if ( allGlobs . some ( ( glob ) => isMatch ( file , glob ) ) )
54+ // (glob1 || glob2) && !glob3 && !glob4...
55+ if (
56+ allGlobs . some (
57+ ( { affirmed, negated } ) =>
58+ ( ! affirmed . length || affirmed . some ( ( glob ) => isMatch ( file , glob ) ) ) &&
59+ ( ! negated . length || negated . every ( ( glob ) => isMatch ( file , glob ) ) ) ,
60+ )
61+ )
5562 modules . push ( ...( server . moduleGraph . getModulesByFile ( id ) || [ ] ) )
5663 }
5764 modules . forEach ( ( i ) => {
@@ -83,7 +90,18 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin {
8390 if ( result ) {
8491 if ( server ) {
8592 const allGlobs = result . matches . map ( ( i ) => i . globsResolved )
86- server . _importGlobMap . set ( id , allGlobs )
93+ server . _importGlobMap . set (
94+ id ,
95+ allGlobs . map ( ( globs ) => {
96+ const affirmed : string [ ] = [ ]
97+ const negated : string [ ] = [ ]
98+
99+ for ( const glob of globs ) {
100+ ; ( glob [ 0 ] === '!' ? negated : affirmed ) . push ( glob )
101+ }
102+ return { affirmed, negated }
103+ } ) ,
104+ )
87105 }
88106 return transformStableResult ( result . s , id , config )
89107 }
0 commit comments