Socket
Socket
Sign inDemoInstall

warm-require

Package Overview
Dependencies
3
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    warm-require

hot require for server


Version published
Weekly downloads
96
decreased by-23.81%
Maintainers
2
Install size
2.63 MB
Created
Weekly downloads
 

Readme

Source

warm-require

Hot reload for server

You can read about the implementation here

Features

  • Reload files which changed
  • update file when any sub-dependency is modified

##installation

npm i --save-dev warm-require

##Usage

//index.js
var warmRequire = require('./warm-require-config');
var hotModule = warmRequire(__dirname + '/module');

function whichGetsCalledOnEveryRequest() {
	// Reload it.
	hotModule = warmRequire(__dirname + '/module');

	// Use it.
	render(hotModule);
}
// warm-require-config.js
if (process.env.NODE_ENV === 'production') {
	module.exports = require;
} else {
	var warmRequire = require('warm-require').watch({
		paths: __dirname + '/**/*.jsx' // used anymatch. https://github.com/es128/anymatch.
	});
	module.exports = warmRequire;
}

Known issues

  • You cannot use with ES6's import statement. It is immutable to make it statically analyzable, so that it would work in browsers as well. (Arrgh) So you will have to use var or let.

Todo

License @ MIT

Keywords

FAQs

Last updated on 04 Sep 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc