Skip to content

Commit 5d9442a

Browse files
joyeecheungdanielleadams
authored andcommitted
lib: load internal/fs/watchers and internal/fs/read_file_context early
So that they are included in the builtin snapshot PR-URL: #38737 Refs: #35711 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent a1b0e64 commit 5d9442a

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

‎lib/fs.js‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ const {
138138
validateInteger,
139139
}=require('internal/validators');
140140

141+
constwatchers=require('internal/fs/watchers');
142+
constReadFileContext=require('internal/fs/read_file_context');
143+
141144
lettruncateWarn=true;
142145
letfs;
143146

144147
// Lazy loaded
145148
letpromises=null;
146-
letwatchers;
147-
letReadFileContext;
148149
letReadStream;
149150
letWriteStream;
150151
letrimraf;
@@ -369,8 +370,6 @@ function checkAborted(signal, callback) {
369370
functionreadFile(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
constcontext=newReadFileContext(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
thrownewERR_FEATURE_UNAVAILABLE_ON_PLATFORM('watch recursively');
2237-
if(!watchers)
2238-
watchers=require('internal/fs/watchers');
22392236
constwatcher=newwatchers.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=newwatchers.StatWatcher(options.bigint);
23072302
stat[watchers.kFSStatWatcherStart](filename,
23082303
options.persistent,options.interval);

‎test/parallel/test-bootstrap-modules.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const expectedModules = new Set([
5656
'NativeModule internal/fs/dir',
5757
'NativeModule internal/fs/utils',
5858
'NativeModule internal/fs/promises',
59+
'NativeModule internal/fs/read_file_context',
5960
'NativeModule internal/fs/rimraf',
6061
'NativeModule internal/fs/watchers',
6162
'NativeModule internal/heap_utils',

0 commit comments

Comments
 (0)