Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack v5.22.0` breaks HtmlWebpackLoader #1603

Closed
trullock opened this issue Feb 15, 2021 · 26 comments
Closed

Webpack v5.22.0` breaks HtmlWebpackLoader #1603

trullock opened this issue Feb 15, 2021 · 26 comments

Comments

@trullock
Copy link

trullock commented Feb 15, 2021

See here, where webpack dont give a single sh*t: webpack/webpack#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

@alexander-akait

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@trullock
Copy link
Author

only updated webpack, from 5.21.2 to 5.22.0

@3cp
Copy link

3cp commented Feb 15, 2021

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

@alexander-akait

This comment has been minimized.

@alexander-akait
Copy link
Collaborator

webpack/webpack#12687 (comment), please update html-webpack-plugin to v5, v4 is not fully compatibility with webpack v5

@trullock

This comment has been minimized.

@jantimon

This comment has been minimized.

@aiden271828
Copy link

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

webpack/webpack#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

@mixalistzikas

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@mixalistzikas

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@mixalistzikas

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@mixalistzikas

This comment has been minimized.

@alexander-akait
Copy link
Collaborator

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

@MartB
Copy link

MartB commented Feb 17, 2021

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

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

@913453448

This comment has been minimized.

@bitbw
Copy link

bitbw commented Feb 18, 2021

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

@takhello

This comment has been minimized.

@jantimon
Copy link
Owner

jantimon commented Feb 18, 2021

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

@trullock
Copy link
Author

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

@dasler-fw
Copy link

dasler-fw commented Feb 20, 2023

I released a fix as [email protected] - 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 [email protected] and newer.

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

and etc.

Please update we.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests