Skip to content

Commit

Permalink
fix(hooks): Remove deprecated tapable calls #879
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Mar 6, 2018
1 parent 020b714 commit 2288f20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {};
Expand Down

0 comments on commit 2288f20

Please sign in to comment.