Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including webpack-nomodule-plugin with all npm packages installed. Try it out:

require("html-webpack-plugin/package.json"); // html-webpack-plugin is a peer dependency. require("webpack/package.json"); // webpack is a peer dependency. var webpackNomodulePlugin = require("webpack-nomodule-plugin")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

webpack-nomodule-plugin v1.0.1

a plugin for html-webpack-plugin to label certain chunks as legacy-only via the nomodule attribute

Webpack Nomodule Plugin

Assigns the nomodule attribute to script tags injected by Html Webpack Plugin


  1. Install via npm i -D webpack-nomodule-plugin
  2. Add to your webpack config AFTER HtmlWebpackPlugin
    var NoModulePlugin = require('webpack-nomodule-plugin').WebpackNoModulePlugin;
    // OR for import style
    import {WebpackNoModulePlugin} from 'webpack-nomodule-plugin'
    plugins: [
        new HtmlWebpackPlugin({
            filename: join(OUTPUT_DIR, './dist/index.html'),
            hash: false,
            inject: 'body',
            minify: minifyOptions,
            showErrors: false
            template: join(__dirname, './src/index.html'),
        new WebpackNoModulePlugin({
            filePatterns: ['polyfill.**.js']

The plugin takes a configuration argument with a key called filePatterns. This is an array of file globs (provided via minimatch) representing which injected script tags to flag as nomodule. Scripts with this attribute will not be executed on newer browsers, so IE and other browser polyfills can be skipped if not needed.


Testing is done via ts-node and mocha. Test files can be found in /spec, and will be auto-discovered as long as the file ends in .spec.ts. Just run npm test after installing to see the tests run.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free