
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
nodejs-hmr
Advanced tools
Add in the first line of code
import hot from 'nodejs-hmr';
// initilaize hot reload api
hot.run();
// or
// hot.run({ cwd: path.resolve('xx/xx') })
// hot.run({ cwd: [ path.resolve('xx/xx'),... ] })
By default, if a module change is detected again, the modified module will be reloaded in turn, and the parent module that references this module will also be reloaded.
// preload ---> preend ---> accept ---> postend .......---> Alldone
Triggered before reloading the module, the event will be dispatched to all parent modules that reference this module
xxx.js
import hot from 'nodejs-hmr';
hot
.create(module)
.preload((old)=>{
// do somthing at pre reload module
})
.preend((old)=>{
// on preload end
})
Accept child module change,
If the change module defines the accept function, the parent module will stop reloading.
xxx.js
import hot from 'nodejs-hmr';
hot
.create(module)
.accept((newModule,oldModule)=>{
// do somehting
})
import hot from 'nodejs-hmr';
hot
.create(module)
.postend((newModule,oldModule)=>{
// do somehting
})
import hot from 'nodejs-hmr';
hot
.create(module)
// clean hook listener
.clean('postend','..')
.postend((newModule,oldModule)=>{
// do somehting
})
Currently, Array, Map, and Object types can be updated through hot.createHotUpdater.
import Color from './color';
import Size from './size';
const registrations = new Array<XX>();
registrations.push(new Color());
registrations.push(new Size());
hot
.create(module)
.accept((newModule,oldModule)=>{
//When the color.js file changes, you can specify the update replacement in the following ways
hot
.createHotUpdater(registrations,newModule,oldModule)
.needHot((item,oldCtor)=> item instanceof oldCtor)
// set replacement instance constructor
.creator((ctor)=>{
return new ctor();
})
// do update
.update();
})
FAQs
## A nodejs hot module reload
We found that nodejs-hmr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.