Detect module's update recursively on nodejs.
// module.js
module.exports = require('./foo') + require('./bar')const makeHotRequire = require('hot-module-require')
const hotRequire = makeHotRequire(__dirname)
let mExports = require('./module')
hotRequire.accept(['./module'], (oldModule, path) => {
// Do something here
// when './module' module or submodules('./foo', './bar'') be detected changed.
let newExports = require('./module')
})
// Or use it like follows
const hotModuleGetter = 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.