Html-webpack-plugin: Webpack v5.22.0` breaks HtmlWebpackLoader

Created on 15 Feb 2021  路  25Comments  路  Source: jantimon/html-webpack-plugin

See here, where webpack dont give a single sh*t: https://github.com/webpack/webpack/issues/12689


Bug report




Updating from 5.21.2 to 5.22.0 makes my build spit out the following errors for all my HtmlWebpackPlugins:

message: Error: The loader "<path>\\node_modules\\html-webpack-plugin\\li b\\loader.js!<path>\\src\\app\\app.html" didn't return html.\n+

Relevant webpack config

new HtmlWebpackPlugin({
            template: path.resolve(__dirname, "src", "app", "app.html"),
            templateParameters: {
                pages
            },
            filename: 'app.html',
            scriptLoading: "defer",
            chunks: ['app']
        })

rest of stack trace:

      '  - index.js:336 HtmlWebpackPlugin.evaluateCompilationResult\n' +
      '    [Useroo]/[html-webpack-plugin]/index.js:336:24\n' +        
      '  \n' +
      '  - index.js:243 \n' +
      '    [Useroo]/[html-webpack-plugin]/index.js:243:22\n' +        
      '  \n' +
      '  - runMicrotasks\n' +
      '  \n' +
      '  - task_queues.js:93 processTicksAndRejections\n' +
      '    internal/process/task_queues.js:93:5\n' +
      '  \n' +
      '  - async Promise.all\n' +
      '  \n' +
      '  - async Promise.all\n' +
      '  \n'
  },

What is the expected behavior?

Not to explode, it doesn't in 5.21.2 but does in 5.22.0

Other relevant information:
webpack version: 5.22.0 (not 5.21.2)
Node.js version: 12, 14
Operating System: Windows, Linux

Most helpful comment

I released a fix as [email protected] - however I strongly recommend to use webpack 5 wit html-webpack-plugin@5

All 25 comments

First and last warning for sh*t. Respect other developers.

For the future, I recommend you apply updates step by step, then it will be easier to determine where the problem came from

only updated webpack, from 5.21.2 to 5.22.0

UPDATE: false alarm. Upgrading html-webpack-plugin from 4.5.1 to 5.1.0 fixed the issue for us.


We confirm there is a breaking behaviour between webpack 5.21.2 and 5.22.0.
It manifested to a different error message for our setup.

Error: The loader "my-app/node_modules/html-webpack-plugin/lib/loader.js!/home/itghuc/my-app/index.ejs" didn't return html

Very basic usage for our setup.

new HtmlWebpackPlugin({ template: 'index.ejs' })

@trullock Please create reproducible test repo

https://github.com/webpack/webpack/issues/12687#issuecomment-779530228, please update html-webpack-plugin to v5, v4 is not fully compatibility with webpack v5

@trullock Please create reproducible test repo

Sure, I'll watch https://github.com/webpack/webpack/issues/12687#issuecomment-779530228 first and see what happens there.

I'll pursue updating html-webpack-plugin too

@trullock does updating resolve the issue for you?

I have also encountered the above problems.
(What a bad day! I thought it was because of the environment.Because I deployed on Windows and developed on Mac)

There are two solutions:

  1. update [email protected] -> @5.x.x
    > https://github.com/webpack/webpack/issues/12689
    > alexander-akait :You need to update html-webpack-plugin to v5, v4 is not fully compatibility with webpack v5

or

  1. webpack use < @5.22.0

We have the same problem. We have webpack 5.21.2 but html-webpack-plugin is dependency from something else. And we can't find the dependency. If we use 2 days ago package-lock.json it works. If we do clean npm install it breaks

@mixalistzikas npm ls html-webpack-plugin

UNMET OPTIONAL DEPENDENCY @storybook/[email protected]
-- UNMET OPTIONAL DEPENDENCY @storybook/[email protected] -- UNMET OPTIONAL DEPENDENCY [email protected]

@mixalistzikas run npm i -D html-webpack-plugin, you have UNMET OPTIONAL DEPENDENCY, it is bad

You forget to run npm i

npm ls html-webpack-plugin should show html-webpack-plugin, if you don't see it you done something wrong

@mixalistzikas All works fine?

No, I still get errors
image

As you can see the problem in script-webpack-plugin from @angular-devkit, nothing to fix here

@mixalistzikas just add the following into your project package.json and hope that its compatible^^

  "resolutions": {
    "html-webpack-plugin": "^5.1.0"
  }

you can do this
灞忓箷蹇収 2021-02-18 涓婂崍11 09 12

Upgrading html-webpack-plugin from 4.5.1 to 5.1.0 fixed the issue for us. 馃榾馃憤

Really a dangerous update, sorry

I released a fix as [email protected] - however I strongly recommend to use webpack 5 wit html-webpack-plugin@5

That's fantastic, thanks. I wasn't using v5 originally due to some other bug which is perhaps now fixed separately. 4.5.2 hopefully gets us out of this scrape and I'll come back if there's an issue with the current V5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amorphius picture amorphius  路  3Comments

ghaiklor picture ghaiklor  路  3Comments

var-bp picture var-bp  路  3Comments

mmjamal picture mmjamal  路  3Comments

klinki picture klinki  路  3Comments