You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/blog/posts/2026-04-08-webpack-5-106.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,8 @@ module.exports = {
99
99
};
100
100
```
101
101
102
-
W> CSS support has matured significantly and is expected to be fully finalized in the next minor release, as planned in the roadmap. As part of this transition, `css-loader`, `style-loader`, and `mini-css-extract-plugin` are planned for deprecation.
102
+
> [!WARNING]
103
+
> CSS support has matured significantly and is expected to be fully finalized in the next minor release, as planned in the roadmap. As part of this transition, `css-loader`, `style-loader`, and `mini-css-extract-plugin` are planned for deprecation.
Copy file name to clipboardExpand all lines: pages/blog/posts/2026-05-19-webpack-5-107.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,8 @@ Explore what's new:
42
42
43
43
## HTML Modules (Experimental)
44
44
45
-
W> **This feature is experimental and partial.** Webpack 5.107 only implements the `html-loader` side of the story: importing an HTML file from JavaScript runs its tag references through the webpack pipeline. **HTML entry points** (using a `.html` file directly as `entry`, the `html-webpack-plugin` part) are **not supported yet** and are planned for the next minor release. The full story is tracked in issue [#536](https://github.com/webpack/webpack/issues/536).
45
+
> [!WARNING]
46
+
> **This feature is experimental and partial.** Webpack 5.107 only implements the `html-loader` side of the story: importing an HTML file from JavaScript runs its tag references through the webpack pipeline. **HTML entry points** (using a `.html` file directly as `entry`, the `html-webpack-plugin` part) are **not supported yet** and are planned for the next minor release. The full story is tracked in issue [#536](https://github.com/webpack/webpack/issues/536).
46
47
47
48
A real-world webpack setup that needs an HTML entry point has historically required at least two extra dependencies. The first is `html-webpack-plugin`, which generates or emits the HTML file and injects the right bundle URLs into it. The second is `html-loader`, which lets webpack walk through `<img src>`, `<link href>`, `<script src>`, and friends so those references go through the normal resolver and asset pipeline.
48
49
@@ -165,7 +166,8 @@ The comment value is parsed with the same context the JS and CSS parsers use, so
165
166
166
167
## TypeScript Support (Experimental)
167
168
168
-
W> **This feature is experimental and depends on a recent Node.js.** It requires Node.js 22.6 or later for the stable `module.stripTypeScriptTypes` API. The transform handles only erasable TypeScript syntax (see limitations below). For anything else, keep using `ts-loader` or `swc-loader`.
169
+
> [!WARNING]
170
+
> **This feature is experimental and depends on a recent Node.js.** It requires Node.js 22.6 or later for the stable `module.stripTypeScriptTypes` API. The transform handles only erasable TypeScript syntax (see limitations below). For anything else, keep using `ts-loader` or `swc-loader`.
169
171
170
172
Webpack 5.107 adds first-class TypeScript support behind a new `experiments.typescript` flag. With it enabled, webpack compiles `.ts`, `.cts`, and `.mts` files directly through Node.js's built-in [`module.stripTypeScriptTypes`](https://nodejs.org/api/module.html#modulestriptypescripttypescode-options), no external loader required. The flag is also turned on automatically by [`experiments.futureDefaults`](/configuration/experiments/#experimentsfuturedefaults).
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ You can learn more about including loaders in the [loaders section](/guides/gett
118
118
While loaders transform certain types of modules, plugins can perform a much wider range of tasks, such as bundle optimization, asset management, and injecting environment variables.
119
119
120
120
> [!TIP]
121
-
> Check out the [plugin interface](#TODO[/api/plugins]) and how to use it to extend webpack's capabilities.
121
+
> Check out the [plugin interface](/docs/api/plugins/types#interface-webpackplugininstance) and how to use it to extend webpack's capabilities.
122
122
123
123
To use a plugin, you `import` it and add it to the `plugins` array. Most plugins are customizable through options. Since you can use a plugin multiple times in a configuration for different purposes, you create an instance of it by calling it with the `new` operator.
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/modules.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Beyond these, webpack supports modules written in many other languages and prepr
42
42
43
43
And many more. In short, webpack offers a powerful, rich API for customization that lets you use it with **any stack** while remaining **non-opinionated** about your development, testing, and production workflows.
44
44
45
-
For a complete list, see [the list of loaders](/docs/loaders) or learn how to [write your own](#TODO[/api/loaders]).
45
+
For a complete list, see [the list of loaders](/docs/loaders) or learn how to [write your own](/docs/api/loaders/types).
Copy file name to clipboardExpand all lines: pages/guides/getting-started/concepts/under-the-hood.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ A non-initial chunk for `./app.jsx` is created because that module is imported d
90
90
-`/dist/main.js` — an `initial` chunk
91
91
-`/dist/394.js` — a `non-initial` chunk
92
92
93
-
By default, `non-initial` chunks have no name, so a unique ID is used instead. When using a dynamic import, you can specify a chunk name explicitly with a ["magic" comment](#TODO[/api/module-methods/#magic-comments]):
93
+
By default, `non-initial` chunks have no name, so a unique ID is used instead. When using a dynamic import, you can specify a chunk name explicitly with a ["magic" comment](/guides/optimization/code-splitting/#magic-comments):
Copy file name to clipboardExpand all lines: pages/guides/getting-started/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -390,4 +390,4 @@ webpack-demo
390
390
> [!WARNING]
391
391
> Do not compile untrusted code with webpack. It could lead to execution of malicious code on your computer, on remote servers, or in the web browsers of your application's end users.
392
392
393
-
If you want to learn more about webpack's design, you can check out the [basic concepts](/guides/getting-started/concepts) and [configuration](#TODO[/configuration]) pages. Furthermore, the [API](#TODO[/api]) section digs into the various interfaces webpack offers.
393
+
If you want to learn more about webpack's design, you can check out the [basic concepts](/guides/getting-started/concepts) and [configuration](#TODO[/configuration]) pages. Furthermore, the [API](/docs/api/types) section digs into the various interfaces webpack offers.
The ES2015 loader spec defines [`import()`](#TODO[/api/module-methods/#import-1]) as the way to load ES2015 modules dynamically at runtime. webpack treats `import()` as a split point and places the requested module in a separate chunk. `import()` takes the module name as its argument and returns a Promise.
432
+
The ES2015 loader spec defines [`import()`](/guides/optimization/code-splitting/#dynamic-imports) as the way to load ES2015 modules dynamically at runtime. webpack treats `import()` as a split point and places the requested module in a separate chunk. `import()` takes the module name as its argument and returns a Promise.
Copy file name to clipboardExpand all lines: pages/guides/optimization/code-splitting/index.md
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -328,7 +328,7 @@ webpack 5.x.x compiled successfully in 268 ms
328
328
> );
329
329
>```
330
330
>
331
-
> This helps webpack tree shake the other unused exports. See [Magic Comments](#TODO[/api/module-methods/#magic-comments]) for details.
331
+
> This helps webpack tree shake the other unused exports. See [Magic Comments](#magic-comments) for details.
332
332
333
333
Because `import()` returns a promise, it can be used with [`async` functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function). Here's how that simplifies the code:
334
334
@@ -357,7 +357,7 @@ Because `import()` returns a promise, it can be used with [`async` functions](ht
357
357
```
358
358
359
359
> [!TIP]
360
-
> You can also provide a [dynamic expression](#TODO[/api/module-methods/#dynamic-expressions-in-import]) to `import()` when you need to import a specific module based on a value computed later.
360
+
> You can also provide a [dynamic expression](/guides/modules-and-dependencies/dependency-management/#dynamic-expressions-in-import-or-require) to `import()` when you need to import a specific module based on a value computed later.
361
361
362
362
### Understanding ChunkLoadError
363
363
@@ -373,6 +373,42 @@ If you encounter this error:
373
373
374
374
For more context, see the related discussion in the webpack issue tracker.
375
375
376
+
## Magic Comments
377
+
378
+
webpack lets you attach inline comments to a dynamic `import()` to control how the resulting chunk is named, split, and loaded. These "magic comments" go inside the `import()` call, immediately before the module request:
- **`webpackChunkName`** - a string that names the generated chunk, so it appears as, for example, `my-chunk.js` instead of a numeric id. Imports that share the same name are bundled into the same chunk.
397
+
- **`webpackMode`** - controls how the module is resolved and split. One of:
398
+
- `"lazy"` (default) - generates a separate lazy-loadable chunk for the module.
399
+
- `"lazy-once"` - generates a single lazy-loadable chunk shared by every module matched by a [dynamic expression](/guides/modules-and-dependencies/dependency-management/#dynamic-expressions-in-import-or-require).
400
+
- `"eager"` - no separate chunk is generated; the module is bundled into the current chunk and no extra network request is made. `import()` still returns a `Promise`, but it resolves immediately.
401
+
- `"weak"` - the module is used only if it has already been loaded some other way; otherwise the returned `Promise` rejects.
402
+
- **`webpackPrefetch`** - `true` or a number. Marks the chunk as a prefetch resource. See [Prefetching/Preloading modules](#prefetchingpreloading-modules) below.
403
+
- **`webpackPreload`** - `true` or a number. Marks the chunk as a preload resource. See [Prefetching/Preloading modules](#prefetchingpreloading-modules) below.
404
+
- **`webpackFetchPriority`** - `"high"`, `"low"`, or `"auto"`. Sets the fetch priority hint used when loading the chunk.
405
+
- **`webpackExports`** - a string or an array of strings. Tells webpack to only bundle the named exports of the imported module, which helps it tree shake the rest.
406
+
- **`webpackInclude`** / **`webpackExclude`** - a regular expression that limits which modules are bundled when you pass a [dynamic expression](/guides/modules-and-dependencies/dependency-management/#dynamic-expressions-in-import-or-require) to `import()`. `webpackInclude` bundles only matching modules; `webpackExclude` skips matching ones.
407
+
- **`webpackIgnore`** - set to `true` to disable webpack's processing for this `import()`. webpack leaves the statement untouched, so it stays a native dynamic import at runtime and is never bundled or split.
408
+
409
+
> [!NOTE]
410
+
> `require.context` and `import.meta.webpackContext` accept a similar set of options (such as `mode`), but as properties of an options object rather than as inline comments. See [Dependency Management](/guides/modules-and-dependencies/dependency-management) for details.
411
+
376
412
## Prefetching/Preloading modules
377
413
378
414
webpack 4.6.0+ adds support for prefetching and preloading.
0 commit comments