css-loader 4.2.0 → 4.2.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
+ ### [4.2.1](https://github.com/webpack-contrib/css-loader/compare/v4.2.0...v4.2.1) (2020-08-06)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * regression with the `exportOnlyLocals` option, now `locals` are not exported under the `locals` name, it was big regression, we apologize for that ([24c0a12](https://github.com/webpack-contrib/css-loader/commit/24c0a122d1396c08326a24f6184f5da09cf52ccc))
11
+
5
12
  ## [4.2.0](https://github.com/webpack-contrib/css-loader/compare/v4.1.1...v4.2.0) (2020-07-31)
6
13
 
7
14
 
package/dist/utils.js CHANGED
@@ -345,7 +345,16 @@ function getImportCode(imports, options) {
345
345
  url,
346
346
  icss
347
347
  } = item;
348
- code += options.esModule ? icss && options.modules.namedExport ? `import ${importName}, * as ${importName}_NAMED___ from ${url};\n` : `import ${importName} from ${url};\n` : `var ${importName} = require(${url});\n`;
348
+
349
+ if (options.esModule) {
350
+ if (icss && options.modules.namedExport) {
351
+ code += `import ${options.modules.exportOnlyLocals ? '' : `${importName}, `}* as ${importName}_NAMED___ from ${url};\n`;
352
+ } else {
353
+ code += `import ${importName} from ${url};\n`;
354
+ }
355
+ } else {
356
+ code += `var ${importName} = require(${url});\n`;
357
+ }
349
358
  }
350
359
 
351
360
  return code ? `// Imports\n${code}` : '';
@@ -353,7 +362,7 @@ function getImportCode(imports, options) {
353
362
 
354
363
  function getModuleCode(result, api, replacements, options) {
355
364
  if (options.modules.exportOnlyLocals === true) {
356
- return 'var ___CSS_LOADER_EXPORT___ = {};\n';
365
+ return '';
357
366
  }
358
367
 
359
368
  const {
@@ -402,7 +411,7 @@ function dashesCamelCase(str) {
402
411
  }
403
412
 
404
413
  function getExportCode(exports, replacements, options) {
405
- let code = '';
414
+ let code = '// Exports\n';
406
415
  let localsCode = '';
407
416
 
408
417
  const addExportToLocalsCode = (name, value) => {
@@ -475,18 +484,31 @@ function getExportCode(exports, replacements, options) {
475
484
  const {
476
485
  importName
477
486
  } = item;
478
- localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase.default)(localName))}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
487
+ localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => {
488
+ if (options.modules.namedExport) {
489
+ return `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase.default)(localName))}] + "`;
490
+ } else if (options.modules.exportOnlyLocals) {
491
+ return `" + ${importName}[${JSON.stringify(localName)}] + "`;
492
+ }
493
+
494
+ return `" + ${importName}.locals[${JSON.stringify(localName)}] + "`;
495
+ });
479
496
  } else {
480
497
  localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`);
481
498
  }
482
499
  }
483
500
 
501
+ if (options.modules.exportOnlyLocals) {
502
+ code += options.modules.namedExport ? localsCode : `${options.esModule ? 'export default' : 'module.exports ='} {\n${localsCode}\n};\n`;
503
+ return code;
504
+ }
505
+
484
506
  if (localsCode) {
485
- code += options.modules.namedExport ? `${localsCode}` : `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`;
507
+ code += options.modules.namedExport ? localsCode : `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`;
486
508
  }
487
509
 
488
510
  code += `${options.esModule ? 'export default' : 'module.exports ='} ___CSS_LOADER_EXPORT___;\n`;
489
- return `// Exports\n${code}`;
511
+ return code;
490
512
  }
491
513
 
492
514
  async function resolveRequests(resolve, context, possibleRequests) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",