html-webpack-plugin: Webpack 4: compilation.mainTemplate.applyPluginsWaterfall is not a function
Description
Webpack 4 support: compilation.mainTemplate.applyPluginsWaterfall is not a function
Error Message & Stack Trace
compilation.mainTemplate.applyPluginsWaterfall is not a function
at /var/www/myproject/node_modules/html-webpack-plugin/lib/compiler.js:81:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 98
- Comments: 32 (3 by maintainers)
Commits related to this issue
- Try to migrate to webpack 4 Currently, fails on https://github.com/jantimon/html-webpack-plugin/issues/841 — committed to MichalZalecki/react-boilerplate-lite by MichalZalecki 6 years ago
- Setting up HtmlWebpackPlugin https://github.com/jantimon/html-webpack-plugin/issues/841#issuecomment-368324924 — committed to zainfathoni/webpack-demo by zainfathoni 6 years ago
Actually I got a fix for the SyncWaterfallHook error, this seems to be due to different webpack plugin using different versions of Tapable.
But if you install the latest Tapable yourself in your package.json like this
"tapable": "1.0.0-beta.5",Everything seems to work…
Right now this is my package.json setup to get Webpack4 up and running, I hope it helps
@iliatcymbal Use
yarn add webpack-contrib/html-webpack-plugin -D, a fork maintained by WebPack until the maintaner of this plugin is able to resolve this, and you’ll be set. I did it this morning and it works flawlessly.html-webpack-plugin 3.0.0 seems to be out…and everything just works : )
Still getting a deprecation warning with html-webpack-plugin 3.0.0+
There is a PR for Webpack 4 support: https://github.com/jantimon/html-webpack-plugin/pull/823
Here is the source branch: https://github.com/Graham42/html-webpack-plugin/tree/feat/webpack-4
The author warns about chunk-related issues, but in my starter Webpack 4 beta setup, it is working.
Hey, what the status, any news?
new HtmlWebpackPlugin()still doesn’t work for meI’m suing config
And got
@jbruni I get an error from the branch.
compilation.hooks.htmlWebpackPluginAlterChunks = new SyncWaterfallHook(['chunks', 'objectWithPluginRef']); TypeError: SyncWaterfallHook is not a constructor@giacomocerquone I am very sorry but this was fixed 1 month ago.
All unit tests and examples work well with webpack 4 and html-webpack-plugin 3 https://travis-ci.org/jantimon/html-webpack-plugin/builds/361541288
Please make sure that you updated all of your dependencies.
If updating does not help please open a new issue with the smallest possible webpack config so we can reproduce and fix the issue.
Solution is to run
yarn add webpack-contrib/html-webpack-plugin -Dyarn can fix the dependencies according to packages.
Somehow the npm install html-webpack-plugin --save-dev is not picking the latest version. Use npm install html-webpack-plugin@3.2.0 --save-dev
@Silvia813 had the same issue, fixed it by installing the latest versions of my babel-loaders
@jantimon I tried that, but it doesn’t work anymore, it gives me compilation.mainTemplate.applyPluginsWaterfall is not a function now
It does not exist anymore please use
npm install html-webpack-plugin --save-devStill getting this error too in a react native project with styleguidist. I’m using this configuration for a project of mine: https://github.com/styleguidist/react-styleguidist/tree/master/examples/react-native
This is the error:
This https://github.com/webpack-contrib/html-webpack-plugin/commit/6319451c00494ec32fea9176bfdcb7528185ab35 fixed it for me. Thanks.
@TomasHubelbauer I updated to
webpack-contrib/html-webpack-contribbut still have an error:Any idea why? Thank you
@jbruni sorry for the noise, the error thrown by html-plugin was related to babel. It’s very weird anyway: I wrote a simple plugin on my own to put the assets into the html and exclude html-webpack-plugin possible errors. It worked flawlessly and the error was instead fired into console at runtime (it’s not fired by webpack): how did it end up into the html file? 🤨
@stevenfitzpatrick is your fix still working for you? I tried but it does not seem to work. Will this be fixed soon in master? I mean, webpack@4 compatibility.
I see a long list like:
My index.html is 12 lines long, so I don’t know what index.html:339 is. Removing
html-webpack-pluginworks fine, but I have no hijacked html xD