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
|**[`preprocessor`](#preprocessor)**|`{Function}`|`undefined`| Allows pre-processing of content before handling |
57
57
|**[`minimize`](#minimize)**|`{Boolean\|Object}`|`true` in production mode, otherwise `false`| Tell `html-loader` to minimize HTML |
58
-
|**[`esModule`](#esmodule)**|`{Boolean}`|`false`|Use ES modules syntax|
58
+
|**[`esModule`](#esmodule)**|`{Boolean}`|`true`|Enable/disable ES modules syntax |
59
59
60
60
### `attributes`
61
61
@@ -488,12 +488,12 @@ module.exports = {
488
488
### `esModule`
489
489
490
490
Type: `Boolean`
491
-
Default: `false`
491
+
Default: `true`
492
492
493
-
By default, `html-loader` generates JS modules that use the CommonJS modules syntax.
493
+
By default, `html-loader` generates JS modules that use the ES modules syntax.
494
494
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
Copy file name to clipboardExpand all lines: test/__snapshots__/preprocessor-option.test.js.snap
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ exports[`'process' option should work with Async "preprocessor" Function option:
4
4
5
5
exports[`'process' option should work with Async "preprocessor" Function option: module 1`] =`
6
6
"// Imports
7
-
var ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ = require(\\"../../src/runtime/getUrl.js\\");
8
-
var ___HTML_LOADER_IMPORT_0___ = require(\\"./image.png\\");
7
+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from \\"../../src/runtime/getUrl.js\\";
8
+
import ___HTML_LOADER_IMPORT_0___ from \\"./image.png\\";
9
9
// Module
10
10
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
11
11
var code = \\"<div>\\\\n <p>Alexander Krasnoyarov</p>\\\\n <imgsrc=\\\\\\"\\"+___HTML_LOADER_REPLACEMENT_0___+\\"\\\\\\"alt=\\\\\\"alt\\\\\\" />\\\\n<div>\\\\n\\";
12
12
// Exports
13
-
module.exports = code;"
13
+
export default code;"
14
14
`;
15
15
16
16
exports[`'process' option should work with Async "preprocessor" Function option: result 1`] = `
@@ -27,15 +27,15 @@ exports[`'process' option should work with the "preprocessor" option #2: errors
27
27
28
28
exports[`'process' option should work with the "preprocessor" option #2: module 1`] = `
29
29
"// Imports
30
-
var ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ = require(\\"../../src/runtime/getUrl.js\\");
31
-
var ___HTML_LOADER_IMPORT_0___ = require(\\"./image.png.webp\\");
32
-
var ___HTML_LOADER_IMPORT_1___ = require(\\"./image.png\\");
30
+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from \\"../../src/runtime/getUrl.js\\";
31
+
import ___HTML_LOADER_IMPORT_0___ from \\"./image.png.webp\\";
32
+
import ___HTML_LOADER_IMPORT_1___ from \\"./image.png\\";
33
33
// Module
34
34
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
35
35
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_1___);
36
36
var code = \\"<picture><sourcetype=\\\\\\"image/webp\\\\\\"srcset=\\\\\\"\\"+___HTML_LOADER_REPLACEMENT_0___+\\"\\\\\\"><imgsrc=\\\\\\"\\"+___HTML_LOADER_REPLACEMENT_1___+\\"\\\\\\"></picture>\\\\n\\";
exports[`'process' option should work with the "preprocessor" option: result 1`] = `
@@ -72,15 +72,15 @@ exports[`'process' option should work with the Async "preprocessor" Function opt
72
72
73
73
exports[`'process' option should work with the Async "preprocessor" Function option #2: module 1`] = `
74
74
"// Imports
75
-
var ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ = require(\\"../../src/runtime/getUrl.js\\");
76
-
var ___HTML_LOADER_IMPORT_0___ = require(\\"./image.png.webp\\");
77
-
var ___HTML_LOADER_IMPORT_1___ = require(\\"./image.png\\");
75
+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from \\"../../src/runtime/getUrl.js\\";
76
+
import ___HTML_LOADER_IMPORT_0___ from \\"./image.png.webp\\";
77
+
import ___HTML_LOADER_IMPORT_1___ from \\"./image.png\\";
78
78
// Module
79
79
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
80
80
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_1___);
81
81
var code = \\"<picture><sourcetype=\\\\\\"image/webp\\\\\\"srcset=\\\\\\"\\"+___HTML_LOADER_REPLACEMENT_0___+\\"\\\\\\"><imgsrc=\\\\\\"\\"+___HTML_LOADER_REPLACEMENT_1___+\\"\\\\\\"></picture>\\\\n\\";
0 commit comments