require-reload
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "require-reload", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Reload a require'd module/file. Useful for hot-reloading classes.", | ||
@@ -15,2 +15,4 @@ "main": "reload.js", | ||
}, | ||
"engines": {"node": ">=0.6.21"}, | ||
"engineStrict": true, | ||
"repository": { | ||
@@ -17,0 +19,0 @@ "type": "git", |
@@ -7,3 +7,4 @@ # require-reload # | ||
```JS | ||
var reload = require('require-reload'), | ||
//things will work just the same with require('require-reload') but see note after this example | ||
var reload = require('require-reload')(require), | ||
api = reload('api.js'); | ||
@@ -20,8 +21,14 @@ //sometime later if you make changes to api.js, you can hot-reload it by calling | ||
## Notes/Caveats ## | ||
Keep in mind that the cache is shared between child modules and their parents. If you want to reload your depdencies when | ||
you're reloaded then you must also use `require-reload`. This is on purpose so things are not unintentionally reloaded. | ||
Note: This uses internal methods to the module system without a context. These APIs may change at any time. I will keep this | ||
maintained to support all version of Node.js >=0.6 and io.js >=1.0.4. Version management will be handled through npm. | ||
**Because of this, it is recommend you use `require('require-reload')(require)` which works without any internal methods.** | ||
## Advanced Usage ## | ||
### reload([context]) ### | ||
### reload([otherContext]) ### | ||
If you want to run reload in the context of another module/file then pass in the `require` variable into `reload` to get an | ||
@@ -41,4 +48,1 @@ instance that is bound to that context. The other module must return its require context to use this. | ||
to clear another context's cache. | ||
Note: This is using internal methods to the module system. These APIs may change at any time. I will keep this | ||
maintained to support all version of Node.js >=0.6 and io.js >1.0.4. Version management will be handled through npm. |
11405
46