Skip to content

Commit d34643d

Browse files
committed
chore: update README, default options, breaking changes
1 parent 02059cb commit d34643d

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### **7.0.0**
6+
7+
### ⚠ BREAKING CHANGES
8+
9+
* minimum supported `Node.js` version is `16.0.0`
10+
* default value of `exportLocalsConvention` is now `"asIs"`, even when the `namedExport` option is set
11+
512
### [6.8.1](https://github.com/webpack-contrib/css-loader/compare/v6.8.0...v6.8.1) (2023-05-28)
613

714

@@ -150,7 +157,7 @@ All notable changes to this project will be documented in this file. See [standa
150157
* `new URL()` syntax used for `url()`, only when the `esModules` option is enabled (enabled by default), it means you can bundle CSS for libraries
151158
* [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)
152159
* 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)
153-
* `[ext]` placeholder don't need `.` (dot) before for the `localIdentName` option, i.e. please change `.[ext]` on `[ext]` (no dot before)
160+
* `[ext]` placeholder don't need `.` (dot) before for the `localIdentName` option, i.e. please change `.[ext]` on `[ext]` (no dot before)
154161
* `[folder]` placeholder was removed without replacement for the `localIdentName` option, please use a custom function if you need complex logic
155162
* `[emoji]` placeholder was removed without replacement for the `localIdentName` option, please use a custom function if you need complex logic
156163
* the `localIdentHashPrefix` was removed in favor the `localIdentHashSalt` option
@@ -169,7 +176,7 @@ All notable changes to this project will be documented in this file. See [standa
169176

170177
### Notes
171178

172-
* **we strongly recommend not to add `.css` to `resolve.extensions`, it reduces performance and in most cases it is simply not necessary, alternative you can set resolve options [by dependency](https://webpack.js.org/configuration/resolve/#resolvebydependency)**
179+
* **we strongly recommend not to add `.css` to `resolve.extensions`, it reduces performance and in most cases it is simply not necessary, alternative you can set resolve options [by dependency](https://webpack.js.org/configuration/resolve/#resolvebydependency)**
173180

174181
### [5.2.7](https://github.com/webpack-contrib/css-loader/compare/v5.2.6...v5.2.7) (2021-07-13)
175182

README.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,17 +1117,6 @@ Default: `false`
11171117

11181118
Enables/disables ES modules named export for locals.
11191119

1120-
> **Warning**
1121-
>
1122-
> Names of locals are converted to camelcase, i.e. the `exportLocalsConvention` option has
1123-
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
1124-
> which are not valid JavaScript identifiers may run into problems which do not implement the entire
1125-
> modules specification.
1126-
1127-
> **Warning**
1128-
>
1129-
> It is not allowed to use JavaScript reserved words in css class names.
1130-
11311120
**styles.css**
11321121

11331122
```css
@@ -1142,7 +1131,7 @@ Enables/disables ES modules named export for locals.
11421131
**index.js**
11431132

11441133
```js
1145-
import { fooBaz, bar } from "./styles.css";
1134+
import { "foo-baz" as fooBaz, bar } from "./styles.css";
11461135

11471136
console.log(fooBaz, bar);
11481137
```
@@ -1219,18 +1208,14 @@ type exportLocalsConvention =
12191208
| ((name: string) => string);
12201209
```
12211210

1222-
Default: based on the `modules.namedExport` option value, if `true` - `camelCaseOnly`, otherwise `asIs`
1211+
Default: `asIs`
12231212

12241213
Style of exported class names.
12251214

12261215
###### `string`
12271216

12281217
By default, the exported JSON keys mirror the class names (i.e `asIs` value).
12291218

1230-
> **Warning**
1231-
>
1232-
> Only `camelCaseOnly` value allowed if you set the `namedExport` value to `true`.
1233-
12341219
| Name | Type | Description |
12351220
| :-------------------: | :------: | :----------------------------------------------------------------------------------------------- |
12361221
| **`'asIs'`** | `string` | Class names will be exported as is. |

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-loader",
3-
"version": "6.8.1",
3+
"version": "7.0.0-pre",
44
"description": "css loader module for webpack",
55
"license": "MIT",
66
"repository": "webpack-contrib/css-loader",
@@ -13,7 +13,7 @@
1313
},
1414
"main": "dist/cjs.js",
1515
"engines": {
16-
"node": ">= 12.13.0"
16+
"node": ">= 16.0.0"
1717
},
1818
"scripts": {
1919
"start": "npm run build -- -w",

src/utils.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,7 @@ function getModulesOptions(rawOptions, exportType, loaderContext) {
587587
// eslint-disable-next-line no-undefined
588588
getLocalIdent: undefined,
589589
namedExport: needNamedExport || false,
590-
exportLocalsConvention:
591-
(rawModulesOptions.namedExport === true || needNamedExport) &&
592-
typeof rawModulesOptions.exportLocalsConvention === "undefined"
593-
? "camelCaseOnly"
594-
: "asIs",
590+
exportLocalsConvention: "asIs",
595591
exportOnlyLocals: false,
596592
...rawModulesOptions,
597593
};

test/exportType.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ describe("'exportType' option", () => {
7272
it("should work with 'string' value and CSS modules", async () => {
7373
const compiler = getCompiler("./basic-string-css-modules.js", {
7474
exportType: "string",
75-
modules: true,
75+
modules: {
76+
exportLocalsConvention: "camelCaseOnly",
77+
},
7678
});
7779
const stats = await compile(compiler);
7880

@@ -185,7 +187,9 @@ describe("'exportType' option", () => {
185187
"./modules/composes/composes-css-style-sheet.js",
186188
{
187189
exportType: "css-style-sheet",
188-
modules: true,
190+
modules: {
191+
exportLocalsConvention: "camelCaseOnly",
192+
},
189193
}
190194
);
191195
const stats = await compile(compiler);
@@ -206,6 +210,7 @@ describe("'exportType' option", () => {
206210
{
207211
exportType: "css-style-sheet",
208212
modules: {
213+
exportLocalsConvention: "camelCaseOnly",
209214
exportOnlyLocals: true,
210215
},
211216
}

test/modules-option.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ describe('"modules" option', () => {
15651565
it('should work with the "namedExport" option', async () => {
15661566
const compiler = getCompiler("./modules/namedExport/base/index.js", {
15671567
modules: {
1568+
exportLocalsConvention: "camelCaseOnly",
15681569
namedExport: true,
15691570
},
15701571
});
@@ -1604,6 +1605,7 @@ describe('"modules" option', () => {
16041605
const compiler = getCompiler("./modules/namedExport/nested/index.js", {
16051606
esModule: true,
16061607
modules: {
1608+
exportLocalsConvention: "camelCaseOnly",
16071609
namedExport: true,
16081610
},
16091611
});
@@ -1623,6 +1625,7 @@ describe('"modules" option', () => {
16231625
const compiler = getCompiler("./modules/namedExport/template/index.js", {
16241626
esModule: true,
16251627
modules: {
1628+
exportLocalsConvention: "camelCaseOnly",
16261629
localIdentName: "[local]",
16271630
namedExport: true,
16281631
},
@@ -1820,6 +1823,7 @@ describe('"modules" option', () => {
18201823
mode: "local",
18211824
localIdentName: "_[local]",
18221825
namedExport: true,
1826+
exportLocalsConvention: "camelCaseOnly",
18231827
exportOnlyLocals: true,
18241828
},
18251829
esModule: true,
@@ -1839,6 +1843,7 @@ describe('"modules" option', () => {
18391843
it('should work with "url" and "namedExport"', async () => {
18401844
const compiler = getCompiler("./modules/url/source.js", {
18411845
modules: {
1846+
exportLocalsConvention: "camelCaseOnly",
18421847
namedExport: true,
18431848
},
18441849
});
@@ -1859,6 +1864,7 @@ describe('"modules" option', () => {
18591864
"./modules/url/source.js",
18601865
{
18611866
modules: {
1867+
exportLocalsConvention: "camelCaseOnly",
18621868
namedExport: true,
18631869
},
18641870
},
@@ -2035,6 +2041,7 @@ describe('"modules" option', () => {
20352041
modules: {
20362042
mode: "icss",
20372043
namedExport: true,
2044+
exportLocalsConvention: "camelCaseOnly",
20382045
},
20392046
}
20402047
);

0 commit comments

Comments
 (0)