Skip to content

Webpack loader that add a hmr method to your module

License

Notifications You must be signed in to change notification settings

pqml/hmr-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hmr-loader

Webpack loader that add a hmr method to your module




Features

  • Wrap your module inside an HMR object
  • Watch/Unwatch changes with the watch and unwatch methods
  • Access to your module via the module property



Installation

$ npm install @internet/hmr -S # with npm
$ yarn add @internet/hmr --dev # with yarn



Usage

⚠️ Specify @internet/hmr to each import statement your want to add hot reloading.

⚠️ hmr-loader doesn't work when specified in a webpack config file.


import Module from '@internet/hmr!./module-object'
import string from '@internet/hmr!./module-string'

// Return true - you can use it to check if the module is wrapped inside the hmr module
Module.__hmr

// Return module ID
Module.id

// Real module default value
Module.module

// onReload will be called on each reload
Module.watch(onReload)

// Stop calling onReload on each reload
Module.unwatch(onReload)

// Only the new module value is sent to the callback, without a new hmr wrapper
function onReload (newValue) {}



Requirements

  • Node >= 8
  • Webpack >= 3



License

MIT.



hmr-loader is a package of the @internet npm scope.

@internet is a collection of opinionated and interoperables front-end npm ES6 modules, with minimal external dependencies.

About

Webpack loader that add a hmr method to your module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published