jantimon/html-webpack-plugin

Customize type attribute of script

chenxsan opened this issue ยท 6 comments

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:

<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.

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

Describe alternatives you've considered

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

Additional context

Good idea - we already have the scriptLoading option which controls where and how tags are injected.

What about adding a new option here?

@jantimon Yeah, a new option would be suitable.

I guess it could be scriptLoading: 'module' - what is the recommended way to load webpack 5 generated js modules? defer?

Modules are deferred automatically, so there's no need to set one.

stale commented

This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days.

not stale