Customize type attribute of script

Author: chenxsanCreated Jun 30, 2021Updated Jan 2, 2026
Labelswontfix

Is your feature request related to a problem? Please describe.

As of 5.41.0, webpack will output .mjs by default when experimental ECMAScript modules support is enabled. You can see a demo here.

I'm wondering if html-webpack-plugin can support customizing the type attribute of script element:

javascript
<script type='module' src=''></script>

Describe the solution you'd like

Add type='module' to script automatically when users enable experimental ESM support in webpack.config.js.

javascript
module.exports = {
  experiments: {
    outputModule: true,
  },
};

Describe alternatives you've considered

Add a type option so users can customize as they wish.

Additional context

Source: jantimon/html-webpack-plugin