You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds [magic coments](https://webpack.js.org/api/module-methods/#magic-comments) to your dynamic `import()` statements.
3
+
Keep your source code clean, add [magic coments](https://webpack.js.org/api/module-methods/#magic-comments) to your dynamic `import()` statements at build time.
4
4
5
5
NOTE: **This loader ignores dynamic imports that already include comments of any kind**.
6
6
@@ -16,6 +16,26 @@ Magic comments supported:
16
16
17
17
First `npm install magic-comments-loader`.
18
18
19
+
Try *not* to have dynamic `import()` statements behind [comments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#comments). **It is better to remove unused code in production**.
20
+
If you must, e.g. your comment is referencing usage of dynamic imports, then these styles are ok:
21
+
22
+
```js
23
+
// import('some-ignored-module')
24
+
/* Some comment about a dynamic import('module') */
25
+
```
26
+
27
+
If you must have a multiline comment then this style is ok (only one `import()` per comment line preceded by an asterisk):
28
+
29
+
```js
30
+
/**
31
+
* Comment about import('module/one')
32
+
* Comment about import('module/two')
33
+
* import('module/three'), etc.
34
+
*/
35
+
```
36
+
37
+
This module uses a [RegExp](https://github.com/morganney/magic-comments-loader/blob/master/src/loader.js#L8) not a parser. If you would like to add better support for ignoring `import()` behind multiline comments please open a pull request. See some more [examples on regexr](https://regexr.com/65fg0).
0 commit comments