Change8

v5.106.0

📦 webpackView on GitHub →
10 features🐛 13 fixes🔧 13 symbols

Summary

This release introduces new configuration options for CSS modules, VirtualUrlPlugin context support, and improved tree-shaking capabilities via CJS destructuring. Numerous bug fixes address issues across CSS processing, path resolution, and module generation.

Migration Steps

  1. If using VirtualUrlPlugin, note that the `context` option defaults to 'auto' and can now be set explicitly to a string path.
  2. If relying on specific behavior of `import.meta` in ESM output, be aware it now returns a populated object instead of `{}` and is hoisted.

✨ New Features

  • Add `exportType: "style"` for CSS modules to inject styles into DOM via HTMLStyleElement, similar to style-loader functionality.
  • Add `context` option support for VirtualUrlPlugin, allowing custom context path for resolving relative imports in virtual modules.
  • Generate different `CssModule` instances for different `exportType` values.
  • Added the `localIdentHashFunction` option to configure the hash function used for hashing.
  • The `localIdentName` option can now be a function.
  • Added support for destructuring assignment `require` in cjs, allowing for tree shaking.
  • Added the `validate` option to enable/disable validation in webpack/plugins/loaders, also implemented API to make it inside plugins.
  • Added `source` support for async WASM modules.
  • Implement `deprecate` flag in schema for better TypeScript support to show which options are already deprecated by the configuration.
  • `import.meta` as standalone expression now returns a complete object with known properties (`url`, `webpack`, `main`, `env`) instead of an empty object `({})`, and hoists it as a module-level variable.

🐛 Bug Fixes

  • Add a static getSourceBasicTypes method to the Module class to prevent errors across multiple versions.
  • Included fragment groups in the conflicting order warning for CSS.
  • Avoid rendering unused top-level `__webpack_exports__` declaration when output ECMA module library.
  • Fixed resolving in CSS modules.
  • Allow external modules place in async chunks when output ECMA module.
  • Set `.name` to "default" for anonymous default export functions and classes per ES spec.
  • Hash entry chunks after runtime chunks to prevent stale content hash references in watch mode.
  • Fix multiple bugs and optimizations in CSS modules: correct third code point position in walkCssTokens number detection, fix multiline CSS comment regex, fix swapped :import/:export error message, fix comma callback incorrectly popping balanced stack, fix cache comparison missing array length check, fix match.index mutation side effect, move publicPathAutoRegex to module scope, precompute merged callbacks in consumeUntil, simplify redundant ternary in CssGenerator, fix typo GRID_TEMPLATE_ARES, remove duplicate grid-column-start, and merge duplicate getCompilationHooks calls.
  • Correct url() path resolution and preserve source maps for non-link CSS export types (style, text, css-style-sheet).
  • Emit error when proxy server returns non-200 status code in HttpUriPlugin instead of silently failing.
  • Fix incorrect condition in FileSystemInfo that always evaluated to false, preventing trailing slash removal from directory paths during build dependency resolution.
  • Fix virtualUrlPlugin absolute path virtual module IDs getting concatenated with compiler context (absolute-path contexts are now used directly).
  • Fix `CompatibilityPlugin` to correctly rename `__webpack_require__` when it appears as an arrow function parameter (e.g. `(__webpack_module, __webpack_exports, __webpack_require__) => { ... }`).

Affected Symbols