diff --git a/src/content/blog/2026-06-18-webpack-5-108.mdx b/src/content/blog/2026-06-18-webpack-5-108.mdx new file mode 100644 index 000000000000..7ee6bf450f70 --- /dev/null +++ b/src/content/blog/2026-06-18-webpack-5-108.mdx @@ -0,0 +1,329 @@ +--- +title: Webpack 5.108 +sort: 20260618 +contributors: + - bjohansebas +--- + +Webpack 5.108 is out, and it pushes two big stories forward. The first continues the native HTML work that started in 5.107: a `.html` file can now be used directly as an `entry`, so webpack covers more of the role `html-webpack-plugin` has played for years, and HTML modules now support Hot Module Replacement. The second is a brand new `universal` target that compiles a single bundle that adapts at runtime to the browser, web workers, Node.js, Electron, and NW.js. + +Around those headlines, this release lands a substantial round of tree-shaking improvements (a new `optimization.inlineExports`, cross-module purity, and CommonJS re-export analysis), modernizes the code webpack generates for capable targets, and adds a typed `defineConfig` helper. + +Both the HTML and `universal` features are experimental and live behind opt-in flags, but the direction stays the same as 5.107: you should eventually be able to build a complete web app with zero extra loaders or plugins for HTML, CSS, and TypeScript. + +Explore what's new: + +- [**HTML Modules: Entry Points and HMR**](#html-modules-entry-points-and-hmr) + - [HTML as an Entry Point](#html-as-an-entry-point) + - [Hot Module Replacement](#hot-module-replacement) + - [Customizing the HTML Parser](#customizing-the-html-parser) +- [**CSS Improvements**](#css-improvements) + - [`url()` Inside HTML `style` Attributes](#url-inside-html-style-attributes) + - [CSS in Node for Universal Builds](#css-in-node-for-universal-builds) +- [**The `universal` Target**](#the-universal-target) +- [**Tree Shaking**](#tree-shaking) + - [`optimization.inlineExports`](#optimizationinlineexports) + - [Cross-Module Dead-Branch Skipping](#cross-module-dead-branch-skipping) + - [Cross-Module Purity](#cross-module-purity) + - [CommonJS Re-exports via `Object.defineProperty`](#commonjs-re-exports-via-objectdefineproperty) +- [**Output and Runtime**](#output-and-runtime) + - [Modern Syntax in Generated Code](#modern-syntax-in-generated-code) + - [`output.strictModuleResolution`](#outputstrictmoduleresolution) + - [`[uniqueName]` Template Placeholder](#uniquename-template-placeholder) + - [Worker Chunk Filenames](#worker-chunk-filenames) +- [**Typed Configuration with `defineConfig`**](#typed-configuration-with-defineconfig) +- [**Bug Fixes**](#bug-fixes) + +## HTML Modules: Entry Points and HMR + +W> **This feature is experimental and partial.** Webpack 5.107 implemented the `html-loader` side of the story: importing an HTML file from JavaScript runs its tag references through the webpack pipeline. Webpack 5.108 adds the ability to use a `.html` file as an `entry`. Full parity with `html-webpack-plugin` is still in progress; the overall effort is tracked in issue [#536](https://github.com/webpack/webpack/issues/536). + +### HTML as an Entry Point + +With [`experiments.html`](/configuration/experiments/#experimentshtml) enabled, you can now point `entry` directly at an HTML file. Its `