Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import process from 'node:process'
import { isString, slash, throttle, toArray } from '@antfu/utils'
import { isPackageExists } from 'local-pkg'
import MagicString from 'magic-string'
import pm from 'picomatch'
import { createUnimport, normalizeScanDirs, resolvePreset } from 'unimport'
import { createFilter } from 'unplugin-utils'
import { presets } from '../presets'
Expand Down Expand Up @@ -297,6 +298,8 @@ ${dts}`.trim()}\n`
}))
: []

const normalizedDirMatchers = normalizedDirPaths.map(dir => pm(dir.glob))

return {
root,
dirs,
Expand All @@ -309,7 +312,7 @@ ${dts}`.trim()}\n`
generateESLint,
unimport,
configFilePaths,
normalizedDirPaths,
normalizedDirMatchers,
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/core/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { FilterPattern } from 'unplugin'
import type { Options } from '../types'
import { slash } from '@antfu/utils'
import { isPackageExists } from 'local-pkg'
import pm from 'picomatch'
import { createUnplugin } from 'unplugin'
import { createContext, EXCLUDE_RE_LIST, INCLUDE_RE_LIST } from './ctx'

Expand Down Expand Up @@ -58,9 +57,7 @@ export default createUnplugin<Options>((options) => {

const normalizedFilePath = slash(file)

const shouldRescan = ctx.normalizedDirPaths.some(dirPath =>
pm.isMatch(normalizedFilePath, dirPath.glob),
)
const shouldRescan = ctx.normalizedDirMatchers.some(match => match(normalizedFilePath))

if (shouldRescan)
await ctx.scanDirs()
Expand Down
Loading