Skip to content

Commit

Permalink
docs(Configurations): explain default value of output.chunkFormat and…
Browse files Browse the repository at this point in the history
… output.chunkLoading is inferred from target (webpack#6321)

* explain default value of output.chunkFormat and output.chunkLoading is inferred from target

* Update output.mdx

* Update src/content/configuration/output.mdx

Co-authored-by: Sam Chen <[email protected]>

* Update src/content/configuration/output.mdx

Co-authored-by: Sam Chen <[email protected]>

* Update output.mdx

* Update src/content/configuration/output.mdx

Co-authored-by: Sam Chen <[email protected]>
  • Loading branch information
tanhauhau and chenxsan authored Aug 10, 2022
1 parent 94b1541 commit 7046bee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/content/configuration/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ module.exports = {

The format of chunks (formats included by default are `'array-push'` (web/WebWorker), `'commonjs'` (node.js), `'module'` (ESM), but others might be added by plugins).

T> The default value of this option depends on the [`target`](/configuration/target/) and [`output.module`](#outputmodule) setting. For more details, search for `"chunkFormat"` [in the webpack defaults](https://github.com/webpack/webpack/blob/main/lib/config/defaults.js).

**webpack.config.js**

```javascript
Expand Down Expand Up @@ -226,6 +228,8 @@ module.exports = {

The method to load chunks (methods included by default are `'jsonp'` (web), `'import'` (ESM), `'importScripts'` (WebWorker), `'require'` (sync node.js), `'async-node'` (async node.js), but others might be added by plugins).

T> The default value of this option depends on the [`target`](/configuration/target/) and [`chunkFormat `](#outputchunkformat) setting. For more details, search for `"chunkLoading"` [in the webpack defaults](https://github.com/webpack/webpack/blob/main/lib/config/defaults.js).

**webpack.config.js**

```javascript
Expand Down Expand Up @@ -353,7 +357,7 @@ module.exports = {
};
```

The following substitutions are available in template strings (via webpack's internal [`ModuleFilenameHelpers`](https://github.com/webpack/webpack/blob/master/lib/ModuleFilenameHelpers.js)):
The following substitutions are available in template strings (via webpack's internal [`ModuleFilenameHelpers`](https://github.com/webpack/webpack/blob/main/lib/ModuleFilenameHelpers.js)):

| Template | Description |
| ------------------------ | --------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -564,7 +568,7 @@ Note this option does not affect output files for on-demand-loaded chunks. It on

### Template strings

The following substitutions are available in template strings (via webpack's internal [`TemplatedPathPlugin`](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js)):
The following substitutions are available in template strings (via webpack's internal [`TemplatedPathPlugin`](https://github.com/webpack/webpack/blob/main/lib/TemplatedPathPlugin.js)):

Substitutions available on Compilation-level:

Expand Down Expand Up @@ -864,7 +868,7 @@ In the above example, we're passing a single entry file to `entry`, however, web
</script>
```

See [this example](https://github.com/webpack/webpack/tree/master/examples/multi-part-library) for more.
See [this example](https://github.com/webpack/webpack/tree/main/examples/multi-part-library) for more.

Note that the above configuration won't work as expected if you're going to configure library options per entry point. Here is how to do it [under each of your entries](/concepts/entry-points/#entrydescription-object):

Expand Down Expand Up @@ -2289,7 +2293,7 @@ module.exports = {

The new option `workerChunkLoading` controls the chunk loading of workers.

T> The default value of this option is depending on the `target` setting. For more details, search for `"workerChunkLoading"`: [in the webpack defaults](https://github.com/webpack/webpack/blob/master/lib/config/defaults.js).
T> The default value of this option depends on the [`target`](/configuration/target/) setting. For more details, search for `"workerChunkLoading"` [in the webpack defaults](https://github.com/webpack/webpack/blob/main/lib/config/defaults.js).

**webpack.config.js**

Expand Down

0 comments on commit 7046bee

Please sign in to comment.