css-loader 3.5.0 → 3.5.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  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.
4
4
 
5
+ ### [3.5.1](https://github.com/webpack-contrib/css-loader/compare/v3.5.0...v3.5.1) (2020-04-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * don't generate an invalid code for `locals` ([#1072](https://github.com/webpack-contrib/css-loader/issues/1072)) ([866b84a](https://github.com/webpack-contrib/css-loader/commit/866b84acd7fd47651f741ca1e6cf7081c2bbe357))
11
+
5
12
  ## [3.5.0](https://github.com/webpack-contrib/css-loader/compare/v3.4.2...v3.5.0) (2020-04-06)
6
13
 
7
14
 
package/dist/utils.js CHANGED
@@ -300,25 +300,26 @@ function getExportCode(exports, exportType, localsConvention, icssReplacements,
300
300
  let code = '';
301
301
  let localsCode = '';
302
302
 
303
- const addExportToLocalsCode = (name, value, index) => {
304
- const isLastItem = index === exports.length - 1;
305
- localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}${isLastItem ? '' : ',\n'}`;
306
- };
303
+ const addExportToLocalsCode = (name, value) => {
304
+ if (localsCode) {
305
+ localsCode += `,\n`;
306
+ }
307
307
 
308
- for (const [index, item] of exports.entries()) {
309
- const {
310
- name,
311
- value
312
- } = item;
308
+ localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`;
309
+ };
313
310
 
311
+ for (const {
312
+ name,
313
+ value
314
+ } of exports) {
314
315
  switch (localsConvention) {
315
316
  case 'camelCase':
316
317
  {
317
- addExportToLocalsCode(name, value, index);
318
+ addExportToLocalsCode(name, value);
318
319
  const modifiedName = (0, _camelcase.default)(name);
319
320
 
320
321
  if (modifiedName !== name) {
321
- addExportToLocalsCode(modifiedName, value, index);
322
+ addExportToLocalsCode(modifiedName, value);
322
323
  }
323
324
 
324
325
  break;
@@ -326,17 +327,17 @@ function getExportCode(exports, exportType, localsConvention, icssReplacements,
326
327
 
327
328
  case 'camelCaseOnly':
328
329
  {
329
- addExportToLocalsCode((0, _camelcase.default)(name), value, index);
330
+ addExportToLocalsCode((0, _camelcase.default)(name), value);
330
331
  break;
331
332
  }
332
333
 
333
334
  case 'dashes':
334
335
  {
335
336
  addExportToLocalsCode(name, value);
336
- const modifiedName = dashesCamelCase(name, index);
337
+ const modifiedName = dashesCamelCase(name);
337
338
 
338
339
  if (modifiedName !== name) {
339
- addExportToLocalsCode(modifiedName, value, index);
340
+ addExportToLocalsCode(modifiedName, value);
340
341
  }
341
342
 
342
343
  break;
@@ -344,13 +345,13 @@ function getExportCode(exports, exportType, localsConvention, icssReplacements,
344
345
 
345
346
  case 'dashesOnly':
346
347
  {
347
- addExportToLocalsCode(dashesCamelCase(name), value, index);
348
+ addExportToLocalsCode(dashesCamelCase(name), value);
348
349
  break;
349
350
  }
350
351
 
351
352
  case 'asIs':
352
353
  default:
353
- addExportToLocalsCode(name, value, index);
354
+ addExportToLocalsCode(name, value);
354
355
  break;
355
356
  }
356
357
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",