node-hot-loader
Advanced tools
Comparing version 1.21.9 to 1.21.10
@@ -0,1 +1,9 @@ | ||
## <small>1.21.10 (2023-08-15)</small> | ||
* Update deps and configs ([6eae882](https://github.com/vlazh/node-hot-loader/commit/6eae882)) | ||
* Update deps and scripts ([d6067ec](https://github.com/vlazh/node-hot-loader/commit/d6067ec)) | ||
* Update README ([440e598](https://github.com/vlazh/node-hot-loader/commit/440e598)) | ||
## <small>1.21.9 (2022-08-26)</small> | ||
@@ -2,0 +10,0 @@ |
@@ -5,21 +5,14 @@ "use strict"; | ||
exports.default = exports.HmrClient = void 0; | ||
var _LogColors = _interopRequireDefault(require("./LogColors")); | ||
var _Logger = _interopRequireDefault(require("./Logger")); | ||
var _LogLevel = require("./LogLevel"); | ||
var _messageActionType = _interopRequireDefault(require("./messageActionType")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* globals __webpack_hash__ */ | ||
class HmrClient { | ||
constructor() { | ||
_defineProperty(this, "logger", new _Logger.default(_LogColors.default.cyan('[HMR]'))); | ||
_defineProperty(this, "lastHash", ''); | ||
_defineProperty(this, "sendRestartMessage", () => { | ||
@@ -34,6 +27,4 @@ // If forked process | ||
}); | ||
_defineProperty(this, "logApplyResult", (logLevel, outdatedModules, renewedModules) => { | ||
const unacceptedModules = !renewedModules || !renewedModules.length ? outdatedModules : outdatedModules.filter(moduleId => renewedModules.indexOf(moduleId) < 0); | ||
if (unacceptedModules.length > 0 && logLevel >= _LogLevel.LogLevel.ERRORS) { | ||
@@ -46,3 +37,2 @@ this.logger.warn("The following modules couldn't be hot updated: (They would need to restart the application!)"); | ||
} | ||
if (!renewedModules || !renewedModules.length) { | ||
@@ -52,6 +42,4 @@ if (logLevel >= _LogLevel.LogLevel.MINIMAL) { | ||
} | ||
return; | ||
} | ||
if (logLevel >= _LogLevel.LogLevel.NORMAL) { | ||
@@ -63,3 +51,2 @@ this.logger.info('Updated modules:'); | ||
const numberIds = renewedModules.every(moduleId => typeof moduleId === 'number'); | ||
if (numberIds) { | ||
@@ -69,3 +56,2 @@ this.logger.info('Consider using the NamedModulesPlugin for module names.'); | ||
} | ||
if (this.isUpToDate()) { | ||
@@ -75,3 +61,2 @@ this.logUpToDate(logLevel); | ||
}); | ||
_defineProperty(this, "logUpToDate", logLevel => { | ||
@@ -82,3 +67,2 @@ if (logLevel >= _LogLevel.LogLevel.MINIMAL) { | ||
}); | ||
_defineProperty(this, "defaultMessageListener", ({ | ||
@@ -93,8 +77,5 @@ action, | ||
} | ||
this.lastHash = stats.hash; | ||
if (!this.isUpToDate()) { | ||
const status = module.hot.status(); | ||
if (status === 'idle') { | ||
@@ -104,3 +85,2 @@ if (logLevel >= _LogLevel.LogLevel.MINIMAL) { | ||
} | ||
this.checkAndApplyUpdates(logLevel); | ||
@@ -111,3 +91,2 @@ } else if (['abort', 'fail'].indexOf(status) >= 0) { | ||
} | ||
this.sendRestartMessage(); | ||
@@ -119,5 +98,3 @@ } | ||
}); | ||
_defineProperty(this, "isUpToDate", () => this.lastHash.indexOf(__webpack_hash__) >= 0); | ||
_defineProperty(this, "checkAndApplyUpdates", logLevel => { | ||
@@ -129,6 +106,4 @@ module.hot.check().then(outdatedModules => { | ||
} | ||
return Promise.resolve(); | ||
} | ||
return module.hot.apply({ | ||
@@ -151,5 +126,5 @@ ignoreUnaccepted: true, | ||
if (logLevel >= _LogLevel.LogLevel.ERRORS) { | ||
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 | ||
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 | ||
// equals 'apply' and module.hot.check() will not work. | ||
this.logger.error(info.error); | ||
@@ -162,3 +137,2 @@ } | ||
} | ||
this.logApplyResult(logLevel, outdatedModules, renewedModules); | ||
@@ -172,3 +146,2 @@ }); | ||
} | ||
this.sendRestartMessage(); | ||
@@ -181,3 +154,2 @@ } else if (logLevel >= _LogLevel.LogLevel.ERRORS) { | ||
} | ||
run(messageListener = this.defaultMessageListener) { | ||
@@ -187,3 +159,2 @@ if (!module.hot) { | ||
} | ||
this.logger.info('Waiting for update signal from webpack...'); | ||
@@ -193,9 +164,5 @@ process.on('message', messageListener); | ||
} | ||
} | ||
exports.HmrClient = HmrClient; | ||
var _default = new HmrClient().run(); | ||
exports.default = _default; |
113
HmrServer.js
@@ -5,23 +5,14 @@ "use strict"; | ||
exports.default = void 0; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _child_process = require("child_process"); | ||
var _requireFromString = _interopRequireDefault(require("require-from-string")); | ||
var _LogColors = _interopRequireDefault(require("./LogColors")); | ||
var _Logger = _interopRequireDefault(require("./Logger")); | ||
var _LogLevel = require("./LogLevel"); | ||
var _messageActionType = _interopRequireDefault(require("./messageActionType")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
class HmrServer { | ||
@@ -36,3 +27,2 @@ static defaultReporter({ | ||
const compilerLogLevel = (0, _LogLevel.parseLogLevel)(compilerOptions.stats); | ||
if (!stateValid) { | ||
@@ -42,9 +32,6 @@ if (compilerLogLevel >= _LogLevel.LogLevel.MINIMAL) { | ||
} | ||
return; | ||
} | ||
if (compilerLogLevel > _LogLevel.LogLevel.NONE) { | ||
const statsInfo = stats.toString(compilerOptions.stats); | ||
if (statsInfo) { | ||
@@ -55,3 +42,2 @@ // To avoid log empty statsInfo, e.g. when options.stats is 'errors-only'. | ||
} | ||
if (compilerLogLevel >= _LogLevel.LogLevel.ERRORS) { | ||
@@ -64,3 +50,2 @@ if (stats.hasErrors()) { | ||
} | ||
if (compilerLogLevel >= _LogLevel.LogLevel.MINIMAL) { | ||
@@ -70,3 +55,2 @@ context.webpackLogger.info('Compiled successfully.'); | ||
} | ||
/** | ||
@@ -86,14 +70,9 @@ * @param {{ | ||
serverProcess: null, | ||
/** Valid or invalid state. */ | ||
stateValid: false, | ||
/** Last compiler stats. */ | ||
/** @type import('webpack').Stats */ | ||
webpackStats: undefined, | ||
/** Compiler watching by compiler.watch(...). */ | ||
watching: undefined, | ||
/** | ||
@@ -106,3 +85,2 @@ * Do not use memory-fs because we can't fork bundle from in-memory file. | ||
webpackLogger: new _Logger.default(_LogColors.default.magenta('Webpack')), | ||
/** @type {import('webpack').Compiler} */ | ||
@@ -116,3 +94,2 @@ compiler: undefined, | ||
}); | ||
_defineProperty(this, "sendMessage", action => { | ||
@@ -122,5 +99,3 @@ if (!this.context.serverProcess) { | ||
} | ||
const logLevel = this.context.logLevel != null ? (0, _LogLevel.parseLogLevel)(this.context.logLevel) : (0, _LogLevel.parseLogLevel)(this.context.compiler.options.stats); | ||
if (this.context.fork) { | ||
@@ -140,3 +115,2 @@ this.context.serverProcess.send({ | ||
}); | ||
_defineProperty(this, "getLauncherFileName", stats => { | ||
@@ -146,30 +120,25 @@ const assets = Object.values(stats.toJson().entrypoints).reduce((acc, group) => { | ||
}, []); | ||
if (assets.length === 1) { | ||
// Only one valid assets, so just return it path | ||
return assets[0]; | ||
} // Create temp launcher file which aggregates all assets. | ||
} | ||
// Create temp launcher file which aggregates all assets. | ||
const launcherString = assets.map(asset => `require('${asset.replace(/\\/g, '/')}');`).join('\n'); | ||
const launcherFileName = _path.default.resolve(stats.compilation.compiler.outputPath, `launcher.${stats.hash}.js`); | ||
this.context.fs.writeFileSync(launcherFileName, launcherString); | ||
this.context.fs.writeFileSync(launcherFileName, launcherString); // If not launched yet (eg. if not a restart) | ||
// If not launched yet (eg. if not a restart) | ||
if (!this.context.serverProcess) { | ||
// Delete created files on exit main process. | ||
const deleteLauncher = () => this.context.fs.unlinkSync(launcherFileName); | ||
process.on('exit', deleteLauncher); | ||
process.on('SIGINT', deleteLauncher); | ||
} | ||
return launcherFileName; | ||
}); | ||
_defineProperty(this, "launchAssets", stats => { | ||
return Promise.resolve().then(() => { | ||
const launcherFileName = this.getLauncherFileName(stats); // Execute built scripts | ||
const launcherFileName = this.getLauncherFileName(stats); | ||
// Execute built scripts | ||
if (this.context.fork) { | ||
@@ -182,15 +151,13 @@ /** @type import('child_process').ForkOptions */ | ||
}; | ||
if (process.getuid) { | ||
forkOptions.uid = process.getuid(); | ||
forkOptions.gid = process.getgid(); | ||
} // Launch in forked process | ||
} | ||
// Launch in forked process | ||
this.context.serverProcess = (0, _child_process.fork)(launcherFileName, this.context.args || process.argv, forkOptions); | ||
this.context.serverProcess = (0, _child_process.fork)(launcherFileName, this.context.args || process.argv, forkOptions); // Exit main process when exit child process. | ||
// Exit main process when exit child process. | ||
const onChildExit = code => process.exit(code); | ||
this.context.serverProcess.on('exit', onChildExit); | ||
if (this.context.autoRestart) { | ||
@@ -208,8 +175,7 @@ // Listen messages from child process | ||
} | ||
this.context.logger.info('Launch assets in forked process.'); | ||
return; | ||
} // Require in current process to lauch script. | ||
} | ||
// Require in current process to lauch script. | ||
if (this.context.inMemory) { | ||
@@ -220,3 +186,2 @@ (0, _requireFromString.default)(this.context.fs.readFileSync(launcherFileName).toString()); | ||
} | ||
this.context.serverProcess = process; | ||
@@ -228,7 +193,5 @@ }).catch(err => { | ||
}); | ||
_defineProperty(this, "compilerStart", () => { | ||
try { | ||
this.sendMessage(_messageActionType.default.CompilerStart); | ||
if (this.context.watching && this.context.stateValid) { | ||
@@ -240,5 +203,5 @@ this.context.reporter({ | ||
}); | ||
} // We are now in invalid state | ||
} | ||
// We are now in invalid state | ||
this.context.stateValid = false; | ||
@@ -249,13 +212,14 @@ } catch (ex) { | ||
}); | ||
_defineProperty(this, "compilerDone", stats => new Promise(resolve => { | ||
// We are now on valid state | ||
this.context.stateValid = true; | ||
this.context.webpackStats = stats; // Do the stuff in nextTick, because bundle may be invalidated | ||
this.context.webpackStats = stats; | ||
// Do the stuff in nextTick, because bundle may be invalidated | ||
// if a change happened while compiling | ||
process.nextTick(() => { | ||
// check if still in valid state | ||
if (!this.context.stateValid) return; // print webpack output | ||
if (!this.context.stateValid) return; | ||
// print webpack output | ||
if (this.context.watching) { | ||
@@ -268,12 +232,12 @@ this.context.reporter({ | ||
}); | ||
} // Already has launched process | ||
} | ||
// Already has launched process | ||
if (this.context.serverProcess) { | ||
this.sendMessage(_messageActionType.default.CompilerDone); | ||
} // Start compiled files in child process (fork) or in current process. | ||
} | ||
// Start compiled files in child process (fork) or in current process. | ||
else { | ||
this.launchAssets(stats); | ||
} | ||
resolve(); | ||
@@ -284,8 +248,7 @@ }); | ||
})); | ||
_defineProperty(this, "startWatch", () => { | ||
const { | ||
compiler | ||
} = this.context; // start watching | ||
} = this.context; | ||
// start watching | ||
this.context.watching = compiler.watch(compiler.options.watchOptions, err => { | ||
@@ -299,3 +262,2 @@ if (err) { | ||
}); | ||
_defineProperty(this, "run", (watch = true) => { | ||
@@ -305,3 +267,2 @@ const { | ||
} = this.context; | ||
if (compiler.hooks) { | ||
@@ -316,11 +277,9 @@ // webpack >= 4 | ||
} | ||
if (watch) { | ||
this.startWatch(); | ||
} | ||
return this; | ||
}); | ||
this.context = { ...this.context, | ||
this.context = { | ||
...this.context, | ||
...options | ||
@@ -332,18 +291,18 @@ }; | ||
} = this.context; | ||
if (inMemory) { | ||
const getName = () => 'memory-fs'; | ||
const MemoryFileSystem = require(getName()); | ||
this.context.fs = new MemoryFileSystem(); | ||
_compiler.outputFileSystem = this.context.fs; | ||
} // if (typeof compiler.outputPath === 'string' && !path.isAbsolute(compiler.outputPath)) { | ||
} | ||
// if (typeof compiler.outputPath === 'string' && !path.isAbsolute(compiler.outputPath)) { | ||
// throw new Error('`output.path` needs to be an absolute path or `/`.'); | ||
// } | ||
} | ||
/** | ||
* @param {import('webpack').Stats} stats | ||
*/ | ||
} | ||
exports.default = HmrServer; |
@@ -6,7 +6,4 @@ "use strict"; | ||
exports.tweakWebpackConfig = tweakWebpackConfig; | ||
var _webpack = _interopRequireDefault(require("webpack")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function handleFunction(options) { | ||
@@ -16,9 +13,8 @@ if (typeof options === 'function') { | ||
} | ||
return options; | ||
} | ||
function handleWebpackConfig(webpackConfig) { | ||
return Array.isArray(webpackConfig) ? webpackConfig.map(handleFunction).find(c => c.target === 'node') : handleFunction(webpackConfig); | ||
} | ||
/** | ||
@@ -29,16 +25,10 @@ * Add hmrClient to all entries. | ||
*/ | ||
function tweakWebpackConfig(webpackConfig) { | ||
const config = handleWebpackConfig(webpackConfig); | ||
if (!config) { | ||
throw new Error('Not found webpack configuration. For multiple configurations in single file you must provide config with target "node".'); | ||
} | ||
const hmrClientEntry = require.resolve('./HmrClient'); | ||
const addHmrClientEntry = (entry, entryOwner) => { | ||
const owner = entryOwner; | ||
if (Array.isArray(owner[entry])) { | ||
@@ -55,12 +45,11 @@ owner[entry].splice(-1, 0, hmrClientEntry); | ||
} | ||
}; // Add HmrClient to every entries. | ||
}; | ||
// Add HmrClient to every entries. | ||
addHmrClientEntry('entry', config); | ||
if (!config.plugins) { | ||
config.plugins = []; | ||
} // Add source-map support if configured. | ||
} | ||
// Add source-map support if configured. | ||
if (config.devtool && config.devtool.indexOf('source-map') >= 0) { | ||
@@ -72,11 +61,11 @@ config.plugins.push(new _webpack.default.BannerPlugin({ | ||
})); | ||
} // Enable HMR globally if not. | ||
} | ||
// Enable HMR globally if not. | ||
if (!config.plugins.find(p => p instanceof _webpack.default.HotModuleReplacementPlugin)) { | ||
config.plugins.push(new _webpack.default.HotModuleReplacementPlugin()); | ||
} | ||
return config; | ||
} | ||
/** | ||
@@ -86,17 +75,14 @@ * Add compiler hooks and start watching (through compiler) for changes. | ||
*/ | ||
function hooks(compiler, options) { | ||
return Promise.resolve().then(() => require('./HmrServer')).then(({ | ||
default: HmrServer | ||
}) => new HmrServer({ ...options, | ||
}) => new HmrServer({ | ||
...options, | ||
compiler // webpack compiler | ||
}).run()); | ||
} | ||
/** | ||
* @param {{ fork: boolean | string; inMemory: boolean; logLevel: string; }} options | ||
*/ | ||
function loader(options) { | ||
@@ -103,0 +89,0 @@ Promise.resolve().then(() => require('@babel/register')({ |
@@ -5,10 +5,9 @@ "use strict"; | ||
exports.default = void 0; | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
class LogColors {} | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class LogColors {} // Make functions from LogColors.defaultColors which apply string and surround it with color definition. | ||
// Make functions from LogColors.defaultColors which apply string and surround it with color definition. | ||
exports.default = LogColors; | ||
_defineProperty(LogColors, "defaultColors", { | ||
@@ -22,5 +21,4 @@ bold: '\u001b[1m', | ||
}); | ||
Object.keys(LogColors.defaultColors).forEach(color => { | ||
LogColors[color] = str => `${LogColors.defaultColors[color]}${str}\u001b[39m\u001b[22m`; | ||
}); |
@@ -5,24 +5,18 @@ "use strict"; | ||
exports.default = void 0; | ||
var _LogColors = _interopRequireDefault(require("./LogColors")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
class Logger { | ||
constructor(prefix) { | ||
_defineProperty(this, "prefix", void 0); | ||
this.prefix = prefix; | ||
} | ||
info(message, ...optionalParams) { | ||
console.log(this.prefix, message, ...optionalParams); | ||
} | ||
warn(message, ...optionalParams) { | ||
console.warn(this.prefix, _LogColors.default.yellow(message), ...optionalParams); | ||
} | ||
error(message, ...optionalParams) { | ||
@@ -32,5 +26,3 @@ const string = message.stack || message; | ||
} | ||
} | ||
exports.default = Logger; |
@@ -7,2 +7,3 @@ "use strict"; | ||
// https://webpack.js.org/configuration/stats/#stats | ||
const LogLevel = { | ||
@@ -16,6 +17,4 @@ NONE: 0, | ||
NORMAL: 3 // normal | ||
}; | ||
exports.LogLevel = LogLevel; | ||
function parseLogLevel(stats) { | ||
@@ -22,0 +21,0 @@ let level = LogLevel.NORMAL; |
@@ -5,11 +5,6 @@ #!/usr/bin/env node | ||
var _path = _interopRequireDefault(require("path")); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _yargs = _interopRequireDefault(require("yargs")); | ||
var _loader = _interopRequireDefault(require("./loader")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const options = { | ||
@@ -23,4 +18,3 @@ config: 'webpack.config.js', | ||
}; | ||
const params = _yargs.default.config(options).usage('Usage: $0 [args]').help('help').alias('help', 'h').alias('help', '?').version("1.21.8").alias('version', 'v').options({ | ||
const params = _yargs.default.config(options).usage('Usage: $0 [args]').help('help').alias('help', 'h').alias('help', '?').version("1.21.9").alias('version', 'v').options({ | ||
config: { | ||
@@ -35,3 +29,2 @@ type: 'string', | ||
} | ||
return value; | ||
@@ -88,6 +81,4 @@ } | ||
} | ||
return true; | ||
}).strict().argv; | ||
options.config = params.config; | ||
@@ -94,0 +85,0 @@ options.fork = params.fork; |
@@ -5,11 +5,8 @@ "use strict"; | ||
exports.default = void 0; | ||
var _HmrServer = _interopRequireDefault(require("./HmrServer")); | ||
var _loader = require("./loader"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
class NodeHotLoaderWebpackPlugin { | ||
@@ -28,10 +25,8 @@ /** | ||
_defineProperty(this, "options", void 0); | ||
this.options = options; | ||
} | ||
/** | ||
* @param {import('webpack').Compiler} compiler | ||
*/ | ||
apply(compiler) { | ||
@@ -46,5 +41,3 @@ if (!this.options.force && !compiler.options.watch) return; | ||
} | ||
} | ||
exports.default = NodeHotLoaderWebpackPlugin; |
{ | ||
"name": "node-hot-loader", | ||
"version": "1.21.9", | ||
"version": "1.21.10", | ||
"description": "Hot module replacement for Node.js applications", | ||
@@ -49,4 +49,4 @@ "author": "VZH", | ||
"build-to-tutoron": "babel src --out-dir '../tutoron/node_modules/node-hot-loader/' --copy-files", | ||
"patch-publish": "npm run build && npm version patch && npm run copy:configs && npm publish ./dist/ && git push --follow-tags", | ||
"minor-publish": "npm run build && npm version minor && npm run copy:configs && npm publish ./dist/ && git push --follow-tags", | ||
"patch-publish": "npm run build && npm version patch --no-workspaces-update -m 'v%s' && npm run copy:configs && cd ./dist && npm publish && git push --follow-tags", | ||
"minor-publish": "npm run build && npm version minor --no-workspaces-update -m 'v%s' && npm run copy:configs && cd ./dist && npm publish && git push --follow-tags", | ||
"version": "conventional-changelog -i CHANGELOG.md -s && git add CHANGELOG.md", | ||
@@ -56,28 +56,28 @@ "changelog": "conventional-changelog -i CHANGELOG.md -s" | ||
"dependencies": { | ||
"@babel/register": "^7.18.9", | ||
"@babel/register": "^7.22.5", | ||
"require-from-string": "^2.0.2", | ||
"source-map-support": "^0.5.21", | ||
"yargs": "^17.5.1" | ||
"yargs": "^17.7.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.18.10", | ||
"@babel/core": "^7.18.13", | ||
"@babel/eslint-parser": "^7.18.9", | ||
"@babel/cli": "^7.22.10", | ||
"@babel/core": "^7.22.10", | ||
"@babel/eslint-parser": "^7.22.10", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/preset-env": "^7.18.10", | ||
"@jstoolkit/configs": "^3.84.7", | ||
"@types/webpack-env": "^1.18.0", | ||
"@typescript-eslint/eslint-plugin": "^5.35.1", | ||
"@babel/preset-env": "^7.22.10", | ||
"@js-toolkit/configs": "^3.87.5", | ||
"@types/webpack-env": "^1.18.1", | ||
"@typescript-eslint/eslint-plugin": "^6.4.0", | ||
"babel-plugin-transform-inline-environment-variables": "^0.4.4", | ||
"conventional-changelog-cli": "^2.2.2", | ||
"conventional-changelog-cli": "^3.0.0", | ||
"copyfiles": "^2.4.1", | ||
"eslint": "^8.22.0", | ||
"eslint": "^8.47.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^2.7.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.8.2", | ||
"webpack": "^5.74.0" | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.28.0", | ||
"eslint-plugin-prettier": "^5.0.0-alpha.2", | ||
"prettier": "^3.0.1", | ||
"rimraf": "^5.0.1", | ||
"typescript": "^5.1.6", | ||
"webpack": "^5.88.2" | ||
}, | ||
@@ -84,0 +84,0 @@ "peerDependencies": { |
@@ -67,7 +67,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) | ||
```json | ||
... | ||
"scripts": { | ||
"start": "node-hot --config webpack.config.server.js" | ||
} | ||
... | ||
``` | ||
@@ -192,4 +190,10 @@ | ||
### Debugging in an IDE | ||
If you have problems with sourcemaps or breakpoints, try to launch `node-hot-loader` with `fork` [option](#Options). | ||
Also you may have to use one of the `eval` sourcemap styles for the `devtool` option in the webpack config. | ||
## License | ||
[MIT](https://opensource.org/licenses/mit-license.php) |
65358
698
198
Updated@babel/register@^7.22.5
Updatedyargs@^17.7.2