Chunk IDs change when new chunks are added or removed

Do you want to request a feature or report a bug?

What is the current behavior?
Currently it is possible to make chunk hashes remain constant when modules are added or removed from the compilation through the use of the HashedModuleIdsPlugin or the NamedModulesPlugin. However I can’t find such a plugin for chunks. In my project I have many chunks, some of which are commons chunks etc. When a new chunk is added, virtually all the other chunks hashes change, even though they contain the same modules.

If the current behavior is a bug, please provide the steps to reproduce.
At the minimum, create a compilation with 1 entry point, HashedModuleIdsPlugin, and generally cache busting set up as per the guide. Add another entry point with different code and notice that the has of the chunk for the first entry point changes as a result (depending on some ordering of chunk IDs which I haven’t worked out). I will try to put together a specific example.

What is the expected behavior?
Ideally the chunkIds should be deterministic based on e.g. the entry modules, the chunk name, the set of modules in it, etc. Something that doesn’t change unless the code in the chunk changes

If this is a feature request, what is motivation or use case for changing the behavior?
Because this results in unnecessary cache busting which increases load time

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
webpack 2.5.1

Author: Fantashit

1 thought on “Chunk IDs change when new chunks are added or removed

  1. Update – I found that using the undocumented new webpack.NamedChunksPlugin() helps, although unnamed chunks (such as created by automatic code splitting where an explicit name is not provided) will still have unstable chunk ids. This plugin does accept an argument to generate names for chunks without them but it’s a bit awkward to generate a sensible name in some cases.

Comments are closed.