Skip to content

Commit 30028f9

Browse files
authored
fix(glob): align hmr matcher options with glob enumeration (#22306)
1 parent a190035 commit 30028f9

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎packages/vite/src/node/plugins/importMetaGlob.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,30 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin {
6666
config.logger,
6767
)
6868
if (result) {
69-
const allGlobs = result.matches.map((i) => i.globsResolved)
7069
if (!importGlobMaps.has(this.environment)) {
7170
importGlobMaps.set(this.environment, new Map())
7271
}
7372

74-
const globMatchers = allGlobs.map((globs) => {
73+
const globMatchers = result.matches.map((i) => {
7574
const affirmed: string[] = []
7675
const negated: string[] = []
77-
for (const glob of globs) {
76+
for (const glob of i.globsResolved) {
7877
if (glob[0] === '!') {
7978
negated.push(glob.slice(1))
8079
} else {
8180
affirmed.push(glob)
8281
}
8382
}
84-
const affirmedMatcher = picomatch(affirmed)
85-
const negatedMatcher = picomatch(negated)
83+
const affirmedMatcher = picomatch(affirmed, {
84+
noextglob: true,
85+
dot: !!i.options.exhaustive,
86+
ignore: i.options.exhaustive ? [] : ['**/node_modules/**'],
87+
})
88+
const negatedMatcher = picomatch(negated, {
89+
noextglob: true,
90+
dot: !!i.options.exhaustive,
91+
ignore: i.options.exhaustive ? [] : ['**/node_modules/**'],
92+
})
8693

8794
return (file: string) => {
8895
// (glob1 || glob2) && !(glob3 || glob4)...

0 commit comments

Comments
 (0)