From 2ca5e8dad5ca1acfe7acee18dda7907c623221f0 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 19 Sep 2024 17:08:36 +0800 Subject: [PATCH 1/6] docs(optimization): add `optimization.avoidEntryIife` --- src/content/configuration/optimization.mdx | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/content/configuration/optimization.mdx b/src/content/configuration/optimization.mdx index 45401729181d..e3326d7012cf 100644 --- a/src/content/configuration/optimization.mdx +++ b/src/content/configuration/optimization.mdx @@ -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.entryIife + +`boolean = false` + +Use `optimization.entryIife` 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. + +Currently, `optimization.entryIife` can only optimize a single entry module along with other modules. + +By default `optimization.entryIife` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise. + +**webpack.config.js** + +```js +module.exports = { + //... + optimization: { + entryIife: true, + }, +}; +``` + +W> The `⁠optimization.entryIife` option can negatively affect build performance, if you prioritize build performance over these optimizations, consider disabling this option. + ## optimization.flagIncludedChunks `boolean` @@ -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. **webpack.config.js** From 5c02838f5ab833b67c0d3317bc4cc16d8662f883 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 26 Sep 2024 02:14:15 +0800 Subject: [PATCH 2/6] udpate --- src/content/configuration/optimization.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content/configuration/optimization.mdx b/src/content/configuration/optimization.mdx index e3326d7012cf..a4bc18b486e0 100644 --- a/src/content/configuration/optimization.mdx +++ b/src/content/configuration/optimization.mdx @@ -124,15 +124,15 @@ 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.entryIife +## optimization.avoidEntryIife `boolean = false` -Use `optimization.entryIife` 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. +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. -Currently, `optimization.entryIife` can only optimize a single entry module along with other modules. +Currently, `optimization.avoidEntryIife` can only optimize a single entry module along with other modules. -By default `optimization.entryIife` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise. +By default `optimization.avoidEntryIife` is enabled in `production` [mode](/configuration/mode/) and disabled elsewise. **webpack.config.js** @@ -140,12 +140,12 @@ By default `optimization.entryIife` is enabled in `production` [mode](/configura module.exports = { //... optimization: { - entryIife: true, + avoidEntryIife: true, }, }; ``` -W> The `⁠optimization.entryIife` option can negatively affect build performance, if you prioritize build performance over these optimizations, consider disabling this option. +W> The `⁠optimization.avoidEntryIife` option can negatively affect build performance, if you prioritize build performance over these optimizations, consider disabling this option. ## optimization.flagIncludedChunks From 24f7dfd55aaf5b01942d516a3946e6a99759e74a Mon Sep 17 00:00:00 2001 From: Wei Date: Thu, 26 Sep 2024 11:41:26 +0800 Subject: [PATCH 3/6] Update src/content/configuration/optimization.mdx Co-authored-by: Sam Chen --- src/content/configuration/optimization.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/configuration/optimization.mdx b/src/content/configuration/optimization.mdx index a4bc18b486e0..2c9d1cf417ce 100644 --- a/src/content/configuration/optimization.mdx +++ b/src/content/configuration/optimization.mdx @@ -448,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](/configuration/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 otherwise. **webpack.config.js** From 6f239eaa72e97ccbaae20defc48971b29f103678 Mon Sep 17 00:00:00 2001 From: Wei Date: Thu, 26 Sep 2024 11:41:36 +0800 Subject: [PATCH 4/6] Update src/content/configuration/optimization.mdx Co-authored-by: Sam Chen --- src/content/configuration/optimization.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/configuration/optimization.mdx b/src/content/configuration/optimization.mdx index 2c9d1cf417ce..a3808b8eca4f 100644 --- a/src/content/configuration/optimization.mdx +++ b/src/content/configuration/optimization.mdx @@ -132,7 +132,7 @@ Use `optimization.avoidEntryIife` to avoid wrapping the entry module in an IIFE 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. +By default, `optimization.avoidEntryIife` is enabled in `production` [mode](/configuration/mode/) and disabled otherwise. **webpack.config.js** From 9f312b25bd91536e9f9da3af6e0a8d60a220da3c Mon Sep 17 00:00:00 2001 From: Wei Date: Thu, 26 Sep 2024 11:41:44 +0800 Subject: [PATCH 5/6] Update src/content/configuration/optimization.mdx Co-authored-by: Sam Chen --- src/content/configuration/optimization.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/configuration/optimization.mdx b/src/content/configuration/optimization.mdx index a3808b8eca4f..4da1110f821e 100644 --- a/src/content/configuration/optimization.mdx +++ b/src/content/configuration/optimization.mdx @@ -128,6 +128,8 @@ W> If you are using webpack [CLI](/api/cli/), the webpack process will not exit `boolean = false` + + 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. Currently, `optimization.avoidEntryIife` can only optimize a single entry module along with other modules. From 7c7acfd4eb73c7d59febad06b188020b6d7152fd Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 26 Sep 2024 11:47:41 +0530 Subject: [PATCH 6/6] Update src/content/configuration/optimization.mdx --- src/content/configuration/optimization.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/configuration/optimization.mdx b/src/content/configuration/optimization.mdx index 4da1110f821e..6218865980c2 100644 --- a/src/content/configuration/optimization.mdx +++ b/src/content/configuration/optimization.mdx @@ -130,7 +130,7 @@ W> If you are using webpack [CLI](/api/cli/), the webpack process will not exit -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. +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. Currently, `optimization.avoidEntryIife` can only optimize a single entry module along with other modules.