jantimon / jantimon/html-webpack-plugin

Customize type attribute of script

Open
#1,663 7 comments 2 reactions 0 assignees View on GitHub
wontfix
Dominant language
JavaScript
Stars
10.7k
Forks
1.3k
Avg merge
1m
Merged PRs (30d)
1

Description

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

As of [5.41.0](https://github.com/webpack/webpack/releases/tag/v5.41.0), webpack will output `.mjs` by default when experimental ECMAScript modules support is enabled. You can see a demo [here](https://stackblitz.com/edit/node-axut71?file=webpack.config.js).

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

```js

```

**Describe the solution you'd like**

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

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

**Describe alternatives you've considered**

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

**Additional context**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the plugin generates the script element and compare that output with the webpack.config.js example using experiments.outputModule. Define whether completion means automatic type="module" handling, a user-configurable type option, or both, then verify the generated HTML.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.