From f526fbf24282509ed11dda14e2535d91c32c4b09 Mon Sep 17 00:00:00 2001 From: adriancuadrado <29214635+adriancuadrado@users.noreply.github.com> Date: Fri, 6 Jun 2025 04:48:59 +0200 Subject: [PATCH 1/2] Update module-methods.mdx Added some clarifications about dynamic expressions in import() and magic comments. --- src/content/api/module-methods.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/content/api/module-methods.mdx b/src/content/api/module-methods.mdx index dd7942f51343..f016c55096c4 100644 --- a/src/content/api/module-methods.mdx +++ b/src/content/api/module-methods.mdx @@ -97,7 +97,7 @@ W> This feature relies on [`Promise`](https://developer.mozilla.org/en-US/docs/W It is not possible to use a fully dynamic import statement, such as `import(foo)`. Because `foo` could potentially be any path to any file in your system or project. -The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. For example, ``import(`./locale/${language}.json`)`` will cause every `.json` file in the `./locale` directory to be bundled into the new chunk. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption. +The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. For example, ``import(`./locale/${language}.json`)`` will only bundle all `.json` files in the `./locale` directory and subdirectories into the new chunk and exclude files with other file extensions. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption. ```javascript // imagine we had a method to get language from cookies or other storage @@ -111,7 +111,7 @@ T> Using the [`webpackInclude` and `webpackExclude`](/api/module-methods/#magic- #### Magic Comments -Inline comments to make features work. By adding comments to the import, we can do things such as name our chunk or select different modes. For a full list of these magic comments see the code below followed by an explanation of what these comments do. +By adding comments to the import, we can do things such as name our chunk or select different modes. For a full list of these magic comments see the code below followed by an explanation of what these comments do. ```js // Single target @@ -137,6 +137,8 @@ import( import(/* webpackIgnore: true */ 'ignored-module.js'); ``` +T> Single line comments (`//`) are also supported. JSDoc comments (`/** */`) are not. + ##### webpackIgnore **JavaScript Usage** From f413041beeb16a4e5a1de73e7a3f2ad84ee9ffa0 Mon Sep 17 00:00:00 2001 From: adriancuadrado <29214635+adriancuadrado@users.noreply.github.com> Date: Fri, 6 Jun 2025 22:43:25 +0200 Subject: [PATCH 2/2] Update module-methods.mdx Fixed lint error: ``` MD013/line-length Line length [Expected: 600; Actual: 628] ``` --- src/content/api/module-methods.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/content/api/module-methods.mdx b/src/content/api/module-methods.mdx index f016c55096c4..6619e4144edb 100644 --- a/src/content/api/module-methods.mdx +++ b/src/content/api/module-methods.mdx @@ -97,7 +97,8 @@ W> This feature relies on [`Promise`](https://developer.mozilla.org/en-US/docs/W It is not possible to use a fully dynamic import statement, such as `import(foo)`. Because `foo` could potentially be any path to any file in your system or project. -The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. For example, ``import(`./locale/${language}.json`)`` will only bundle all `.json` files in the `./locale` directory and subdirectories into the new chunk and exclude files with other file extensions. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption. +The `import()` must contain at least some information about where the module is located. Bundling can be limited to a specific directory or set of files so that when you are using a dynamic expression - every module that could potentially be requested on an `import()` call is included. +For example, ``import(`./locale/${language}.json`)`` will only bundle all `.json` files in the `./locale` directory and subdirectories into the new chunk and exclude files with other file extensions. At run time, when the variable `language` has been computed, any file like `english.json` or `german.json` will be available for consumption. ```javascript // imagine we had a method to get language from cookies or other storage