Skip to content

Commit fd94d2a

Browse files
chore: update module-methods.mdx (#7681)
* chore: add adrian to contributors * Update module-methods.mdx Added some clarifications about dynamic expressions in import() and magic comments. * Update module-methods.mdx Fixed lint error: ``` MD013/line-length Line length [Expected: 600; Actual: 628] ``` --------- Co-authored-by: adriancuadrado <29214635+adriancuadrado@users.noreply.github.com>
1 parent 87f3fa5 commit fd94d2a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/content/api/module-methods.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ contributors:
1414
- jamesgeorge007
1515
- WofWca
1616
- snitin315
17+
- adriancuadrado
1718
related:
1819
- title: CommonJS Wikipedia
1920
url: https://en.wikipedia.org/wiki/CommonJS
@@ -97,7 +98,8 @@ W> This feature relies on [`Promise`](https://developer.mozilla.org/en-US/docs/W
9798

9899
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.
99100

100-
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.
101+
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.
102+
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.
101103

102104
```javascript
103105
// imagine we had a method to get language from cookies or other storage
@@ -111,7 +113,7 @@ T> Using the [`webpackInclude` and `webpackExclude`](/api/module-methods/#magic-
111113

112114
#### Magic Comments
113115

114-
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.
116+
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.
115117

116118
```js
117119
// Single target
@@ -137,6 +139,8 @@ import(
137139
import(/* webpackIgnore: true */ 'ignored-module.js');
138140
```
139141

142+
T> Single line comments (`//`) are also supported. JSDoc comments (`/** */`) are not.
143+
140144
##### webpackIgnore
141145

142146
**JavaScript Usage**

0 commit comments

Comments
 (0)