Closed davidmurdoch closed 3 months ago
@davidmurdoch
This is not a bug, this is the feature.
The html bundler can handeln only script
tags defined in a template.
The JS files defined in entry will be ignored or may works unexpected.
The integrity option makes a seance only for a generated HTML with script
tags.
If you add a check to ensure hashes
is not undefined
it seems to work fine. If it's not supported at all the plugin should throw a specific error saying so.
Since a webpack config can be created to conditionally include entry points based on conditions/flags a user provides, I could see cases where someone would end up with a config that doesn't have an HTML files to compile, like in debugging (me, today), partial compilation (common in large projects and microservices), or an empty entry point directory specified via the directory feature (maybe it's generated from a boilerplate project and no HTML files have been created/needed).
Anyway, I think you should reconsider this plugin's lack of ability to be a complete "No Op" when it doesn't need to do any work. I don't think it should have errored in this case. ☺️
@davidmurdoch
Thanks for clarifying. You are right, I will add the checking for this use case.
@davidmurdoch the issue is fixed in the v3.17.2
Current behaviour
This is a weird issue because it's not really a use case for this plugin. I only discovered it while try to debug an issue when using the cache (might open another issue for that later).
If
integrity: true
is set , and there are no HTML entries (with a script tag to add integrity to, I think), the plugin throws an error.The following config causes a failure:
The error message when running
npx -y webpack
:Expected behaviour
It shouldn't error :-)
I think you just need to check that
hashes
exists before trying to iterate.Reproduction
Environment
Additional context
Appreciation for the useful project