reliable-module-ids-plugin

This Webpack plugin provides more reliable module IDs for improved long-term caching and code reuse between project installations and builds.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
reliable-module-ids-plugin
301.0.15 years ago5 years agoMinified + gzip package size for reliable-module-ids-plugin in KB

Readme

Reliable Module IDs Plugin
GitHub license Build Status npm version Greenkeeper badge
This Webpack plugin provides more reliable module IDs for improved long-term caching and code reuse between project installations and builds. It is intended to bridge the gap between Webpack 4 and the deterministic IDs feature coming in Webpack 5.

Installation

This is a Node.js module available through the npm registry. Node 8 and Webpack 4.38 or higher are required.
Installation is done using the npm install command:
$ npm install --save-dev reliable-module-ids-plugin

Once installed the plugin can be added to your Webpack plugins configurationplugins:
const ReliableModuleIdsPlugin = require('reliable-module-ids-plugin')

module.exports = {
  //...
  plugins: [
    new ReliableModuleIdsPlugin({
      // options
    })
  ]
}

If you have already configured optimization.moduleIdsoptimization you should set this to false so Webpack will defer to the provided algorithm.

Options

hashFunction

The hashing algorithm to use, defaults to 'md5'. All functions from Node.JS' crypto.createHashcreateHash are supported.

hashDigest

The encoding to use when generating the hash, defaults to 'hex'. All encodings from Node.JS' hash.digestdigest are supported.

hashDigestLength

The prefix length of the hash digest to use, defaults to 8. Note that some generated IDs might be longer than specified here, to avoid module ID collisions.

Prior Art

This plugin is based upon Webpack's built-in HashedModuleIdsPluginhashed-plugin by Tobias Koppers and uses the node_modules path normalization as demonstrated in the SimpleNamedModulesPluginsimple-plugin by Tomer Brisker.

Development

This project uses Prettier for automatic code formatting and is tested with Jasmine.

License

This package is MIT licensed.