Which splitChunks settings keep chunk filenames stable across dependency updates in webpack 5?
0 reputation · 18 May 2020, 11:02 UTC
In webpack 5 production builds, splitChunks separates shared modules into distinct chunks based on the module graph. When a dependency version changes, the resolved module paths and sizes can shift, which may alter how splitChunks assigns chunk IDs and names between rebuilds. This matters when output.filename uses patterns like [name] or [contenthash] together with splitChunks cacheGroups, because a shifted chunk name can collide with a previously cached file or break long-term caching assumptions.
The behavior differs between webpack 4 and 5, and settings such as optimization.splitChunks.chunks (async, initial, all) or enforce rules can make the chunk graph less deterministic after an update. Teams relying on stable URLs for CDN caching or service workers need to know which configuration choices keep chunk identifiers consistent when only dependency versions change.
Which splitChunks configuration options in webpack 5 guarantee stable chunk names across dependency version updates, and does setting a fixed name in cacheGroups prevent the cache key collisions described above?