Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with html-webpack-plugin@5.5.0 when scriptLoading: 'module' is in use #10

Closed
bj00rn opened this issue Dec 21, 2022 · 0 comments · Fixed by #11
Closed

Incompatible with html-webpack-plugin@5.5.0 when scriptLoading: 'module' is in use #10

bj00rn opened this issue Dec 21, 2022 · 0 comments · Fixed by #11

Comments

@bj00rn
Copy link
Contributor

bj00rn commented Dec 21, 2022

When scriptLoading: 'module' introduced in html-webpack-plugin 5.5.0, is in use, both type="module" and nomodule attributes are set on the resulting script tags.

This behaviour defeats the purpose of this plugin since both scripts are executed even on browsers that supports module scripts (at least in Chrome).

image

https://html.spec.whatwg.org/multipage/scripting.html#attr-script-nomodule

package.json

"webpack": "5.75.0",
"webpack-nomodule-plugin": "1.1.0",
"html-webpack-plugin": "5.5.0",

Example webpack config:

   var NoModulePlugin = require('webpack-nomodule-plugin').WebpackNoModulePlugin;
    // OR for import style
    import {WebpackNoModulePlugin} from 'webpack-nomodule-plugin'
    ...
    entry: {
            app: ['../src/index'],
            deprecatedBrowser: ['../src/deprecatedBrowser'],
    },
    plugins: [
        new HtmlWebpackPlugin({
            inject: 'body',
            template: join(__dirname, './src/index.html'),
            scriptLoading: 'module',
        }),
        new WebpackNoModulePlugin({
            filePatterns: ['deprecatedBrowser.**.js']
        })
    ]

Resulting HTML

<script type="module" src="/app.3b55ae197e23b1c9a94b.js"></script>
<script type="module" src="/deprecatedBrowser.5b62336a361365cf6e2e.js" nomodule=""></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant