Skip to content

Commit 2288f20

Browse files
committedMar 6, 2018
fix(hooks): Remove deprecated tapable calls #879
1 parent 020b714 commit 2288f20

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class HtmlWebpackPlugin {
6262
});
6363
}
6464

65-
compiler.plugin('make', (compilation, callback) => {
65+
// Backwards compatible version of: compiler.hooks.make.tapAsync()
66+
(compiler.hooks ? compiler.hooks.make.tapAsync.bind(compiler.hooks.make, 'HtmlWebpackPlugin') : compiler.plugin.bind(compiler, 'make'))((compilation, callback) => {
6667
// Compile the template (queued)
6768
compilationPromise = childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation)
6869
.catch(err => {
@@ -82,7 +83,8 @@ class HtmlWebpackPlugin {
8283
});
8384
});
8485

85-
compiler.plugin('emit', (compilation, callback) => {
86+
// Backwards compatible version of: compiler.plugin.emit.tapAsync()
87+
(compiler.hooks ? compiler.hooks.emit.tapAsync.bind(compiler.hooks.emit, 'HtmlWebpackPlugin') : compiler.plugin.bind(compiler, 'emit'))((compilation, callback) => {
8688
const applyPluginsAsyncWaterfall = self.applyPluginsAsyncWaterfall(compilation);
8789
// Get chunks info as json
8890
// Note: we're excluding stuff that we don't need to improve toJson serialization speed.

‎lib/compiler.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ module.exports.compileTemplate = function compileTemplate (template, context, ou
5555
// Fix for "Uncaught TypeError: __webpack_require__(...) is not a function"
5656
// Hot module replacement requires that every child compiler has its own
5757
// cache. @see https://github.com/ampedandwired/html-webpack-plugin/pull/179
58-
childCompiler.plugin('compilation', compilation => {
58+
59+
// Backwards compatible version of: childCompiler.hooks.compilation
60+
(childCompiler.hooks ? childCompiler.hooks.compilation.tap.bind(childCompiler.hooks.compilation, 'HtmlWebpackPlugin') : childCompiler.plugin.bind(childCompiler, 'compilation'))(compilation => {
5961
if (compilation.cache) {
6062
if (!compilation.cache[compilerName]) {
6163
compilation.cache[compilerName] = {};

0 commit comments

Comments
 (0)
Please sign in to comment.