@@ -138,13 +138,14 @@ const {
138138 validateInteger,
139139} = require ( 'internal/validators' ) ;
140140
141+ const watchers = require ( 'internal/fs/watchers' ) ;
142+ const ReadFileContext = require ( 'internal/fs/read_file_context' ) ;
143+
141144let truncateWarn = true ;
142145let fs ;
143146
144147// Lazy loaded
145148let promises = null ;
146- let watchers ;
147- let ReadFileContext ;
148149let ReadStream ;
149150let WriteStream ;
150151let rimraf ;
@@ -369,8 +370,6 @@ function checkAborted(signal, callback) {
369370function readFile ( path , options , callback ) {
370371 callback = maybeCallback ( callback || options ) ;
371372 options = getOptions ( options , { flag : 'r' } ) ;
372- if ( ! ReadFileContext )
373- ReadFileContext = require ( 'internal/fs/read_file_context' ) ;
374373 const context = new ReadFileContext ( callback , options . encoding ) ;
375374 context . isUserFd = isFd ( path ) ; // File descriptor ownership
376375
@@ -2234,8 +2233,6 @@ function watch(filename, options, listener) {
22342233 if ( options . recursive === undefined ) options . recursive = false ;
22352234 if ( options . recursive && ! ( isOSX || isWindows ) )
22362235 throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM ( 'watch recursively' ) ;
2237- if ( ! watchers )
2238- watchers = require ( 'internal/fs/watchers' ) ;
22392236 const watcher = new watchers . FSWatcher ( ) ;
22402237 watcher [ watchers . kFSWatchStart ] ( filename ,
22412238 options . persistent ,
@@ -2301,8 +2298,6 @@ function watchFile(filename, options, listener) {
23012298 stat = statWatchers . get ( filename ) ;
23022299
23032300 if ( stat === undefined ) {
2304- if ( ! watchers )
2305- watchers = require ( 'internal/fs/watchers' ) ;
23062301 stat = new watchers . StatWatcher ( options . bigint ) ;
23072302 stat [ watchers . kFSStatWatcherStart ] ( filename ,
23082303 options . persistent , options . interval ) ;
0 commit comments