1.1.7 • Published 4 years ago
electron-hmr v1.1.7
electron-hmr
an electron hot module replace for nodejs

Quickly Start
npm i elecrton-hmr -Dand run hmr , use --help to see the options
ehmrif you want to use whit vite or other , install concurrently
npm i concurrently -Dpackage.json
...
"scripts": {
"dev": "concurrently \"ehmr\" \"vite\" ",
//...
},
...JavaScript Api
// you also can use import like : import { ElectronHmr } from "electron-hmr"
const { ElectronHmr } = require('electron-hmr');
// use electron binary path
const electron = require('electron');
// init and create electron
const electronHmr = new ElectronHmr({
electronBinaryPath: electron.toString(),
// other options
})
// rebuild after 3000s delay
settimeout(electronHmr.rebuild,3000)Three way to rebuild electron
1. you can use rebuild() to rebuild the electron
electronHmr.rebuild()2. start hot module replace, it will watch file change and rebuild automaticly
electronHmr.watch(/*options*/)3. or you can use chokidar to watch file and rebuild manually
import { watch } from 'chokidar';
watch('.').on('change', (path, stats) => {
if (stats?.isFile /* or some condition*/) {
// rebuild the electron
electronHmr.rebuild()
}
});