https://github.com/nswbmw/proxy-hot-reload
Node.js application hot reload with `Proxy`.
https://github.com/nswbmw/proxy-hot-reload
hot-reload proxy
Last synced: 3 months ago
JSON representation
Node.js application hot reload with `Proxy`.
- Host: GitHub
- URL: https://github.com/nswbmw/proxy-hot-reload
- Owner: nswbmw
- Created: 2017-06-12T07:25:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-27T03:34:41.000Z (about 8 years ago)
- Last Synced: 2025-06-09T11:48:55.225Z (4 months ago)
- Topics: hot-reload, proxy
- Language: JavaScript
- Size: 8.79 KB
- Stars: 19
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## proxy-hot-reload
Node.js application hot reload with `Proxy`.
**NB**: proxy-hot-reload can only proxy modules that return an plain object, like:
```js
module.export = { ... }
// or
exports.xxx = ...
```### Install
```sh
$ npm i proxy-hot-reload --save
```### Example
**app.js**
```js
'use strict';if (process.env.NODE_ENV !== 'production') {
require('proxy-hot-reload')({
includes: '**/*.js'
});
}const express = require('express');
const app = express();
const user = require('./user');app.get('/', function (req, res) {
res.send(user);
})app.listen(3000);
```**user.js**
```js
module.exports = {
id: 1,
age: 19
}
``````sh
DEBUG=proxy-hot-reload node app.js
```Then try to modify user.js, access to `localhost:3000`.
### Usage
**require('proxy-hot-reload')([option])**
option:
1. includeFiles([obsolute filepath]) || includes(glob pattern string): as `PROXY_HOT_RELOAD_INCLUDES`, files should be includes, see [glob](https://github.com/isaacs/node-glob).
2. excludeFiles([obsolute filepath]) || excludes(glob pattern string): as `PROXY_HOT_RELOAD_EXCLUDES`, files should be excludes, see [glob](https://github.com/isaacs/node-glob).
3. watchedFileChangedButNotReloadCache: default:```js
function (filename) {
debug(`${filename} changed, but not reload cache!`)
}
```### Note
1. proxy-hot-reload should not be used in production environment.
2. proxy-hot-reload is effective for some specific files like: `lib/*.js`, `utils/*.js` etc.If you find some bugs please raise an issue or make a pull request.
### License
MIT