Skip to content

Commit 1c487be

Browse files
fi3eworkchenxsansnitin315
authored
docs(optimization): add optimization.avoidEntryIife (#7402)
Co-authored-by: Sam Chen <chenxsan@gmail.com> Co-authored-by: Nitin Kumar <snitin315@gmail.com>
1 parent b9bc5ab commit 1c487be

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/content/configuration/optimization.mdx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,31 @@ module.exports = {
124124

125125
W> If you are using webpack [CLI](/api/cli/), the webpack process will not exit with an error code while this plugin is enabled. If you want webpack to "fail" when using the CLI, please check out the [`bail` option](/api/cli/#advanced-options).
126126

127+
## optimization.avoidEntryIife
128+
129+
`boolean = false`
130+
131+
<Badge text="5.95.0+" />
132+
133+
Use `optimization.avoidEntryIife` to avoid wrapping the entry module in an IIFE when it is required (search for `"This entry needs to be wrapped in an IIFE because"` in [JavascriptModulesPlugin](https://github.com/webpack/webpack/blob/main/lib/javascript/JavascriptModulesPlugin.js)). This approach helps optimize performance for JavaScript engines and enables tree shaking when building ESM libraries.
134+
135+
Currently, `optimization.avoidEntryIife` can only optimize a single entry module along with other modules.
136+
137+
By default, `optimization.avoidEntryIife` is enabled in `production` [mode](/configuration/mode/) and disabled otherwise.
138+
139+
**webpack.config.js**
140+
141+
```js
142+
module.exports = {
143+
//...
144+
optimization: {
145+
avoidEntryIife: true,
146+
},
147+
};
148+
```
149+
150+
W> The `⁠optimization.avoidEntryIife` option can negatively affect build performance, if you prioritize build performance over these optimizations, consider disabling this option.
151+
127152
## optimization.flagIncludedChunks
128153

129154
`boolean`
@@ -425,7 +450,7 @@ module.exports = {
425450

426451
`boolean`
427452

428-
Adds an additional hash compilation pass after the assets have been processed to get the correct asset content hashes. If `realContentHash` is set to `false`, internal data is used to calculate the hash and it can change when assets are identical. By default `optimization.realContentHash` is enabled in production mode and disabled elsewise.
453+
Adds an additional hash compilation pass after the assets have been processed to get the correct asset content hashes. If `realContentHash` is set to `false`, internal data is used to calculate the hash and it can change when assets are identical. By default `optimization.realContentHash` is enabled in production [mode](/configuration/mode/) and disabled otherwise.
429454

430455
**webpack.config.js**
431456

0 commit comments

Comments
 (0)