Skip to content

Commit 2639fb9

Browse files
authored
docs: more about v5.103.0 (#7722)
1 parent e478a5c commit 2639fb9

File tree

7 files changed

+165
-19
lines changed

7 files changed

+165
-19
lines changed

src/content/configuration/dotenv.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ related:
1212

1313
<Badge text="5.103.0+" />
1414
The `dotenv` option enables webpack's built-in environment variable loading from
15-
`.env` files. ## `dotenv`
15+
`.env` files.
1616

1717
`boolean` `object`
1818

src/content/configuration/experiments.mdx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ module.exports = {
6969
When enabled, webpack can build remote resources that begin with the `http(s):` protocol.
7070

7171
- Type:
72-
7372
- `(string | RegExp | ((uri: string) => boolean))[]`
7473

7574
A shortcut for [`experiments.buildHttp.allowedUris`](#experimentsbuildhttpalloweduris).
@@ -223,9 +222,12 @@ Enables the following syntaxes:
223222

224223
```js
225224
import defer * as module from 'module-name';
226-
// or
227225
import * as module2 from /* webpackDefer: true */ 'module-name2';
228226

227+
// Or using dynamic import
228+
import.defer('module-name3');
229+
import(/* webpackDefer: true */ 'module-name4');
230+
229231
export function f() {
230232
// module-name is evaluated synchronously, then call doSomething() on it.
231233
module.doSomething();
@@ -251,12 +253,7 @@ Esbuild is _not_ compatible with this feature (see [evanw/esbuild#1439](https://
251253

252254
#### Not implemented
253255

254-
The asynchronous form of this proposal is not implemented yet.
255-
256-
```js
257-
import.defer('module-name'); // not implemented
258-
import(/* webpackDefer: true */ 'module-name'); // not implemented
259-
```
256+
import.defer() is not yet supported for ContextModule (the import path is a dynamic expression).
260257

261258
### experiments.futureDefaults
262259

@@ -278,7 +275,6 @@ module.exports = {
278275
Compile entrypoints and dynamic `import`s only when they are in use. It can be used for either Web or Node.js.
279276

280277
- Type
281-
282278
- `boolean`
283279
- `object`
284280

src/content/configuration/module.mdx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,50 @@ The `'relative'` value for `module.parser.javascript.url` is available since web
748748
1. This is useful for SSR (Server side rendering) when base URL is not known by server (and it saves a few bytes). To be identical it must also be used for the client build.
749749
2. Also for static site generators, mini-css-plugin and html-plugin, etc. where server side rendering is commonly needed.
750750

751+
#### module.parser.javascript.parse
752+
753+
<Badge text="5.103.0+" />
754+
755+
Use a custom JavaScript parse function instead of webpack's built-in parser.
756+
757+
Return `ast`, `comments`, and `semicolons` to ensure webpack’s AST analysis works correctly.
758+
759+
- `ast` should be ESTree-compatible.
760+
- `comments` is an array of ESTree comment nodes.
761+
- `semicolons` is a set of positions where the parser inserted a semicolon.
762+
763+
- Type: `(code: string, options: ParseOptions) => ParseResult`
764+
- Example:
765+
766+
```js
767+
module.exports = {
768+
module: {
769+
parser: {
770+
javascript: {
771+
parse: (code, options) => {
772+
const comments = [];
773+
const semicolons = new Set();
774+
const onInsertedSemicolon = (pos) => semicolons.add(pos);
775+
776+
const parseOptions = {
777+
...options,
778+
module: options.sourceType === 'module',
779+
loc: options.locations,
780+
onComment: options.comments ? comments : undefined,
781+
onInsertedSemicolon: options.semicolons
782+
? onInsertedSemicolon
783+
: undefined,
784+
};
785+
786+
const ast = meriyah.parse(code, parseOptions);
787+
return { ast, comments, semicolons };
788+
},
789+
},
790+
},
791+
},
792+
};
793+
```
794+
751795
### module.parser.json
752796

753797
Configure options for json parser.

src/content/guides/output-management.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Now run an `npm run build` and inspect the `/dist` folder. If everything went we
216216

217217
You might be wondering how webpack and its plugins seem to "know" what files are being generated. The answer is in the manifest that webpack keeps to track how all the modules map to the output bundles. If you're interested in managing webpack's [`output`](/configuration/output) in other ways, the manifest would be a good place to start.
218218

219-
The manifest data can be extracted into a json file for consumption using the [`WebpackManifestPlugin`](https://github.com/shellscape/webpack-manifest-plugin).
219+
The manifest data can be extracted into a json file for consumption using the [`ManifestPlugin`](/plugins/manifest-plugin/).
220220

221221
We won't go through a full example of how to use this plugin within your projects, but you can read up on [the concept page](/concepts/manifest) and the [caching guide](/guides/caching) to find out how this ties into long term caching.
222222

src/content/plugins/eval-source-map-dev-tool-plugin.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ new webpack.EvalSourceMapDevToolPlugin(options);
2626

2727
The following options are supported:
2828

29-
- `test` (`string|RegExp|array`): Include source maps for modules based on their extension (defaults to `.js` and `.css`).
30-
- `include` (`string|RegExp|array`): Include source maps for module paths that match the given value.
31-
- `exclude` (`string|RegExp|array`): Exclude modules that match the given value from source map generation.
29+
- `test` (`string` `RegExp` `function (asset) => boolean` `[string, RegExp, function (asset) => boolean]`): Include source maps for modules based on their extension (defaults to `.js` and `.css`).
30+
- `include` (`string` `RegExp` `function (asset) => boolean` `[string, RegExp, function (asset) => boolean]`): Include source maps for module paths that match the given value.
31+
- `exclude` (`string` `RegExp` `function (asset) => boolean` `[string, RegExp, function (asset) => boolean]`): Exclude modules that match the given value from source map generation.
3232
- `append` (`string|function`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file.
3333

3434
Starting from version 5.84.0, webpack allows the `append` option to be a function that accepts path data and an asset info object as arguments, and returns a string.
@@ -37,7 +37,7 @@ The following options are supported:
3737
(pathData: PathData, assetInfo?: AssetInfo) => string;
3838
```
3939

40-
- `ignoreList` (`string|RegExp|array`): Decide whether to ignore source files that match the specified value in source maps.
40+
- `ignoreList` (`string` `RegExp` `function (source) => boolean` `[string, RegExp, function (source) => boolean]`): Decide whether to ignore source files that match the specified value in source maps.
4141
- `module` (`boolean`): Indicates whether loaders should generate source maps (defaults to `true`).
4242
- `moduleFilenameTemplate` (`string`): See [`output.devtoolModuleFilenameTemplate`](/configuration/output/#outputdevtoolmodulefilenametemplate).
4343
- `columns` (`boolean`): Indicates whether column mappings should be used (defaults to `true`).
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: ManifestPlugin
3+
group: webpack
4+
contributors:
5+
- hai-x
6+
- alexander-akait
7+
---
8+
9+
<Badge text="5.103.0+" />
10+
11+
The built-in `ManifestPlugin` generates one asset manifest for your build. Port from [`WebpackManifestPlugin`](https://github.com/shellscape/webpack-manifest-plugin).
12+
13+
**webpack.config.js**
14+
15+
```javascript
16+
new webpack.ManifestPlugin({
17+
// options...
18+
});
19+
```
20+
21+
## Options
22+
23+
### `entrypoints`
24+
25+
`boolean = true`
26+
27+
Enables generation of the `entrypoints` section in the manifest.
28+
29+
When `entrypoints` is enabled and one entry uses `dependOn`
30+
31+
**webpack.config.js**
32+
33+
```javascript
34+
module.exports = {
35+
entry: {
36+
entry1: {
37+
import: './src/file_1.js',
38+
dependOn: 'entry2',
39+
},
40+
entry2: './src/file_2.js',
41+
},
42+
plugins: [
43+
new webpack.ManifestPlugin({
44+
filename: 'manifest.json',
45+
}),
46+
],
47+
};
48+
```
49+
50+
The resulting manifest will contain the parent/child relationship map
51+
52+
**manifest.json**
53+
54+
```json
55+
{
56+
"entrypoints": {
57+
"entry1": {
58+
"imports": ["entry1.js"],
59+
"parents": ["entry2"]
60+
},
61+
"entry2": {
62+
"imports": ["entry2.js"]
63+
}
64+
}
65+
}
66+
```
67+
68+
### `filename`
69+
70+
`string = manifest.json`
71+
72+
Specifies the filename of the output file on disk. By default the plugin will emit `manifest.json` inside the `output.path` directory.
73+
74+
### `filter`
75+
76+
`(item: ManifestItem) => boolean`
77+
78+
Allows filtering the files which make up the manifest.
79+
80+
### `generate`
81+
82+
`function (manifest: ManifestObject) => ManifestObject`
83+
84+
Receives the manifest object, modifies it, and returns the modified manifest.
85+
86+
### `prefix`
87+
88+
`string = "[publicpath]"`
89+
90+
Specifies a path prefix for all keys in the manifest.
91+
92+
### serialize
93+
94+
`function (manifest: ManifestObject) => string = (manifest) => JSON.stringify(manifest, null, 2)`
95+
96+
Receives the manifest object and returns the manifest string.
97+
98+
Use `serialize` to output other formats, for example YAML:
99+
100+
```javascript
101+
new webpack.ManifestPlugin({
102+
serialize(manifest) {
103+
return YAML.stringify(manifest, 4);
104+
},
105+
});
106+
```

src/content/plugins/source-map-dev-tool-plugin.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ new webpack.SourceMapDevToolPlugin(options);
2424

2525
The following options are supported:
2626

27-
- `test` (`string` `RegExp` `[string, RegExp]`): Include source maps for modules based on their extension (defaults to `.js`, `.mjs`, and `.css`).
28-
- `include` (`string` `RegExp` `[string, RegExp]`): Include source maps for module paths that match the given value.
29-
- `exclude` (`string` `RegExp` `[string, RegExp]`): Exclude modules that match the given value from source map generation.
27+
- `test` (`string` `RegExp` `function (asset) => boolean` `[string, RegExp, function (asset) => boolean]`): Include source maps for modules based on their extension (defaults to `.js`, `.mjs`, and `.css`).
28+
- `include` (`string` `RegExp` `function (asset) => boolean` `[string, RegExp, function (asset) => boolean]`): Include source maps for module paths that match the given value.
29+
- `exclude` (`string` `RegExp` `function (asset) => boolean` `[string, RegExp], function (asset) => boolean`): Exclude modules that match the given value from source map generation.
3030
- `filename` (`string`): Defines the output filename of the SourceMap (will be inlined if no value is provided).
3131
- `append` (`string` `function` `false`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. Since webpack v4.36.0, path parameters are supported: `[chunk]`, `[filename]` and `[contenthash]`. Setting `append` to `false` disables the appending.
3232

@@ -38,7 +38,7 @@ The following options are supported:
3838

3939
- `moduleFilenameTemplate` (`string`): See [`output.devtoolModuleFilenameTemplate`](/configuration/output/#outputdevtoolmodulefilenametemplate).
4040
- `fallbackModuleFilenameTemplate` (`string`): See link above.
41-
- `ignoreList` (`string|RegExp|array`): Decide whether to ignore source files that match the specified value in source maps.
41+
- `ignoreList` (`string` `RegExp` `function (source) => boolean` `[string, RegExp, function (source) => boolean]`): Decide whether to ignore source files that match the specified value in source maps.
4242
- `module = true` (`boolean`): Indicates whether loaders should generate source maps.
4343
- `columns = true` (`boolean`): Indicates whether column mappings should be used.
4444
- `namespace` (`string`): Namespace prefix to allow multiple webpack roots in the devtools. See [`output.devtoolNamespace`](/configuration/output/#outputdevtoolnamespace).

0 commit comments

Comments
 (0)