require('@clapp/hmr')(() => {
require('./your-dev-module');
});callbackFunction which will be called each time when some file was changedoptionsOptionsdebugShow list of modules which was removed from the cache. Default: falsewatchDirRelative path to the directory to be watched recursively. Default: directory of the current modulewatchFilePatternsFiles that will trigger reload on change. Default:["**/*.ts", "**/*.js"]chokidarChokidar options
route.ts
function route(req: http.Request, res: http.Response): http.RequestListener {
res.write('Hello World');
res.end()
});
export default route;index.ts
import http from 'http';
import hmr from '@clapp/hmr';
let route: http.RequestListener;
hmr(async () => {
console.log('Reloading app...');
({ default: route } = await import('./route'));
});
const server = http.createServer((req, res) => route(req, res));
server.listen(3000);