webpack: upgrade timefix and warnfix plugins to use hooks

This commit is contained in:
Pooya Parsa 2018-02-26 14:14:24 +03:30
parent f987d16adb
commit 08d02ddb10
2 changed files with 4 additions and 4 deletions

View File

@ -1,17 +1,17 @@
// Taken from https://github.com/egoist/poi/blob/3e93c88c520db2d20c25647415e6ae0d3de61145/packages/poi/lib/webpack/timefix-plugin.js#L1-L16 // Taken from https://github.com/egoist/poi/blob/3e93c88c520db2d20c25647415e6ae0d3de61145/packages/poi/lib/webpack/timefix-plugin.js#L1-L16
// Thanks to @egoist // Thanks to @egoist
module.exports = class TimeFixPlugin { module.exports = class TimeFixPlugin {
constructor(timefix = 11000) { constructor(timefix = 5000) {
this.timefix = timefix this.timefix = timefix
} }
apply(compiler) { apply(compiler) {
compiler.plugin('watch-run', (watching, callback) => { compiler.hooks.watchRun.tap('timefix-plugin', (watching, callback) => {
watching.startTime += this.timefix watching.startTime += this.timefix
callback() callback()
}) })
compiler.plugin('done', stats => { compiler.hooks.done.tap('timefix-plugin', stats => {
stats.startTime -= this.timefix stats.startTime -= this.timefix
}) })
} }

View File

@ -1,6 +1,6 @@
module.exports = class WarnFixPlugin { module.exports = class WarnFixPlugin {
apply(compiler) /* istanbul ignore next */ { apply(compiler) /* istanbul ignore next */ {
compiler.plugin('done', stats => { compiler.hooks.done.tap('warnfix-plugin', stats => {
stats.compilation.warnings = stats.compilation.warnings.filter(warn => { stats.compilation.warnings = stats.compilation.warnings.filter(warn => {
if ( if (
warn.name === 'ModuleDependencyWarning' && warn.name === 'ModuleDependencyWarning' &&