This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

electron-hmr
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

electron-hmr

an electron hot module replace for nodejs

https://cdn.jsdelivr.net/gh/enncy/electron-hmr@1.1.1/docs/show.gif

Quickly Start

npm i elecrton-hmr -D

and run hmr , use --help to see the options

ehmr

if you want to use whit vite or other , install concurrently

npm i concurrently -D

package.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()
    }
});

Package Sidebar

Install

npm i electron-hmr

Weekly Downloads

5

Version

1.1.7

License

Apache-2.0

Unpacked Size

30.1 kB

Total Files

17

Last publish

Collaborators

  • enncy