jantimon/html-webpack-plugin

support for setting attributes

electriquo opened this issue · 1 comments

i am using webpack 5 and when the web app is launched, the browser shows the following error

Uncaught SyntaxError: Cannot use 'import.meta' outside a module

currently, the output html has the following

<script defer src="vendors.0395f232202da9c00fd5.bundle.js"></script>
<script defer src="main.0395f232202da9c00fd5.bundle.js"></script>

and what fix the issue is having type="module"

<script defer src="vendors.0395f232202da9c00fd5.bundle.js"></script>
<script defer src="main.0395f232202da9c00fd5.bundle.js" type="module"></script>

note that

There is no need to use the defer attribute (see <script> attributes) when loading a module script; modules are deferred automatically.

i used to leverage https://github.com/numical/script-ext-html-webpack-plugin to handle it

new ScriptExtHtmlWebpackPlugin({
  module: "main",
}),

but https://github.com/numical/script-ext-html-webpack-plugin has been deprecated and has no support for webpack 5. also tried setting the value "module" for the following configurations without any success:

how can type="module" be added?
if the type="module" is not needed, how can i fix the issue?

this has been added to the lastest version (5.5.0) thanks to @noppa #1672