Skip to content

Commit f526fbf

Browse files
Update module-methods.mdx
Added some clarifications about dynamic expressions in import() and magic comments.
1 parent cc4785f commit f526fbf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/content/api/module-methods.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ W> This feature relies on [`Promise`](https://developer.mozilla.org/en-US/docs/W
9797

9898
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.
9999

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

102102
```javascript
103103
// 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-
111111

112112
#### Magic Comments
113113

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.
114+
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.
115115

116116
```js
117117
// Single target
@@ -137,6 +137,8 @@ import(
137137
import(/* webpackIgnore: true */ 'ignored-module.js');
138138
```
139139

140+
T> Single line comments (`//`) are also supported. JSDoc comments (`/** */`) are not.
141+
140142
##### webpackIgnore
141143

142144
**JavaScript Usage**

0 commit comments

Comments
 (0)