From 2288f20ee3185c2ace0c8e97a1c32e2a7e11f0e0 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Tue, 6 Mar 2018 11:27:49 +0100 Subject: [PATCH] fix(hooks): Remove deprecated tapable calls #879 --- index.js | 6 ++++-- lib/compiler.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b2e9013d..ae6026e5 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,8 @@ class HtmlWebpackPlugin { }); } - compiler.plugin('make', (compilation, callback) => { + // Backwards compatible version of: compiler.hooks.make.tapAsync() + (compiler.hooks ? compiler.hooks.make.tapAsync.bind(compiler.hooks.make, 'HtmlWebpackPlugin') : compiler.plugin.bind(compiler, 'make'))((compilation, callback) => { // Compile the template (queued) compilationPromise = childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation) .catch(err => { @@ -82,7 +83,8 @@ class HtmlWebpackPlugin { }); }); - compiler.plugin('emit', (compilation, callback) => { + // Backwards compatible version of: compiler.plugin.emit.tapAsync() + (compiler.hooks ? compiler.hooks.emit.tapAsync.bind(compiler.hooks.emit, 'HtmlWebpackPlugin') : compiler.plugin.bind(compiler, 'emit'))((compilation, callback) => { const applyPluginsAsyncWaterfall = self.applyPluginsAsyncWaterfall(compilation); // Get chunks info as json // Note: we're excluding stuff that we don't need to improve toJson serialization speed. diff --git a/lib/compiler.js b/lib/compiler.js index 3d4765ba..90b2b8f1 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -55,7 +55,9 @@ module.exports.compileTemplate = function compileTemplate (template, context, ou // Fix for "Uncaught TypeError: __webpack_require__(...) is not a function" // Hot module replacement requires that every child compiler has its own // cache. @see https://github.com/ampedandwired/html-webpack-plugin/pull/179 - childCompiler.plugin('compilation', compilation => { + + // Backwards compatible version of: childCompiler.hooks.compilation + (childCompiler.hooks ? childCompiler.hooks.compilation.tap.bind(childCompiler.hooks.compilation, 'HtmlWebpackPlugin') : childCompiler.plugin.bind(childCompiler, 'compilation'))(compilation => { if (compilation.cache) { if (!compilation.cache[compilerName]) { compilation.cache[compilerName] = {};