@@ -17,7 +17,7 @@ import {
1717import { sep , join } from 'pathe'
1818import { findUp as internalFindUp , findUpSync as internalFindUpSync } from 'find-up'
1919import { minimatch } from 'minimatch'
20- import fastGlobLib from 'fast-glob '
20+ import { createRequire } from 'module '
2121import {
2222 mkdirSync as fsMkdirSync ,
2323 readFileSync as fsReadFileSync ,
@@ -33,7 +33,6 @@ import {
3333 accessSync ,
3434 ReadStream ,
3535 WriteStream ,
36- statSync ,
3736} from 'fs'
3837
3938import {
@@ -58,6 +57,8 @@ import * as os from 'os'
5857
5958import type { Pattern , Options as GlobOptions } from 'fast-glob'
6059
60+ const require = createRequire ( import . meta. url )
61+
6162/**
6263 * Strip the first `strip` parts of the path.
6364 *
@@ -510,7 +511,7 @@ export function unixFileIsOwnedByCurrentUser(path: string): boolean | undefined
510511 if ( ! fileExistsSync ( path ) ) return false
511512
512513 try {
513- const stats = statSync ( path )
514+ const stats = fsStatSync ( path )
514515 const currentUid = process . getuid ( )
515516
516517 return stats . uid === currentUid
@@ -594,11 +595,13 @@ export async function glob(pattern: Pattern | Pattern[], options?: GlobOptions):
594595 * @returns An array of pathnames that match the given pattern.
595596 */
596597export function globSync ( pattern : Pattern | Pattern [ ] , options ?: GlobOptions ) : string [ ] {
598+ // Performance: fast-glob is a heavy dependency. We lazy-load it here to avoid
599+ // overhead during CLI startup for commands that don't need globbing.
597600 let overridenOptions = options
598601 if ( options ?. dot == null ) {
599602 overridenOptions = { ...options , dot : true }
600603 }
601- return fastGlobLib . sync ( pattern , overridenOptions )
604+ return ( require ( 'fast-glob' ) as typeof import ( 'fast-glob' ) ) . sync ( pattern , overridenOptions )
602605}
603606
604607/**
0 commit comments