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

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 10
  • Comments: 26 (2 by maintainers)

Most upvoted comments

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' })

I released a fix as html-webpack-plugin@4.5.2 - however I strongly recommend to use webpack 5 wit html-webpack-plugin@5

I released a fix as html-webpack-plugin@4.5.2 - however I strongly recommend to use webpack 5 wit html-webpack-plugin@5

It’s only thing that finally helped: using @4.5.2. HtmlWebpackPlugin is not working with webpack@5.21.0 and newer.

Giving: htmlwebpackplugin ReferenceError: module is not defined Object.data:text/javascript,webpack_public_path = htmlWebpackPluginPublicPath;

and etc.

Please update we.

Upgrading html-webpack-plugin from 4.5.1 to 5.1.0 fixed the issue for us. 😀👍

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