v5.5.0 contains breaking change with type attribute having undefined value
Current behaviour 💣
When using a custom template (and injecting tags/attributes manually), v5.5.0 has introduced a breaking change where the "type" attribute can be present with a value of undefined. In my case, this result in the rendering of type="undefined", preventing all scripts from being loaded by the browser.
htmlWebpackPlugin.tags.bodyTags[0].attributes
// {type: undefined, otherStuff: ...}
Expected behaviour ☀️
Like v5.4.0: attributes with an undefined value should not be present in the attributes object.
htmlWebpackPlugin.tags.bodyTags[0].attributes
// {otherStuff: ...}
Reproduction Example 👾
Not applicable.
Environment 🖥
- v5.4.0 is okay
- v5.5.0 is the first version to have
undefinedvalues
I've added:
Object.entries(attributes)
.filter(([key, val]) => val !== undefined)
... rest of code
to my template for now, as that's easy enough, but I do believe this should be addressed in v5.5.1
Oh thanks for the input - I guess that's from this change: https://github.com/jantimon/html-webpack-plugin/commit/1e4262528ff02a83e1fc7739b42472680fd205c2
type: options.scriptLoading === 'module' ? 'module' : undefined,
could be changed to a spread logic:
...( options.scriptLoading === 'module' ? { type: 'module' } : {})
That would definitely work :-)