Skip to content

Commit 8d32b7f

Browse files
authored
docs: rename esModules -> esModule to match the code (#1548)
1 parent 05002f3 commit 8d32b7f

7 files changed

+20
-20
lines changed

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ All notable changes to this project will be documented in this file. See [standa
138138

139139
### Notes
140140

141-
* using `~` is deprecated when the `esModules` option is enabled (enabled by default) and can be removed from your code (**we recommend it**) (`url(~package/image.png)` -> `url(package/image.png)`, `@import url(~package/style.css)` -> `@import url(package/style.css)`, `composes: import from '~package/one.css';` -> `composes: import from 'package/one.css';`), but we still support it for historical reasons. Why can you remove it? The loader will first try to resolve `@import`/`url()`/etc as relative, if it cannot be resolved, the loader will try to resolve `@import`/`url()`/etc inside [`node_modules` or modules directories](https://webpack.js.org/configuration/resolve/#resolvemodules).
141+
* using `~` is deprecated when the `esModule` option is enabled (enabled by default) and can be removed from your code (**we recommend it**) (`url(~package/image.png)` -> `url(package/image.png)`, `@import url(~package/style.css)` -> `@import url(package/style.css)`, `composes: import from '~package/one.css';` -> `composes: import from 'package/one.css';`), but we still support it for historical reasons. Why can you remove it? The loader will first try to resolve `@import`/`url()`/etc as relative, if it cannot be resolved, the loader will try to resolve `@import`/`url()`/etc inside [`node_modules` or modules directories](https://webpack.js.org/configuration/resolve/#resolvemodules).
142142
* `file-loader` and `url-loader` are deprecated, please migrate on [`asset modules`](https://webpack.js.org/guides/asset-modules/), since v6 `css-loader` is generating `new URL(...)` syntax, it enables by default built-in [`assets modules`](https://webpack.js.org/guides/asset-modules/), i.e. `type: 'asset'` for all `url()`
143143

144144
### ⚠ BREAKING CHANGES
@@ -147,9 +147,9 @@ All notable changes to this project will be documented in this file. See [standa
147147
* minimum supported `webpack` version is `5`, we recommend to update to the latest version for better performance
148148
* for `url` and `import` options `Function` type was removed in favor `Object` type with the `filter` property, i.e. before `{ url: () => true }`, now `{ url: { filter: () => true } }` and before `{ import: () => true }`, now `{ import: { filter: () => true } }`
149149
* the `modules.compileType` option was removed in favor the `modules.mode` option with `icss` value, also the `modules` option can have `icss` string value
150-
* `new URL()` syntax used for `url()`, only when the `esModules` option is enabled (enabled by default), it means you can bundle CSS for libraries
150+
* `new URL()` syntax used for `url()`, only when the `esModule` option is enabled (enabled by default), it means you can bundle CSS for libraries
151151
* [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) are handling in `url()`, it means you can register loaders for them, [example](https://webpack.js.org/configuration/module/#rulescheme)
152-
* aliases with `false` value for `url()` now generate empty data URI (i.e. `data:0,`), only when the `esModules` option is enabled (enabled by default)
152+
* aliases with `false` value for `url()` now generate empty data URI (i.e. `data:0,`), only when the `esModule` option is enabled (enabled by default)
153153
* `[ext]` placeholder don't need `.` (dot) before for the `localIdentName` option, i.e. please change `.[ext]` on `[ext]` (no dot before)
154154
* `[folder]` placeholder was removed without replacement for the `localIdentName` option, please use a custom function if you need complex logic
155155
* `[emoji]` placeholder was removed without replacement for the `localIdentName` option, please use a custom function if you need complex logic

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ import "./styles.css";
15381538
15391539
> **Warning**
15401540
>
1541-
> The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1541+
> The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
15421542
15431543
The default export is `string`.
15441544

@@ -1577,7 +1577,7 @@ console.log(sheet);
15771577
15781578
> **Warning**
15791579
>
1580-
> The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1580+
> The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
15811581
15821582
> **Warning**
15831583
>

src/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
659659
if (needNamedExport) {
660660
if (rawOptions.esModule === false) {
661661
throw new Error(
662-
"The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModules' option to be enabled"
662+
"The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModule' option to be enabled"
663663
);
664664
}
665665

@@ -673,7 +673,7 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
673673
if (modulesOptions.namedExport === true) {
674674
if (rawOptions.esModule === false) {
675675
throw new Error(
676-
"The 'modules.namedExport' option requires the 'esModules' option to be enabled"
676+
"The 'modules.namedExport' option requires the 'esModule' option to be enabled"
677677
);
678678
}
679679

test/__snapshots__/exportType.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`'exportType' option should throw an error with 'css-style-sheet' value for CSS modules when \`esModule\` disabled, but 'modules.namedExport' enabled: errors 1`] = `
44
Array [
55
"ModuleBuildError: Module build failed (from \`replaced original path\`):
6-
Error: The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModules' option to be enabled",
6+
Error: The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModule' option to be enabled",
77
]
88
`;
99

@@ -12,7 +12,7 @@ exports[`'exportType' option should throw an error with 'css-style-sheet' value
1212
exports[`'exportType' option should throw an error with 'css-style-sheet' value for CSS modules when \`esModule\` disabled: errors 1`] = `
1313
Array [
1414
"ModuleBuildError: Module build failed (from \`replaced original path\`):
15-
Error: The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModules' option to be enabled",
15+
Error: The 'exportType' option with the 'css-style-sheet' or 'string' value requires the 'esModule' option to be enabled",
1616
]
1717
`;
1818

test/__snapshots__/modules-option.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -2425,7 +2425,7 @@ exports[`"modules" option should throw an error when the "namedExport" is enable
24252425
exports[`"modules" option should throw an error when the "namedExport" option is "true", but the "esModule" is "false": errors 1`] = `
24262426
Array [
24272427
"ModuleBuildError: Module build failed (from \`replaced original path\`):
2428-
Error: The 'modules.namedExport' option requires the 'esModules' option to be enabled",
2428+
Error: The 'modules.namedExport' option requires the 'esModule' option to be enabled",
24292429
]
24302430
`;
24312431

test/__snapshots__/url-option.test.js.snap

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`"url" option should resolve "file" protocol path when the "esModules" is "false": errors 1`] = `Array []`;
3+
exports[`"url" option should resolve "file" protocol path when the "esModule" is "false": errors 1`] = `Array []`;
44

5-
exports[`"url" option should resolve "file" protocol path when the "esModules" is "false": module 1`] = `
5+
exports[`"url" option should resolve "file" protocol path when the "esModule" is "false": module 1`] = `
66
"// Imports
77
var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = require(\\"../../../src/runtime/noSourceMaps.js\\");
88
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\");
@@ -29,7 +29,7 @@ module.exports = ___CSS_LOADER_EXPORT___;
2929
"
3030
`;
3131

32-
exports[`"url" option should resolve "file" protocol path when the "esModules" is "false": result 1`] = `
32+
exports[`"url" option should resolve "file" protocol path when the "esModule" is "false": result 1`] = `
3333
Array [
3434
Array [
3535
"./url/url-file-protocol.css",
@@ -51,7 +51,7 @@ Array [
5151
]
5252
`;
5353

54-
exports[`"url" option should resolve "file" protocol path when the "esModules" is "false": warnings 1`] = `Array []`;
54+
exports[`"url" option should resolve "file" protocol path when the "esModule" is "false": warnings 1`] = `Array []`;
5555

5656
exports[`"url" option should resolve "file" protocol path: errors 1`] = `Array []`;
5757

@@ -106,9 +106,9 @@ Array [
106106

107107
exports[`"url" option should resolve "file" protocol path: warnings 1`] = `Array []`;
108108

109-
exports[`"url" option should resolve absolute path when the 'esModules' is 'false': errors 1`] = `Array []`;
109+
exports[`"url" option should resolve absolute path when the 'esModule' is 'false': errors 1`] = `Array []`;
110110

111-
exports[`"url" option should resolve absolute path when the 'esModules' is 'false': module 1`] = `
111+
exports[`"url" option should resolve absolute path when the 'esModule' is 'false': module 1`] = `
112112
"// Imports
113113
var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = require(\\"../../../src/runtime/noSourceMaps.js\\");
114114
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\");
@@ -135,7 +135,7 @@ module.exports = ___CSS_LOADER_EXPORT___;
135135
"
136136
`;
137137

138-
exports[`"url" option should resolve absolute path when the 'esModules' is 'false': result 1`] = `
138+
exports[`"url" option should resolve absolute path when the 'esModule' is 'false': result 1`] = `
139139
Array [
140140
Array [
141141
"./url/url-absolute.css",
@@ -157,7 +157,7 @@ Array [
157157
]
158158
`;
159159

160-
exports[`"url" option should resolve absolute path when the 'esModules' is 'false': warnings 1`] = `Array []`;
160+
exports[`"url" option should resolve absolute path when the 'esModule' is 'false': warnings 1`] = `Array []`;
161161

162162
exports[`"url" option should resolve absolute path: errors 1`] = `Array []`;
163163

test/url-option.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('"url" option', () => {
149149
expect(getErrors(stats)).toMatchSnapshot("errors");
150150
});
151151

152-
it("should resolve absolute path when the 'esModules' is 'false'", async () => {
152+
it("should resolve absolute path when the 'esModule' is 'false'", async () => {
153153
// Create the file with absolute path
154154
const fileDirectory = path.resolve(__dirname, "fixtures", "url");
155155
const file = path.resolve(fileDirectory, "url-absolute.css");
@@ -227,7 +227,7 @@ describe('"url" option', () => {
227227
expect(getErrors(stats)).toMatchSnapshot("errors");
228228
});
229229

230-
it('should resolve "file" protocol path when the "esModules" is "false"', async () => {
230+
it('should resolve "file" protocol path when the "esModule" is "false"', async () => {
231231
// Create the file with absolute path
232232
const fileDirectory = path.resolve(__dirname, "fixtures", "url");
233233
const file = path.resolve(fileDirectory, "url-file-protocol.css");

0 commit comments

Comments
 (0)