Skip to content

Commit 570c5ce

Browse files
authored
docs(configuration): sort output options alphabetically (#5292)
* docs(configuration): fix heading level * docs(configuration): move output.futureEmitAssets * docs(configuration): move output.uniqueName * docs(configuration): move output.importFunctionName * docs(configuration): move output.iife * docs(configuration): move output.module * docs(configuration): move output.workerChunkLoading
1 parent 3582696 commit 570c5ce

File tree

1 file changed

+75
-75
lines changed

1 file changed

+75
-75
lines changed

src/content/configuration/output.mdx

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ module.exports = {
443443
};
444444
```
445445

446-
## `output.filename`
446+
## output.filename
447447

448448
`string` `function (pathData, assetInfo) => string`
449449

@@ -537,7 +537,7 @@ Note this option is called filename but you are still allowed to use something l
537537

538538
Note this option does not affect output files for on-demand-loaded chunks. It only affects output files that are initially loaded. For on-demand-loaded chunk files the [`output.chunkFilename`](#outputchunkfilename) option is used. Files created by loaders also aren't affected. In this case you would have to try the specific loader's available options.
539539

540-
## Template strings
540+
### Template strings
541541

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

@@ -629,45 +629,41 @@ type ModulePathData = {
629629

630630
T> In some context properties will use JavaScript code expressions instead of raw values. In these cases the `WithLength` variant is available and should be used instead of slicing the original value.
631631

632-
## `output.globalObject`
633-
634-
`string = 'window'`
632+
## output.futureEmitAssets
635633

636-
When targeting a library, especially when `libraryTarget` is `'umd'`, this option indicates what global object will be used to mount the library. To make UMD build available on both browsers and Node.js, set `output.globalObject` option to `'this'`. Defaults to `self` for Web-like targets.
634+
`boolean = false`
637635

638-
For example:
636+
Tells webpack to use the future version of asset emitting logic, which allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after they were emitted.
639637

640-
**webpack.config.js**
638+
W> `output.futureEmitAssets` option will be removed in webpack v5.0.0 and this behaviour will become the new default.
641639

642640
```javascript
643641
module.exports = {
644-
// ...
642+
//...
645643
output: {
646-
library: 'myLib',
647-
libraryTarget: 'umd',
648-
filename: 'myLib.js',
649-
globalObject: 'this',
644+
futureEmitAssets: true,
650645
},
651646
};
652647
```
653648

654-
## `output.uniqueName`
655-
656-
`string`
649+
## `output.globalObject`
657650

658-
A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to [`output.library`](/configuration/output/#outputlibrary) name or the package name from `package.json` in the context, if both aren't found, it is set to an `''`.
651+
`string = 'window'`
659652

660-
`output.uniqueName` will be used to generate unique globals for:
653+
When targeting a library, especially when `libraryTarget` is `'umd'`, this option indicates what global object will be used to mount the library. To make UMD build available on both browsers and Node.js, set `output.globalObject` option to `'this'`. Defaults to `self` for Web-like targets.
661654

662-
- [`output.chunkLoadingGlobal`](/configuration/output/#outputchunkloadingglobal)
655+
For example:
663656

664657
**webpack.config.js**
665658

666659
```javascript
667660
module.exports = {
668661
// ...
669662
output: {
670-
uniqueName: 'my-package-xyz',
663+
library: 'myLib',
664+
libraryTarget: 'umd',
665+
filename: 'myLib.js',
666+
globalObject: 'this',
671667
},
672668
};
673669
```
@@ -744,6 +740,38 @@ Customize the main hot update filename. `[fullhash]` and `[runtime]` are availab
744740

745741
T> Typically you don't need to change `output.hotUpdateMainFilename`.
746742

743+
## output.iife
744+
745+
`boolean = true`
746+
747+
Tells webpack to add [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) wrapper around emitted code.
748+
749+
```javascript
750+
module.exports = {
751+
//...
752+
output: {
753+
iife: true,
754+
},
755+
};
756+
```
757+
758+
## output.importFunctionName
759+
760+
`string = 'import'`
761+
762+
The name of the native `import()` function. Can be used for polyfilling, e.g. with [`dynamic-import-polyfill`](https://github.com/GoogleChromeLabs/dynamic-import-polyfill).
763+
764+
**webpack.config.js**
765+
766+
```javascript
767+
module.exports = {
768+
//...
769+
output: {
770+
importFunctionName: '__import__',
771+
},
772+
};
773+
```
774+
747775
## output.library
748776

749777
Output a library exposing the exports of your entry point.
@@ -1849,23 +1877,30 @@ MyLibrary(_entry_return_);
18491877

18501878
The dependencies for your library will be defined by the [`externals`](/configuration/externals/) config.
18511879

1852-
## `output.importFunctionName`
1880+
## output.module
18531881

1854-
`string = 'import'`
1882+
`boolean = false`
18551883

1856-
The name of the native `import()` function. Can be used for polyfilling, e.g. with [`dynamic-import-polyfill`](https://github.com/GoogleChromeLabs/dynamic-import-polyfill).
1884+
Output JavaScript files as module type. Disabled by default as it's an experimental feature.
18571885

1858-
**webpack.config.js**
1886+
When enabled, webpack will set [`output.iife`](#outputiife) to `false`, [`output.scriptType`](#outputscripttype) to `'module'` and `terserOptions.module` to `true` internally.
1887+
1888+
If you're using webpack to compile a library to be consumed by others, make sure to set [`output.libraryTarget`](#librarytarget-module) to `'module'` when `output.module` is `true`.
18591889

18601890
```javascript
18611891
module.exports = {
18621892
//...
1893+
experiments: {
1894+
outputModule: true,
1895+
},
18631896
output: {
1864-
importFunctionName: '__import__',
1897+
module: true,
18651898
},
18661899
};
18671900
```
18681901

1902+
W> `output.module` is an experimental feature and can only be enabled by setting [`experiments.outputModule`](/configuration/experiments/#experiments) to `true`.
1903+
18691904
## `output.path`
18701905

18711906
`string = path.join(process.cwd(), 'dist')`
@@ -2141,43 +2176,28 @@ module.exports = {
21412176
};
21422177
```
21432178

2144-
## `output.workerChunkLoading`
2145-
2146-
`string: 'require' | 'import-scripts' | 'async-node' | 'import' | 'universal'` `boolean: false`
2147-
2148-
The new option `workerChunkLoading` controls the chunk loading of workers.
2149-
2150-
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).
2151-
2152-
**webpack.config.js**
2179+
## output.uniqueName
21532180

2154-
```javascript
2155-
module.exports = {
2156-
//...
2157-
output: {
2158-
workerChunkLoading: false,
2159-
},
2160-
};
2161-
```
2181+
`string`
21622182

2163-
## `output.futureEmitAssets`
2183+
A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to [`output.library`](/configuration/output/#outputlibrary) name or the package name from `package.json` in the context, if both aren't found, it is set to an `''`.
21642184

2165-
`boolean = false`
2185+
`output.uniqueName` will be used to generate unique globals for:
21662186

2167-
Tells webpack to use the future version of asset emitting logic, which allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after they were emitted.
2187+
- [`output.chunkLoadingGlobal`](/configuration/output/#outputchunkloadingglobal)
21682188

2169-
W> `output.futureEmitAssets` option will be removed in webpack v5.0.0 and this behaviour will become the new default.
2189+
**webpack.config.js**
21702190

21712191
```javascript
21722192
module.exports = {
2173-
//...
2193+
// ...
21742194
output: {
2175-
futureEmitAssets: true,
2195+
uniqueName: 'my-package-xyz',
21762196
},
21772197
};
21782198
```
21792199

2180-
## `output.wasmLoading`
2200+
## output.wasmLoading
21812201

21822202
`boolean = false` `string`
21832203

@@ -2197,41 +2217,21 @@ module.exports = {
21972217
};
21982218
```
21992219

2200-
## `output.iife`
2201-
2202-
`boolean = true`
2203-
2204-
Tells webpack to add [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) wrapper around emitted code.
2205-
2206-
```javascript
2207-
module.exports = {
2208-
//...
2209-
output: {
2210-
iife: true,
2211-
},
2212-
};
2213-
```
2220+
## output.workerChunkLoading
22142221

2215-
## `output.module`
2216-
2217-
`boolean = false`
2222+
`string: 'require' | 'import-scripts' | 'async-node' | 'import' | 'universal'` `boolean: false`
22182223

2219-
Output JavaScript files as module type. Disabled by default as it's an experimental feature.
2224+
The new option `workerChunkLoading` controls the chunk loading of workers.
22202225

2221-
When enabled, webpack will set [`output.iife`](#outputiife) to `false`, [`output.scriptType`](#outputscripttype) to `'module'` and `terserOptions.module` to `true` internally.
2226+
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).
22222227

2223-
If you're using webpack to compile a library to be consumed by others, make sure to set [`output.libraryTarget`](#librarytarget-module) to `'module'` when `output.module` is `true`.
2228+
**webpack.config.js**
22242229

22252230
```javascript
22262231
module.exports = {
22272232
//...
2228-
experiments: {
2229-
outputModule: true,
2230-
},
22312233
output: {
2232-
module: true,
2234+
workerChunkLoading: false,
22332235
},
22342236
};
22352237
```
2236-
2237-
W> `output.module` is an experimental feature and can only be enabled by setting [`experiments.outputModule`](/configuration/experiments/#experiments) to `true`.

0 commit comments

Comments
 (0)