Change8

v5.110.0

📦 webpackView on GitHub →
27 features🐛 4 fixes🔧 15 symbols

Summary

This release introduces significant performance improvements through enhanced minification of CSS and HTML, better tree-shaking for CommonJS modules, and new performance hinting features. It also adds several new module rule conditions and presets, improving build flexibility and developer experience.

Migration Steps

  1. Replace the `webpack-node-externals` plugin with the `externalsPresets.nodeModules` preset and its `allowlist` option.

✨ New Features

  • Wrap concatenated modules in lazy `__webpack_require__.cw` accessors and inline `require()`.
  • Add performance hints reporting build costs: duplicate packages and modules, circular dependencies, broad contexts, large modules and chunks, hotspots, `eval`, missing PURE annotations, polyfills, redundant dynamic imports, OS-dependent rules, cache effectiveness, chunk loading, splitting refusals, skipped optimizations, and unused rules, defines, externals, aliases, and barrel reexports. Oversized assets name their largest modules, and entrypoints with runtimes recommend `optimization.runtimeChunk`. Enable all checks with `performance.all`, report hints in stats only with `performance.hints: "stats"`, and get them in a stable order.
  • Add the `descriptionRelativePath` module rule condition.
  • Add OS-independent `glob` matching to module rules.
  • Report inner-graph, AMD and bare `module` bailouts in `optimizationBailout`.
  • Allow marking externals as side-effect-free with a `sideEffects` flag.
  • Give externals the original request of a context module element.
  • Add the `externalsPresets.nodeModules` preset with an `allowlist` option to externalize installed packages, replacing the `webpack-node-externals` plugin.
  • Add `output.library.umdAmdContainer` for an AMD-style loader branch in UMD.
  • Resolve `@custom-media` values that are `true` / `false` or name another custom media.
  • Add the `__webpack_css_server_styles__` module variable to read CSS collected while rendering without a DOM, preserving the order styles were applied.
  • Patch the HTML `<head>` in place on hot update instead of forcing a full reload, including when a `<script>` that never executed is removed.
  • Scope counter names in CSS modules; fix the `counter()` counter-style and `animation` timeline keywords.
  • Derive `import defer` / `import source` from the target and fix the source phase.
  • Emit analyzable ESM urls for chunks, assets, styles, workers and wasm.
  • Tree shake CommonJS: `module.exports` object literals, exports destructured from a `require()` binding, unused method requires, and unused side-effect-free `require()` calls and reexports.
  • Resolve relative entry `baseUri` values and bake one side of a hash cycle.
  • Minify CSS further, including shorthands, box longhands, `font-weight`, `<position>` and `font-stretch` keywords, colors, numbers, times, zero units, `calc()` and math functions, selector lists, An+B, keyframe selectors, media-feature ranges, `unicode-range`, `transition` layers, `display`, transforms, gradients, font families, identical repeated declarations, and dead rules. Abilities are read off target browsers, `vendorPrefixes` adds/drops prefixes, and `rewriteCustomProperties` shortens custom property values.
  • Safely minify CSS (with source maps) and HTML assets when `optimization.minimize` is enabled, unless a minimizer is already configured.
  • Minify HTML further by dropping redundant quotes, whitespace, unnecessary escapes, implied tags, optional end tags, empty attributes, and nested empty elements; folding enumerated values and casing; normalizing attributes; and rewriting `style`, token lists, `srcset`, `sizes`, URL, integer, boolean, viewport `content`, inline `<style>`, and JSON `<script>` bodies. Adds `optimization.minimize.html` options: `collapseWhitespace`, `mergeStyles`, `minifyConditionalComments`, `minifySrcdoc`, `preserveComments`, `removeEmptyAttributes`, `removeEmptyElements`, `removeImpliedTags`, `removeRedundantAttributes`, `sortAttributes`, and `sortTokenLists`.
  • Suggest the closest name or a casing fix anywhere in a failed request.
  • Add aggregated `shutdown` hook to `MultiCompiler`.
  • Report which compilers changed on the MultiCompiler `done` hook.
  • Add `[containedpath]`/`[containedfile]` placeholders for `[path]`/`[file]` of asset and html modules with `experiments.futureDefaults`.
  • Support an object for an entry's `html` that overrides `output.html` per option.
  • Configure or exclude each asset type's minifier via `optimization.minimize`.
  • Support printing CSS and HTML beautified as well as minified.

🐛 Bug Fixes

  • Fix the `counter()` counter-style and `animation` timeline keywords.
  • Fix the source phase for `import defer` / `import source`.
  • Keep CSS in the order styles were applied when using `__webpack_css_server_styles__`.
  • Patch the HTML `<head>` in place on hot update instead of forcing a full reload, including when a `<script>` that never executed is removed.

Affected Symbols