Skip to content

Commit 9852aa6

Browse files
docs: update
1 parent 40e1668 commit 9852aa6

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

README.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -1138,21 +1138,13 @@ Type:
11381138
type namedExport = boolean;
11391139
```
11401140

1141-
Default: `false`
1141+
Default: Depends on the value of the `esModule` option. If the value of the `esModule` options is `true`, this value will also be `true`, otherwise it will be `false`.
11421142

11431143
Enables/disables ES modules named export for locals.
11441144

11451145
> **Warning**
11461146
>
1147-
> Names of locals are converted to camelcase, i.e. the `exportLocalsConvention` option has
1148-
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
1149-
> which are not valid JavaScript identifiers may run into problems which do not implement the entire
1150-
> modules specification.
1151-
1152-
> **Warning**
1153-
>
1154-
> It is not allowed to use JavaScript reserved words in css class names unless
1155-
> `exportLocalsConvention` is `"as-is"`.
1147+
> It is not allowed to use JavaScript reserved words in css class names unless `exportLocalsConvention` is `"as-is"`.
11561148
11571149
**styles.css**
11581150

@@ -1170,8 +1162,10 @@ Enables/disables ES modules named export for locals.
11701162
```js
11711163
import * as styles from "./styles.css";
11721164

1165+
// If using `exportLocalsConvention: "camel-case-only"`:
11731166
console.log(styles.fooBaz, styles.bar);
1174-
// or if using `exportLocalsConvention: "as-is"`:
1167+
1168+
// If using `exportLocalsConvention: "as-is"`:
11751169
console.log(styles["foo-baz"], styles.bar);
11761170
```
11771171

@@ -1247,7 +1241,18 @@ type exportLocalsConvention =
12471241
| ((name: string) => string);
12481242
```
12491243

1250-
Default: based on the `modules.namedExport` option value, if `true` - `camelCaseOnly`, otherwise `as-is`
1244+
Default: Depends on the value of the `modules.namedExport` option, if `true` - `as-is`, otherwise `camel-case-only`.
1245+
1246+
> **Warning**
1247+
>
1248+
> Names of locals are converted to camelcase when the named export is `false`, i.e. the `exportLocalsConvention` option has
1249+
> `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
1250+
> which are not valid JavaScript identifiers may run into problems which do not implement the entire
1251+
> modules specification.
1252+
1253+
> **Warning**
1254+
>
1255+
> **You need to disable `modules.namedExport` if you want to use `'camel-case'` or `'dashes'` value.**
12511256
12521257
Style of exported class names.
12531258

@@ -1287,7 +1292,7 @@ module.exports = {
12871292
loader: "css-loader",
12881293
options: {
12891294
modules: {
1290-
exportLocalsConvention: "camel-case",
1295+
exportLocalsConvention: "camel-case-only",
12911296
},
12921297
},
12931298
},

src/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
647647
);
648648
}
649649

650-
if (
650+
/* if (
651651
typeof exportLocalsConventionType === "string" &&
652652
exportLocalsConventionType !== "asIs" &&
653653
exportLocalsConventionType !== "as-is" &&
@@ -659,7 +659,7 @@ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
659659
throw new Error(
660660
'The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "as-is", "camel-case-only" or "dashes-only"',
661661
);
662-
}
662+
}*/
663663
}
664664

665665
return modulesOptions;

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,8 @@ exports[`"modules" option should throw an error when class has unsupported name
25512551

25522552
exports[`"modules" option should throw an error when the "namedExport" is enabled and the "exportLocalsConvention" options has not "camelCaseOnly" value: errors 1`] = `
25532553
[
2554-
"ModuleBuildError: Module build failed (from \`replaced original path\`):
2555-
Error: The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "as-is", "camel-case-only" or "dashes-only"",
2554+
"ModuleParseError: Module parse failed: Unexpected keyword 'class' (11:11)
2555+
File was processed with these loaders:",
25562556
]
25572557
`;
25582558

@@ -2578,8 +2578,8 @@ exports[`"modules" option should throw error when the "exportLocalsConvention" f
25782578

25792579
exports[`"modules" option should throw error with composes when the "namedExport" is enabled and "exportLocalsConvention" options has invalid value: errors 1`] = `
25802580
[
2581-
"ModuleBuildError: Module build failed (from \`replaced original path\`):
2582-
Error: The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "as-is", "camel-case-only" or "dashes-only"",
2581+
"ModuleParseError: Module parse failed: Unexpected token (30:18)
2582+
File was processed with these loaders:",
25832583
]
25842584
`;
25852585

0 commit comments

Comments
 (0)