Socket
Socket
Sign inDemoInstall

node-hot-loader

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-hot-loader - npm Package Compare versions

Comparing version 1.16.3 to 1.17.0

messageActionType.js

22

CHANGELOG.md

@@ -0,1 +1,23 @@

## 1.17.0 (2019-08-19)
* 1.16.0 ([28f73d5](https://github.com/vlazh/node-hot-loader/commit/28f73d5))
* 1.16.1 ([5952870](https://github.com/vlazh/node-hot-loader/commit/5952870))
* 1.16.2 ([7ba937c](https://github.com/vlazh/node-hot-loader/commit/7ba937c))
* 1.16.3 ([672f16c](https://github.com/vlazh/node-hot-loader/commit/672f16c))
* Add args option and refactor ([8c6a42d](https://github.com/vlazh/node-hot-loader/commit/8c6a42d))
* Exclude source map from assets ([3e43a13](https://github.com/vlazh/node-hot-loader/commit/3e43a13))
* Fix config ([3066543](https://github.com/vlazh/node-hot-loader/commit/3066543))
* Fix node-hot version ([90e22ff](https://github.com/vlazh/node-hot-loader/commit/90e22ff))
* Prettierify ([24110dd](https://github.com/vlazh/node-hot-loader/commit/24110dd))
* Reorganize build ([75e33fc](https://github.com/vlazh/node-hot-loader/commit/75e33fc))
* Update deps ([7ec894f](https://github.com/vlazh/node-hot-loader/commit/7ec894f))
* Update deps ([ce73fe7](https://github.com/vlazh/node-hot-loader/commit/ce73fe7))
* Update deps ([99043c3](https://github.com/vlazh/node-hot-loader/commit/99043c3))
* Update deps and configs ([949a639](https://github.com/vlazh/node-hot-loader/commit/949a639))
* Update docs ([deb5fc6](https://github.com/vlazh/node-hot-loader/commit/deb5fc6))
* Update scripts ([92a59d5](https://github.com/vlazh/node-hot-loader/commit/92a59d5))
* Update scripts ([8c87512](https://github.com/vlazh/node-hot-loader/commit/8c87512))
## <small>1.16.3 (2019-08-04)</small>

@@ -2,0 +24,0 @@

58

HmrClient.js

@@ -14,2 +14,4 @@ "use strict";

var _messageActionType = _interopRequireDefault(require("./messageActionType"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -19,3 +21,2 @@

/* globals __webpack_hash__ */
class HmrClient {

@@ -25,2 +26,4 @@ constructor() {

_defineProperty(this, "lastHash", '');
_defineProperty(this, "logApplyResult", (logLevel, outdatedModules, renewedModules) => {

@@ -30,3 +33,3 @@ const unacceptedModules = !renewedModules || !renewedModules.length ? outdatedModules : outdatedModules.filter(moduleId => renewedModules.indexOf(moduleId) < 0);

if (unacceptedModules.length > 0 && logLevel >= _LogLevel.LogLevel.ERRORS) {
this.logger.warn("The following modules couldn't be hot updated: (They would need restart the server!)");
this.logger.warn("The following modules couldn't be hot updated: (They would need to restart the application!)");
unacceptedModules.forEach(moduleId => {

@@ -57,3 +60,3 @@ this.logger.warn(` - ${moduleId}`);

if (this.upToDate()) {
if (this.isUpToDate()) {
this.logUpToDate(logLevel);

@@ -69,14 +72,15 @@ }

_defineProperty(this, "defaultListener", message => {
_defineProperty(this, "defaultMessageListener", ({
action,
stats,
logLevel
}) => {
// webpackHotUpdate
if (message.action !== 'built') {
if (action !== _messageActionType.default.CompilerDone) {
return;
}
this.lastHash = message.stats.hash;
const {
logLevel
} = message;
this.lastHash = stats.hash;
if (!this.upToDate()) {
if (!this.isUpToDate()) {
const status = module.hot.status();

@@ -89,5 +93,5 @@

this.check(logLevel);
this.checkAndApplyUpdates(logLevel);
} else if (['abort', 'fail'].indexOf(status) >= 0 && logLevel >= _LogLevel.LogLevel.ERRORS) {
this.logger.warn(`Cannot apply update as a previous update ${status}ed. Need to do restart the server!`);
this.logger.warn(`Cannot apply update as a previous update ${status}ed. You need to restart the application!`);
}

@@ -99,9 +103,9 @@ } else {

_defineProperty(this, "upToDate", () => this.lastHash.indexOf(__webpack_hash__) >= 0);
_defineProperty(this, "isUpToDate", () => this.lastHash.indexOf(__webpack_hash__) >= 0);
_defineProperty(this, "check", logLevel => {
_defineProperty(this, "checkAndApplyUpdates", logLevel => {
module.hot.check().then(outdatedModules => {
if (!outdatedModules) {
if (logLevel >= _LogLevel.LogLevel.ERRORS) {
this.logger.warn('Cannot find update. Need to do restart the server!');
this.logger.warn('Cannot find update. You need to restart the application!');
}

@@ -116,4 +120,5 @@

ignoreErrored: true,
// true allows to restore state after errors.
onUnaccepted: info => {
onUnaccepted(info) {
if (logLevel >= _LogLevel.LogLevel.ERRORS) {

@@ -123,3 +128,4 @@ this.logger.warn(`Ignored an update to unaccepted module ${info.chain.join(' -> ')}`);

},
onDeclined: info => {
onDeclined(info) {
if (logLevel >= _LogLevel.LogLevel.ERRORS) {

@@ -129,3 +135,4 @@ this.logger.warn(`Ignored an update to declined module ${info.chain.join(' -> ')}`);

},
onErrored: info => {
onErrored(info) {
if (logLevel >= _LogLevel.LogLevel.ERRORS) {

@@ -138,5 +145,6 @@ this.logger.warn(`Ignored an error while updating module ${info.moduleId} (${info.type})`); // If ignoreErrored is true and throw info.error then module.hot.status() always

}
}).then(renewedModules => {
if (!this.upToDate()) {
this.check(logLevel);
if (!this.isUpToDate()) {
this.checkAndApplyUpdates(logLevel);
}

@@ -148,6 +156,4 @@

if (logLevel >= _LogLevel.LogLevel.ERRORS) {
const status = module.hot.status();
if (['abort', 'fail'].indexOf(status) >= 0) {
this.logger.error('Cannot check for update. Need to do restart the server!');
if (['abort', 'fail'].indexOf(module.hot.status()) >= 0) {
this.logger.error('Cannot check for update. You need to restart the application!');
this.logger.error(err.stack || err.message);

@@ -162,3 +168,3 @@ } else {

run(listener = this.defaultListener) {
run(messageListener = this.defaultMessageListener) {
if (!module.hot) {

@@ -169,3 +175,3 @@ throw new Error('Hot Module Replacement is disabled.');

this.logger.info('Waiting for update signal from webpack...');
process.on('message', listener);
process.on('message', messageListener);
return this;

@@ -172,0 +178,0 @@ }

@@ -22,2 +22,4 @@ "use strict";

var _messageActionType = _interopRequireDefault(require("./messageActionType"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -68,7 +70,13 @@

/**
* @param {{ compiler: import('webpack').Compiler; fork: boolean | string; inMemory: boolean; logLevel: string; }} options
* @param {{
* compiler: import('webpack').Compiler;
* fork?: boolean | string[];
* args?: string[];
* inMemory?: boolean;
* logLevel?: string;
* }} options
*/
constructor(_options) {
_defineProperty(this, "context", {
/** When started compiled script contain process object in which script running. */
/** When started compiled script contains process object in which script running. */
serverProcess: null,

@@ -94,5 +102,6 @@

webpackLogger: new _Logger.default(_LogColors.default.magenta('Webpack')),
compiler: undefined,
fork: false,
args: undefined,
inMemory: false,
compiler: undefined,
logLevel: undefined

@@ -150,2 +159,3 @@ });

if (this.context.fork) {
/** @type import('child_process').ForkOptions */
const options = {

@@ -162,3 +172,3 @@ cwd: process.cwd(),

this.context.serverProcess = (0, _child_process.fork)(getLauncherFileName(), process.argv, options); // Listen for serverProcess events.
this.context.serverProcess = (0, _child_process.fork)(getLauncherFileName(), this.context.args || process.argv, options); // Listen for serverProcess events.

@@ -187,5 +197,5 @@ this.context.serverProcess.on('exit', code => {

_defineProperty(this, "compilerInvalid", () => {
_defineProperty(this, "compilerStart", () => {
try {
this.sendMessage('compile');
this.sendMessage(_messageActionType.default.CompilerStart);

@@ -228,3 +238,3 @@ if (this.context.watching && this.context.stateValid) {

// Already has launched process
this.sendMessage('built');
this.sendMessage(_messageActionType.default.CompilerDone);
} else {

@@ -264,7 +274,7 @@ // Start compiled files in child process (fork) or in current process.

// webpack >= 4
compiler.hooks.invalid.tap('node-hot-loader', this.compilerInvalid);
compiler.hooks.invalid.tap('node-hot-loader', this.compilerStart);
compiler.hooks.done.tapPromise('node-hot-loader', this.compilerDone);
} else {
// webpack < 4
compiler.plugin('invalid', this.compilerInvalid);
compiler.plugin('invalid', this.compilerStart);
compiler.plugin('done', this.compilerDone);

@@ -271,0 +281,0 @@ }

@@ -17,2 +17,3 @@ #!/usr/bin/env node

fork: undefined,
args: undefined,
inMemory: undefined,

@@ -22,3 +23,3 @@ logLevel: undefined

const params = _yargs.default.config(options).usage('Usage: $0 [args]').help('help').alias('help', 'h').alias('help', '?').version("1.16.3").alias('version', 'v').options({
const params = _yargs.default.config(options).usage('Usage: $0 [args]').help('help').alias('help', 'h').alias('help', '?').version("1.17.0").alias('version', 'v').options({
config: {

@@ -39,3 +40,3 @@ type: 'string',

type: 'string',
describe: 'Launch compiled assets in forked process with optional node exec arguments. With ',
describe: 'Launch compiled assets in forked process with optional node exec arguments.',
defaultDescription: 'false',

@@ -49,2 +50,12 @@ requiresArg: false,

},
args: {
type: 'string',
describe: 'List of arguments for forked process.',
requiresArg: false,
coerce: value => {
if (value === undefined) return undefined;
if (value.length === 0) return [];
return value.split(',');
}
},
inMemory: {

@@ -67,3 +78,3 @@ type: 'boolean',

}
}).example('node-hot --config webpack.config.js', 'Using a specific webpack config file.').example('node-hot', 'Using default webpack config file.').example('node-hot --logLevel minimal', 'Set a specific logLevel for node-hot-loader.').example('node-hot --fork', 'Launch compiled assets in forked process.').example('node-hot --fork=--arg1,--arg2', 'Launch compiled assets in forked process with passing node exec arguments.').showHelpOnFail(false, 'Use the --help option to get the list of available options.').check(args => {
}).example('node-hot --config webpack.config.js', 'Using a specific webpack config file.').example('node-hot', 'Using default webpack config file.').example('node-hot --logLevel minimal', 'Set a specific logLevel for node-hot-loader.').example('node-hot --fork', 'Launch compiled assets in forked process.').example('node-hot --fork=--arg1,--arg2', 'Launch compiled assets in forked process with passing node exec arguments.').example('node-hot --args=--arg1,--arg2', 'Pass arguments to forked process. Available in process.argv.').showHelpOnFail(false, 'Use the --help option to get the list of available options.').check(args => {
if (!_fs.default.existsSync(args.config)) {

@@ -78,4 +89,5 @@ throw new Error(`Webpack config file '${args.config}' not found!`);

options.fork = params.fork;
options.args = params.args;
options.inMemory = params.inMemory && !options.fork;
options.logLevel = params.logLevel;
(0, _loader.default)(options);

@@ -19,6 +19,7 @@ "use strict";

* @param {{
* force: boolean;
* fork: boolean | string[];
* inMemory: boolean;
* logLevel: string;
* force?: boolean;
* fork?: boolean | string[];
* args?: string[];
* inMemory?: boolean;
* logLevel?: string;
* }} options

@@ -25,0 +26,0 @@ */

{
"name": "node-hot-loader",
"version": "1.16.3",
"version": "1.17.0",
"description": "Hot module replacement for Node.js applications",

@@ -19,5 +19,5 @@ "author": "Vladimir Zhukov",

"build-to-tutoron": "babel src --out-dir '../tutoron/node_modules/node-hot-loader/' --copy-files",
"patch-publish": "npm version patch && npm run build && git commit --amend --no-edit && npm publish ./dist/ --access public && git push --follow-tags",
"minor-publish": "npm version minor && npm run build && git commit --amend --no-edit && npm publish ./dist/ --access public && git push --follow-tags",
"major-publish": "npm version major && npm run build && git commit --amend --no-edit && npm publish ./dist/ --access public && git push --follow-tags",
"patch-publish": "npm version patch && npm run build && git commit --amend --no-edit && npm publish ./dist/ && git push --follow-tags",
"minor-publish": "npm version minor && npm run build && git commit --amend --no-edit && npm publish ./dist/ && git push --follow-tags",
"major-publish": "npm version major && npm run build && git commit --amend --no-edit && npm publish ./dist/ && git push --follow-tags",
"version": "conventional-changelog -i CHANGELOG.md -s && git add CHANGELOG.md",

@@ -66,3 +66,4 @@ "changelog": "conventional-changelog -i CHANGELOG.md -s"

"@babel/preset-env": "^7.5.5",
"@vzh/configs": "^3.37.0",
"@types/webpack-env": "^1.14.0",
"@vzh/configs": "^3.37.6",
"babel-eslint": "^10.0.2",

@@ -72,4 +73,4 @@ "babel-plugin-transform-inline-environment-variables": "^0.4.3",

"copyfiles": "^2.1.1",
"eslint": "^6.1.0",
"eslint-config-airbnb-base": "^13.2.0",
"eslint": "^6.2.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.0.0",

@@ -79,4 +80,4 @@ "eslint-plugin-import": "^2.18.2",

"prettier": "^1.18.2",
"rimraf": "^2.6.3",
"webpack": "^4.39.1"
"rimraf": "^3.0.0",
"webpack": "^4.39.2"
},

@@ -83,0 +84,0 @@ "peerDependencies": {

@@ -46,2 +46,3 @@ # 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)

| `--fork` | Launch compiled assets in forked process with optional node exec arguments. |
| `--args` | List of arguments for forked process. |
| `--logLevel` | Log level related to [webpack stats configuration presets names](https://webpack.js.org/configuration/stats/#stats). | If not set then use webpack stats configuration. |

@@ -59,2 +60,4 @@

node-hot --fork=--arg1,--arg2 --
# or
node-hot --fork --args=--arg1,--arg2
# or just

@@ -95,5 +98,6 @@ node-hot

fork, // boolean | string[]. For example ['--key', 'key value'].
args, // string[]. For example ['--arg1', 'arg2'].
logLevel, // string
}),
]
],
};

@@ -100,0 +104,0 @@ ```

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc