Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(optimization): add optimization.avoidEntryIife #7402

Merged
merged 6 commits into from
Sep 29, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/content/configuration/optimization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ module.exports = {

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).

## optimization.avoidEntryIife

`boolean = false`

fi3ework marked this conversation as resolved.
Show resolved Hide resolved
Use `optimization.avoidEntryIife` to avoid wrapping the entry module in an IIFE when it is required (search for `"This entry need 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.
snitin315 marked this conversation as resolved.
Show resolved Hide resolved

Currently, `optimization.avoidEntryIife` can only optimize a single entry module along with other modules.

By default `optimization.avoidEntryIife` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise.
fi3ework marked this conversation as resolved.
Show resolved Hide resolved

**webpack.config.js**

```js
module.exports = {
//...
optimization: {
avoidEntryIife: true,
},
};
```

W> The `⁠optimization.avoidEntryIife` option can negatively affect build performance, if you prioritize build performance over these optimizations, consider disabling this option.

## optimization.flagIncludedChunks

`boolean`
Expand Down Expand Up @@ -425,7 +448,7 @@ module.exports = {

`boolean`

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.
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 elsewise.
fi3ework marked this conversation as resolved.
Show resolved Hide resolved

**webpack.config.js**

Expand Down