UNPKG

@oriflame/constant-moduleids-webpack-plugin

Version:

Webpack plugin for generating constant hashed moduleIds for use with DLL plugin.

6 lines (3 loc) 1.29 kB
In its basic form [HashedModuleIdsPlugin](https://webpack.js.org/plugins/hashed-module-ids-plugin/) and [DeterministicModuleIdsPlugin](https://webpack.js.org/configuration/optimization/#optimizationmoduleids) both use `Module.identifier()` as a source for final moduleId. It is true that generated ids by these plugins are based on module name/path but it is not always only the module name. In some cases webpack internally creates a `ConcatenatedModule` for multiple internal modules for one main module and then `identifier` contains something like `<module name>|<hash of all internal modules>`. This id can change between multiple builds even when the version of some dependency (main module) doesn't change. It is probably caused by using different number of internal modules. And this volatility is a problem when the result bundle is used as a DLL with `DLLReferencePlugin`. Every consumer would have to rebuild its bundle every time the dll bundle would change (every change, even patch, would have to be treated as a breaking). This plugin replaces the use of `Module.identifier()` with `Module.libIdent()` (resp. `getFullModuleName` with `getShortModuleName`) which results in **only the name of module being used**. That way **moduleIds never change and can be relied on**.