0.2.5 • Published 8 years ago

warm-require v0.2.5

Weekly downloads
375
License
MIT
Repository
github
Last release
8 years ago

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

0.2.5

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago