Detect module's update recursively on nodejs.
// module.jsmodule.exports=require('./foo')+require('./bar')constmakeHotRequire=require('hot-module-require')consthotRequire=makeHotRequire(__dirname)letmExports=require('./module')hotRequire.accept(['./module'],(oldModule,path)=>{// Do something here // when './module' module or submodules('./foo', './bar'') be detected changed.letnewExports=require('./module')})// Or use it like followsconsthotModuleGetter=hotRequire('./module')hotModuleGetter()// Returns the already updated `require('./module')``hotModuleGetter.remove()// Calls `remove` for interrupting detect updated npm run example- See: More options see detect-dep
make a hot require instance
dirname(optional, default'')presetOpts{{}} (optional, default{})presetOpts.recursive{boolean} Analysis file recursively (optional, defaulttrue)
Returns HotRequire
Resolve file name
name{string}
- See: chokidar
file Watcher
The event emitter
The map about dependent relations
Type: Map
The map about dependence relations
Type: Map
Get dependence tree of which file
modulePath{string}opts
Returns {}
Add Dependencies
modulePath{string}deps{string[]}
Remove Dependencies
modulePath{string}deps{string[]}
Watch file with callback and make dependence(dependent) relations
deps{string[]}callback{function}
Watch file with callback and make dependence(dependent) relations
deps{string[]}callback{function}
Close file watcher
Returns any void
- detect-dep - Detect file's dependencies.