css-loader 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1156,7 +1156,7 @@ Enables/disables ES modules named export for locals.
1156
1156
 
1157
1157
  > **Warning**
1158
1158
  >
1159
- > It is not allowed to use the `default` reserved word in css classes.
1159
+ > Because it is not allowed to use the `default` class in CSS when the `namedExport` is `true` (since ECMA modules have a reserved keyword `default` for default export), it will be automatically renamed to the `_default` class.
1160
1160
 
1161
1161
  **styles.css**
1162
1162
 
@@ -1167,6 +1167,9 @@ Enables/disables ES modules named export for locals.
1167
1167
  .bar {
1168
1168
  color: blue;
1169
1169
  }
1170
+ .default {
1171
+ color: green;
1172
+ }
1170
1173
  ```
1171
1174
 
1172
1175
  **index.js**
@@ -1179,6 +1182,9 @@ console.log(styles["foo-baz"], styles.bar);
1179
1182
 
1180
1183
  // If using `exportLocalsConvention: "camel-case-only"`:
1181
1184
  console.log(styles.fooBaz, styles.bar);
1185
+
1186
+ // For the `default` classname
1187
+ console.log(styles["_default"]);
1182
1188
  ```
1183
1189
 
1184
1190
  You can enable a ES module named export using:
package/dist/utils.js CHANGED
@@ -845,9 +845,12 @@ function getExportCode(exports, replacements, icssPluginUsed, options, isTemplat
845
845
  let identifierId = 0;
846
846
  const addExportToLocalsCode = (names, value) => {
847
847
  const normalizedNames = Array.isArray(names) ? new Set(names) : new Set([names]);
848
- for (const name of normalizedNames) {
848
+ for (let name of normalizedNames) {
849
849
  const serializedValue = isTemplateLiteralSupported ? convertToTemplateLiteral(value) : JSON.stringify(value);
850
850
  if (options.modules.namedExport) {
851
+ if (name === "default") {
852
+ name = `_${name}`;
853
+ }
851
854
  if (!validIdentifier.test(name) || keywords.has(name)) {
852
855
  identifierId += 1;
853
856
  const id = `_${identifierId.toString(16)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",