node-hot-loader
Advanced tools
Comparing version 1.5.3 to 1.6.0
@@ -0,1 +1,9 @@ | ||
<a name="1.6.0"></a> | ||
## 1.6.0 (2018-02-24) | ||
* Improve logger output colors ([86b7b9c](https://github.com/vlazh/node-hot-loader/commit/86b7b9c)) | ||
* Update README ([6abefd6](https://github.com/vlazh/node-hot-loader/commit/6abefd6)) | ||
<a name="1.5.3"></a> | ||
@@ -2,0 +10,0 @@ ## <small>1.5.3 (2018-02-23)</small> |
@@ -28,3 +28,3 @@ 'use strict'; | ||
if (unacceptedModules.length > 0) { | ||
this.logger.warn("The following modules couldn't be hot updated: (They would need a full reload!)"); | ||
this.logger.warn("The following modules couldn't be hot updated: (They would need restart server!)"); | ||
unacceptedModules.forEach(moduleId => { | ||
@@ -36,11 +36,11 @@ this.logger.warn(` - ${moduleId}`); | ||
if (!renewedModules || renewedModules.length === 0) { | ||
this.logger.log('Nothing hot updated.'); | ||
this.logger.info('Nothing hot updated.'); | ||
} else { | ||
this.logger.log('Updated modules:'); | ||
this.logger.info('Updated modules:'); | ||
renewedModules.forEach(moduleId => { | ||
this.logger.log(` - ${moduleId}`); | ||
this.logger.info(` - ${moduleId}`); | ||
}); | ||
const numberIds = renewedModules.every(moduleId => typeof moduleId === 'number'); | ||
if (numberIds) { | ||
this.logger.log('Consider using the NamedModulesPlugin for module names.'); | ||
this.logger.info('Consider using the NamedModulesPlugin for module names.'); | ||
} | ||
@@ -61,6 +61,6 @@ } | ||
if (status === 'idle') { | ||
this.logger.log('Checking for updates...'); | ||
this.logger.info('Checking for updates...'); | ||
this.check(); | ||
} else if (['abort', 'fail'].indexOf(status) >= 0) { | ||
this.logger.warn(`Cannot apply update as a previous update ${status}ed. Need to do a full reload!`); | ||
this.logger.warn(`Cannot apply update as a previous update ${status}ed. Need to do restart server!`); | ||
} | ||
@@ -75,3 +75,3 @@ } | ||
if (!updatedModules) { | ||
this.logger.warn('Cannot find update. Need to do a full reload!'); | ||
this.logger.warn('Cannot find update. Need to do restart server!'); | ||
// this.logger.warn( '(Probably because of restarting the server)'); | ||
@@ -102,3 +102,3 @@ return null; | ||
if (this.upToDate()) { | ||
this.logger.log('App is up to date.'); | ||
this.logger.info('App is up to date.'); | ||
} | ||
@@ -109,3 +109,3 @@ }); | ||
if (['abort', 'fail'].indexOf(status) >= 0) { | ||
this.logger.warn('Cannot check for update. Need to do a full reload!'); | ||
this.logger.warn('Cannot check for update. Need to do restart server!'); | ||
this.logger.warn(err.stack || err.message); | ||
@@ -124,3 +124,3 @@ } else { | ||
this.logger.log('Waiting for update signal from webpack...'); | ||
this.logger.info('Waiting for update signal from webpack...'); | ||
process.on('message', listener); | ||
@@ -127,0 +127,0 @@ return this; |
@@ -25,10 +25,12 @@ 'use strict'; | ||
var _Logger = require('./Logger'); | ||
var _Logger2 = _interopRequireDefault(_Logger); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class HmrServer { | ||
static defaultReporter(reporterOptions) { | ||
const { stateValid, log, stats, compilerOptions } = reporterOptions; | ||
static defaultReporter({ context, stateValid, stats, compilerOptions }) { | ||
if (!stateValid) { | ||
log(`${_LogColors2.default.magenta('Webpack')}: Compiling...`); | ||
context.webpackLogger.info('Compiling...'); | ||
return; | ||
@@ -43,3 +45,3 @@ } | ||
// To avoid log empty statsInfo, e.g. when options.stats is 'errors-only'. | ||
log(statsInfo); | ||
context.webpackLogger.info(statsInfo); | ||
} | ||
@@ -49,9 +51,8 @@ } | ||
if (!compilerOptions.noInfo && !compilerOptions.quiet) { | ||
let msg = 'Compiled successfully.'; | ||
if (stats.hasErrors()) { | ||
msg = 'Failed to compile.'; | ||
context.webpackLogger.error('Failed to compile.'); | ||
} else if (stats.hasWarnings()) { | ||
msg = 'Compiled with warnings.'; | ||
context.webpackLogger.warn('Compiled with warnings.'); | ||
} | ||
log(`${_LogColors2.default.magenta('Webpack')}: ${msg}`); | ||
context.webpackLogger.info('Compiled successfully.'); | ||
} | ||
@@ -88,5 +89,7 @@ } | ||
reporter: HmrServer.defaultReporter, | ||
info: console.log.bind(console), | ||
warn: console.warn.bind(console), | ||
error: console.error.bind(console), | ||
// info: console.log.bind(console), | ||
// warn: console.warn.bind(console), | ||
// error: console.error.bind(console), | ||
logger: new _Logger2.default(_LogColors2.default.cyan('[HMR]')), | ||
webpackLogger: new _Logger2.default(_LogColors2.default.magenta('Webpack')), | ||
fork: false, | ||
@@ -156,3 +159,3 @@ compiler: undefined | ||
}); | ||
this.context.info('Launch assets in forked process.'); | ||
this.context.logger.info('Launch assets in forked process.'); | ||
} else { | ||
@@ -163,3 +166,3 @@ // Require in current process to lauch script. | ||
}).catch(err => { | ||
this.context.error(err); | ||
this.context.logger.error(err); | ||
process.exit(); | ||
@@ -185,3 +188,3 @@ }); | ||
stats, | ||
log: this.context.info, | ||
context: this.context, | ||
compilerOptions: this.context.compiler.options | ||
@@ -205,3 +208,3 @@ }); | ||
stateValid: false, | ||
log: this.context.info, | ||
context: this.context, | ||
compilerOptions: this.context.compiler.options | ||
@@ -222,4 +225,4 @@ }); | ||
if (err) { | ||
this.context.error(err.stack || err); | ||
if (err.details) this.context.error(err.details); | ||
this.context.logger.error(err.stack || err); | ||
if (err.details) this.context.logger.error(err.details); | ||
} | ||
@@ -232,3 +235,3 @@ }; | ||
this.context.watching = compiler.watch(compiler.options.watchOptions, this.compilerWatch); | ||
this.context.info(_LogColors2.default.cyan('[HMR]'), 'Waiting webpack...'); | ||
this.context.logger.info('Waiting webpack...'); | ||
}; | ||
@@ -235,0 +238,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,2 +6,9 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var _LogColors = require('./LogColors'); | ||
var _LogColors2 = _interopRequireDefault(_LogColors); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Logger { | ||
@@ -13,3 +20,3 @@ | ||
log(message, ...optionalParams) { | ||
info(message, ...optionalParams) { | ||
console.log(this.prefix, message, ...optionalParams); | ||
@@ -19,9 +26,9 @@ } | ||
warn(message, ...optionalParams) { | ||
console.warn(this.prefix, message, ...optionalParams); | ||
console.warn(this.prefix, _LogColors2.default.yellow(message), ...optionalParams); | ||
} | ||
error(message, ...optionalParams) { | ||
console.error(this.prefix, message, ...optionalParams); | ||
console.error(this.prefix, _LogColors2.default.red(message), ...optionalParams); | ||
} | ||
} | ||
exports.default = Logger; |
{ | ||
"name": "node-hot-loader", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Hot module replacement for Node.js applications", | ||
@@ -78,2 +78,4 @@ "main": "./lib/node-hot.js", | ||
"eslint-plugin-import": "^2.9.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"prettier": "^1.10.2", | ||
"rimraf": "^2.6.1" | ||
@@ -80,0 +82,0 @@ }, |
@@ -121,1 +121,5 @@ # Node Hot Loader [![npm package](https://img.shields.io/npm/v/node-hot-loader.svg?style=flat-square)](https://www.npmjs.org/package/node-hot-loader) | ||
[MIT](https://opensource.org/licenses/mit-license.php) | ||
## Other projects | ||
Try the [reflexy](https://github.com/vlazh/reflexy) - react flexbox layout components. |
40115
17
497
125
16