Skip to content

Commit 7393225

Browse files
docs: v5.102.0 (#7661)
1 parent 688a9d6 commit 7393225

File tree

8 files changed

+168
-98
lines changed

8 files changed

+168
-98
lines changed

src/content/api/normalmodulefactory-hooks.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,4 @@ Possible default identifiers:
152152
5. `asset/source`
153153
6. `asset/resource`
154154
7. `asset/inline`
155+
8. `asset/bytes`

src/content/awesome-webpack.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ _People passionate about Webpack (In no particular order)_
9595
- [Worker Loader](https://github.com/webpack/worker-loader): Worker loader module for Webpack. -- _Maintainer_: `Webpack Team` [![Github][githubicon]](https://github.com/webpack)
9696
- [Resolve URL Loader](https://github.com/bholloway/resolve-url-loader): Resolves relative paths in url() statements. -- _Maintainer_: `Ben Holloway` [![Github][githubicon]](https://github.com/bholloway)
9797
- [Import Loader](https://github.com/webpack/imports-loader): Imports loader module for Webpack. -- _Maintainer_: `Webpack Team` [![Github][githubicon]](https://github.com/webpack)
98-
- [SourceMap Loader](https://github.com/webpack/source-map-loader): Extract sourceMappingURL comments from modules. -- _Maintainer_: `Webpack Team` [![Github][githubicon]](https://github.com/webpack)
9998
- [Combine Loader](https://www.npmjs.com/package/webpack-combine-loaders) - Converts a loaders array into a single loader string. -- _Maintainer_: `James Friend` [![Github][githubicon]](https://github.com/jsdf)
10099
- [Icon Font Loader](https://github.com/vusion/icon-font-loader) - Converts svgs into font icons in CSS. -- _Maintainer_: `Forrest R. Zhao` [![Github][githubicon]](https://github.com/rainfore)
101100
- [Icons Loader](https://www.npmjs.com/package/icons-loader) - Generates an iconfont from SVG dependencies. -- _Maintainer_: `Mike Vercoelen` [![Github][githubicon]](https://github.com/mikevercoelen)

src/content/configuration/devtool.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ related:
1818
---
1919

2020
This option controls if and how source maps are generated.
21-
22-
Use the [`SourceMapDevToolPlugin`](/plugins/source-map-dev-tool-plugin) for a more fine grained configuration. See the [`source-map-loader`](/loaders/source-map-loader) to deal with existing source maps.
21+
Use the [`SourceMapDevToolPlugin`](/plugins/source-map-dev-tool-plugin) for a more fine grained configuration. See the [`Rule.extractSourceMap`](/configuration/module/#ruleextractsourcemap) to deal with existing source maps.
2322

2423
## devtool
2524

src/content/configuration/experiments.mdx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Available options:
2727
- [`css`](#experimentscss)
2828
- [`deferImport`](#experimentsdeferimport)
2929
- [`futureDefaults`](#experimentsfuturedefaults)
30-
- `layers`: Enable module and chunk layers.
3130
- [`lazyCompilation`](#experimentslazycompilation)
3231
- [`outputModule`](#experimentsoutputmodule)
3332
- `syncWebAssembly`: Support the old WebAssembly like in webpack 4.
34-
- [`topLevelAwait`](#experimentstoplevelawait)
33+
- `layers`: Enable module and chunk layers, removed and works without additional options since `5.102.0`.
34+
- `topLevelAwait`: Transforms a module into an `async` module when an `await` is used at the top level. Starting from webpack version `5.83.0` (however, in versions prior to that, you can enable it by setting `experiments.topLevelAwait` to `true`), this feature is enabled by default, removed and works without additional options since `5.102.0`.
3535

3636
**webpack.config.js**
3737

@@ -41,7 +41,6 @@ module.exports = {
4141
experiments: {
4242
asyncWebAssembly: true,
4343
buildHttp: true,
44-
layers: true,
4544
lazyCompilation: true,
4645
outputModule: true,
4746
syncWebAssembly: true,
@@ -368,17 +367,3 @@ module.exports = {
368367
},
369368
};
370369
```
371-
372-
### experiments.topLevelAwait
373-
374-
`boolean = true`
375-
376-
The `topLevelAwait` option transforms a module into an `async` module when an `await` is used at the top level. Starting from webpack version `5.83.0`, this feature is enabled by default. However, in versions prior to that, you can enable it by setting `experiments.topLevelAwait` to `true`.
377-
378-
```js
379-
module.exports = {
380-
experiments: {
381-
topLevelAwait: true,
382-
},
383-
};
384-
```

src/content/configuration/module.mdx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ module.exports = {
141141
// type: string | ((pathData: PathData, assetInfo?: AssetInfo) => string)
142142
outputPath: 'cdn-assets/',
143143
},
144+
'asset/bytes': {
145+
// No generator options are supported for this module type yet
146+
}
144147
javascript: {
145148
// No generator options are supported for this module type yet
146149
},
@@ -249,6 +252,9 @@ module.exports = {
249252
'asset/source': {
250253
// ditto
251254
},
255+
'asset/bytes': {
256+
// ditto
257+
},
252258
javascript: {
253259
// Parser options for javascript modules
254260
// e.g, enable parsing of require.ensure syntax
@@ -1019,6 +1025,28 @@ module.exports = {
10191025
};
10201026
```
10211027

1028+
## Rule.extractSourceMap
1029+
1030+
`boolean = false`
1031+
1032+
Extracts existing source map data from files (from their `//# sourceMappingURL` comment), useful for preserving the source maps of third-party libraries.
1033+
1034+
**webpack.config.js**
1035+
1036+
```js
1037+
module.exports = {
1038+
// ...
1039+
module: {
1040+
rules: [
1041+
{
1042+
test: /\.m?js$/,
1043+
extractSourceMap: true,
1044+
},
1045+
],
1046+
},
1047+
};
1048+
```
1049+
10221050
## Rule.loader
10231051

10241052
`Rule.loader` is a shortcut to `Rule.use: [ { loader } ]`. See [`Rule.use`](#ruleuse) and [`UseEntry.loader`](#useentry) for details.
@@ -1280,11 +1308,11 @@ module.exports = {
12801308
module: {
12811309
rules: [
12821310
{
1283-
test: /\.png/,
1311+
test: /\.png$/,
12841312
type: 'asset/resource',
12851313
},
12861314
{
1287-
test: /\.html/,
1315+
test: /\.html$/,
12881316
type: 'asset/resource',
12891317
generator: {
12901318
filename: 'static/[hash][ext]',
@@ -1444,7 +1472,7 @@ Include all modules that pass test assertion. If you supply a `Rule.test` option
14441472

14451473
`string`
14461474

1447-
Possible values: `'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/sync' | 'webassembly/async' | 'asset' | 'asset/source' | 'asset/resource' | 'asset/inline' | 'css/auto'`
1475+
Possible values: `'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/sync' | 'webassembly/async' | 'asset' | 'asset/source' | 'asset/resource' | 'asset/inline' | 'asset/bytes' | 'css' | 'css/auto' | 'css/module' | 'css/global'`
14481476

14491477
`Rule.type` sets the type for a matching module. This prevents defaultRules and their default importing behaviors from occurring. For example, if you want to load a `.json` file through a custom loader, you'd need to set the `type` to `javascript/auto` to bypass webpack's built-in json importing.
14501478

src/content/configuration/other-options.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ module.exports = {
260260
module: {
261261
timestamp: true,
262262
},
263+
contextModule: {
264+
hash: true,
265+
timestamp: true,
266+
},
263267
resolve: {
264268
timestamp: true,
265269
},
@@ -337,6 +341,16 @@ Snapshots for building modules.
337341
- `hash`: Compare content hashes to determine invalidation (more expensive than `timestamp`, but changes less often).
338342
- `timestamp`: Compare timestamps to determine invalidation.
339343

344+
### contextModule
345+
346+
`object = {hash boolean = true, timestamp boolean = true}`
347+
348+
Snapshots for building context modules.
349+
350+
- `hash`: Compare content hashes to determine invalidation (more expensive than `timestamp`, but changes less often).
351+
- `timestamp`: Compare timestamps to determine invalidation.
352+
353+
340354
### resolve
341355

342356
`object = {hash boolean = true, timestamp boolean = true}`

0 commit comments

Comments
 (0)