From 845314dff7eeaa6cbf58c295a7921b67010f83f5 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 12 Oct 2024 13:53:57 +0530 Subject: [PATCH 1/2] docs: update output.devtoolNamespace --- src/content/configuration/output.mdx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/content/configuration/output.mdx b/src/content/configuration/output.mdx index fb6a90953dbe..402e2f4b9161 100644 --- a/src/content/configuration/output.mdx +++ b/src/content/configuration/output.mdx @@ -420,7 +420,23 @@ If multiple modules would result in the same name, [`output.devtoolFallbackModul This option determines the module's namespace used with the [`output.devtoolModuleFilenameTemplate`](#outputdevtoolmodulefilenametemplate). When not specified, it will default to the value of: [`output.uniqueName`](#outputuniquename). It's used to prevent source file path collisions in sourcemaps when loading multiple libraries built with webpack. -For example, if you have 2 libraries, with namespaces `library1` and `library2`, which both have a file `./src/index.js` (with potentially different contents), they will expose these files as `webpack://library1/./src/index.js` and `webpack://library2/./src/index.js`. +For example, if you have 2 libraries, with namespaces `library1` and `library2`, which both have a file `./src/index.js` (with potentially different contents), they will expose these files as `webpack://library1/./src/index.js` and `webpack://library2/./src/index.js`. + +This option also accepts template strings like `[name]` to dynamically generate the namespace. + +**webpack.config.js** + +```javascript +module.exports = { + //... + output: { + filename: "[name]-bundle.js", + library: "library-[name]", + libraryTarget: "commonjs", + devtoolNamespace: "library-[name]" + }, +}; +``` ## output.enabledChunkLoadingTypes From a825a9725d3524e5743464522d954c84ebab5d77 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 12 Oct 2024 13:55:50 +0530 Subject: [PATCH 2/2] docs: update output.devtoolNamespace --- src/content/configuration/output.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/configuration/output.mdx b/src/content/configuration/output.mdx index 402e2f4b9161..2a58eddf5950 100644 --- a/src/content/configuration/output.mdx +++ b/src/content/configuration/output.mdx @@ -422,7 +422,7 @@ This option determines the module's namespace used with the [`output.devtoolModu For example, if you have 2 libraries, with namespaces `library1` and `library2`, which both have a file `./src/index.js` (with potentially different contents), they will expose these files as `webpack://library1/./src/index.js` and `webpack://library2/./src/index.js`. -This option also accepts template strings like `[name]` to dynamically generate the namespace. +You can use template strings like `[name]` to dynamically generate namespaces based on the build context, providing additional flexibility. **webpack.config.js** @@ -433,7 +433,7 @@ module.exports = { filename: "[name]-bundle.js", library: "library-[name]", libraryTarget: "commonjs", - devtoolNamespace: "library-[name]" + devtoolNamespace: "library-[name]" // Sets a unique namespace for each library }, }; ```