Socket
Book a DemoInstallSign in
Socket

pear-hotmods

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pear-hotmods

The `pear-hotmods` library is a Pear ecosystem library. It automatically reloads Module instances which can be passed on to a live-reload mechanism commonly supplied by frontend-frameworks.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
2
Created
Source

pear-hotmods

The pear-hotmods library is a Pear ecosystem library. It automatically reloads Module instances which can be passed on to a live-reload mechanism commonly supplied by frontend-frameworks.

Install

npm install pear-hotmods

API

const { hotmods } = await import('pear-hotmods')
import hotmods from 'pear-hotmods'

hotmods([options, ] listener <Async Function|Function>)

Call the listener function

Options

  • paths <Array> - paths allowlist to match against. Paths are drive keys: they are rooted to application root. If unset or empty array, matches against all paths.

Example

Scenario where Preact framework is being used with prefresh for hot-reloading during application development:

if (Pear.config.dev) {
  const { hotmods } = await import('pear-hotmods')
  await import('@prefresh/core')
  hotmods({ paths: ['/components'] }, (reloads) => {
    for (const { original, previous, next, type, key } of reloads) {
      console.log('Hot reloading - path:', key, 'operation:', type)
      window.__PREFRESH__.replaceComponent(original, next, true)
      window.__PREFRESH__.replaceComponent(previous, next, true)
    }
  })
}

License

Apache-2.0

FAQs

Package last updated on 09 Sep 2025

Did you know?

Socket

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.

Install

Related posts