Highlights
webpack now optimizes exports and concatenates modules per runtime (often equal entrypoint), which will lead to better optimization when using multiple entrypoints.
Entrypoints do no longer affect each other when using a runtime per entrypoint.
webpack defaults has been improved to be optimized for http/2 serving (creating more chunks as request limit as been increased).
Features
- new option
splitChunks.enforceSizeThreshold
resp.splitChunks.cacheGroups[x].enforceSizeThreshold
- when over this limit,
minRemainingSize
,maxInitialRequests
andmaxAsyncRequests
are ignore - This enforces big chunks to be splitted, e. g. big vendors, even if this adds more requests or keeps small remaining chunks
- when over this limit,
- added
compilation/compiler.getCache
API for easier to use caching- also exposes
getLazyHashedEtag
to plugins
- also exposes
- Allow to use
"..."
in more configuration options to access the defaults:
cache.managed/immutablePaths
,module.defaultRules
,optimization.minimizer
- assets now use a content hash instead of the module hash
- improved the
experiments.mjs
to mirror node.js behaviortype: "module"
*.cjs
and*.mjs
data:text/javascript
anddata:application/javascript
- Disallow not fully specified requests in imports from these types
- add
Rule.descriptionData
to allow matching data from the package.json - add support for parsing and evaluating
??
expressions - add
entry[x].runtime
option to set runtimeChunk set entry optimization.usedExports
now analyses used exports separately per runtime to allow independent optimization- add
"global"
option tooptimization.usedExports
analyse used exports globally instead (faster)
- add
optimization.concatenateModules
now optimizes per runtime when analysed byoptimization.usedExports
- add
splitChunks.usedExports
resp.splitChunks.cacheGroups[x].usedExports
to compare modules based on used exports or ignore them while comparing- This is relevant when looking for shared module to combine them in a chunk. When enabled modules will only be considered as equal when used exports match.
false
is usually better for long term caching and a smaller total sizetrue
is usually better for load performance of individual pages.- This is enabled by default in production mode.
- add
optimization.mangleExports: "size"
to optimize export names for minimal size - give useful error message when using
runtime
ordependOn
incorrectly inentry
- improve
--progress
and--progress --profile
output - store build dependencies and store cache after finishing the compilation in watch mode to avoid adding extra delay
Changes
splitChunks.minSize
defaults to20k
in productionsplitChunks.enforceSizeThreshold
defaults to50k
in production- using
compilation.cache
directly is now deprecated - deprecate
optimization.noEmitOnErrors
in favor ofoptimization.emitOnErrors
- negative flags can be confusing
Bugfixes
- improve the merging of resolve options to apply
byDependency
in the correct order as specified - calling
compiler.close
multiple times will still call all callbacks correctly Compiler.hooks.invalid
will now also be triggered when manually invalidating the watching- fix passing
externalsType
via configuration - add
webpack-cli
as optional peer dependency to allow using it with Yarn 2 - fix display for built time in stats at 10 o'clock