css-loader 5.0.0 → 5.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/dist/utils.js CHANGED
@@ -21,6 +21,7 @@ exports.getExportCode = getExportCode;
21
21
  exports.resolveRequests = resolveRequests;
22
22
  exports.isUrlRequestable = isUrlRequestable;
23
23
  exports.sort = sort;
24
+ exports.webpackIgnoreCommentRegexp = void 0;
24
25
 
25
26
  var _url = require("url");
26
27
 
@@ -46,9 +47,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
46
47
  MIT License http://www.opensource.org/licenses/mit-license.php
47
48
  Author Tobias Koppers @sokra
48
49
  */
49
- const whitespace = '[\\x20\\t\\r\\n\\f]';
50
- const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, 'ig');
50
+ const whitespace = "[\\x20\\t\\r\\n\\f]";
51
+ const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, "ig");
51
52
  const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
53
+ const webpackIgnoreCommentRegexp = /webpackIgnore:(\s+)?(true|false)/;
54
+ exports.webpackIgnoreCommentRegexp = webpackIgnoreCommentRegexp;
52
55
 
53
56
  function unescape(str) {
54
57
  return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
@@ -67,7 +70,7 @@ function unescape(str) {
67
70
  }
68
71
 
69
72
  function normalizePath(file) {
70
- return _path.default.sep === '\\' ? file.replace(/\\/g, '/') : file;
73
+ return _path.default.sep === "\\" ? file.replace(/\\/g, "/") : file;
71
74
  } // eslint-disable-next-line no-control-regex
72
75
 
73
76
 
@@ -75,9 +78,9 @@ const filenameReservedRegex = /[<>:"/\\|?*]/g; // eslint-disable-next-line no-co
75
78
 
76
79
  const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;
77
80
 
78
- function escapeLocalident(localident) {
81
+ function escapeLocalIdent(localident) {
79
82
  return (0, _cssesc.default)(localident // For `[hash]` placeholder
80
- .replace(/^((-?[0-9])|--)/, '_$1').replace(filenameReservedRegex, '-').replace(reControlChars, '-').replace(/\./g, '-'), {
83
+ .replace(/^((-?[0-9])|--)/, "_$1").replace(filenameReservedRegex, "-").replace(reControlChars, "-").replace(/\./g, "-"), {
81
84
  isIdentifier: true
82
85
  });
83
86
  }
@@ -100,14 +103,14 @@ function normalizeUrl(url, isStringValue) {
100
103
  let normalizedUrl = url;
101
104
 
102
105
  if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
103
- normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, '');
106
+ normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, "");
104
107
  }
105
108
 
106
109
  if (matchNativeWin32Path.test(url)) {
107
- return decodeURIComponent(normalizedUrl);
110
+ return decodeURI(normalizedUrl);
108
111
  }
109
112
 
110
- return decodeURIComponent(unescape(normalizedUrl));
113
+ return decodeURI(unescape(normalizedUrl));
111
114
  }
112
115
 
113
116
  function requestify(url, rootContext) {
@@ -115,12 +118,12 @@ function requestify(url, rootContext) {
115
118
  return (0, _url.fileURLToPath)(url);
116
119
  }
117
120
 
118
- return url.charAt(0) === '/' ? (0, _loaderUtils.urlToRequest)(url, rootContext) : (0, _loaderUtils.urlToRequest)(url);
121
+ return url.charAt(0) === "/" ? (0, _loaderUtils.urlToRequest)(url, rootContext) : (0, _loaderUtils.urlToRequest)(url);
119
122
  }
120
123
 
121
124
  function getFilter(filter, resourcePath) {
122
125
  return (...args) => {
123
- if (typeof filter === 'function') {
126
+ if (typeof filter === "function") {
124
127
  return filter(...args, resourcePath);
125
128
  }
126
129
 
@@ -129,7 +132,7 @@ function getFilter(filter, resourcePath) {
129
132
  }
130
133
 
131
134
  function getValidLocalName(localName, exportLocalsConvention) {
132
- if (exportLocalsConvention === 'dashesOnly') {
135
+ if (exportLocalsConvention === "dashesOnly") {
133
136
  return dashesCamelCase(localName);
134
137
  }
135
138
 
@@ -145,7 +148,7 @@ function getModulesOptions(rawOptions, loaderContext) {
145
148
  } = loaderContext;
146
149
  let isIcss;
147
150
 
148
- if (typeof rawOptions.modules === 'undefined') {
151
+ if (typeof rawOptions.modules === "undefined") {
149
152
  const isModules = moduleRegExp.test(resourcePath);
150
153
 
151
154
  if (!isModules) {
@@ -155,32 +158,32 @@ function getModulesOptions(rawOptions, loaderContext) {
155
158
  if (!isModules && !isIcss) {
156
159
  return false;
157
160
  }
158
- } else if (typeof rawOptions.modules === 'boolean' && rawOptions.modules === false) {
161
+ } else if (typeof rawOptions.modules === "boolean" && rawOptions.modules === false) {
159
162
  return false;
160
163
  }
161
164
 
162
165
  let modulesOptions = {
163
- compileType: isIcss ? 'icss' : 'module',
166
+ compileType: isIcss ? "icss" : "module",
164
167
  auto: true,
165
- mode: 'local',
168
+ mode: "local",
166
169
  exportGlobals: false,
167
- localIdentName: '[hash:base64]',
170
+ localIdentName: "[hash:base64]",
168
171
  localIdentContext: loaderContext.rootContext,
169
- localIdentHashPrefix: '',
172
+ localIdentHashPrefix: "",
170
173
  // eslint-disable-next-line no-undefined
171
174
  localIdentRegExp: undefined,
172
175
  // eslint-disable-next-line no-undefined
173
176
  getLocalIdent: undefined,
174
177
  namedExport: false,
175
- exportLocalsConvention: 'asIs',
178
+ exportLocalsConvention: "asIs",
176
179
  exportOnlyLocals: false
177
180
  };
178
181
 
179
- if (typeof rawOptions.modules === 'boolean' || typeof rawOptions.modules === 'string') {
180
- modulesOptions.mode = typeof rawOptions.modules === 'string' ? rawOptions.modules : 'local';
182
+ if (typeof rawOptions.modules === "boolean" || typeof rawOptions.modules === "string") {
183
+ modulesOptions.mode = typeof rawOptions.modules === "string" ? rawOptions.modules : "local";
181
184
  } else {
182
185
  if (rawOptions.modules) {
183
- if (typeof rawOptions.modules.auto === 'boolean') {
186
+ if (typeof rawOptions.modules.auto === "boolean") {
184
187
  const isModules = rawOptions.modules.auto && moduleRegExp.test(resourcePath);
185
188
 
186
189
  if (!isModules) {
@@ -192,7 +195,7 @@ function getModulesOptions(rawOptions, loaderContext) {
192
195
  if (!isModules) {
193
196
  return false;
194
197
  }
195
- } else if (typeof rawOptions.modules.auto === 'function') {
198
+ } else if (typeof rawOptions.modules.auto === "function") {
196
199
  const isModule = rawOptions.modules.auto(resourcePath);
197
200
 
198
201
  if (!isModule) {
@@ -200,8 +203,8 @@ function getModulesOptions(rawOptions, loaderContext) {
200
203
  }
201
204
  }
202
205
 
203
- if (rawOptions.modules.namedExport === true && typeof rawOptions.modules.exportLocalsConvention === 'undefined') {
204
- modulesOptions.exportLocalsConvention = 'camelCaseOnly';
206
+ if (rawOptions.modules.namedExport === true && typeof rawOptions.modules.exportLocalsConvention === "undefined") {
207
+ modulesOptions.exportLocalsConvention = "camelCaseOnly";
205
208
  }
206
209
  }
207
210
 
@@ -210,7 +213,7 @@ function getModulesOptions(rawOptions, loaderContext) {
210
213
  };
211
214
  }
212
215
 
213
- if (typeof modulesOptions.mode === 'function') {
216
+ if (typeof modulesOptions.mode === "function") {
214
217
  modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath);
215
218
  }
216
219
 
@@ -219,13 +222,13 @@ function getModulesOptions(rawOptions, loaderContext) {
219
222
  throw new Error('The "modules.namedExport" option requires the "esModules" option to be enabled');
220
223
  }
221
224
 
222
- if (modulesOptions.exportLocalsConvention !== 'camelCaseOnly' && modulesOptions.exportLocalsConvention !== 'dashesOnly') {
225
+ if (modulesOptions.exportLocalsConvention !== "camelCaseOnly" && modulesOptions.exportLocalsConvention !== "dashesOnly") {
223
226
  throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly" or "dashesOnly"');
224
227
  }
225
228
  }
226
229
 
227
230
  if (/\[emoji(?::(\d+))?\]/i.test(modulesOptions.localIdentName)) {
228
- loaderContext.emitWarning('Emoji is deprecated and will be removed in next major release.');
231
+ loaderContext.emitWarning("Emoji is deprecated and will be removed in next major release.");
229
232
  }
230
233
 
231
234
  return modulesOptions;
@@ -234,12 +237,12 @@ function getModulesOptions(rawOptions, loaderContext) {
234
237
  function normalizeOptions(rawOptions, loaderContext) {
235
238
  const modulesOptions = getModulesOptions(rawOptions, loaderContext);
236
239
  return {
237
- url: typeof rawOptions.url === 'undefined' ? true : rawOptions.url,
238
- import: typeof rawOptions.import === 'undefined' ? true : rawOptions.import,
240
+ url: typeof rawOptions.url === "undefined" ? true : rawOptions.url,
241
+ import: typeof rawOptions.import === "undefined" ? true : rawOptions.import,
239
242
  modules: modulesOptions,
240
- sourceMap: typeof rawOptions.sourceMap === 'boolean' ? rawOptions.sourceMap : loaderContext.sourceMap,
241
- importLoaders: typeof rawOptions.importLoaders === 'string' ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
242
- esModule: typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule
243
+ sourceMap: typeof rawOptions.sourceMap === "boolean" ? rawOptions.sourceMap : loaderContext.sourceMap,
244
+ importLoaders: typeof rawOptions.importLoaders === "string" ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
245
+ esModule: typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule
243
246
  };
244
247
  }
245
248
 
@@ -248,7 +251,7 @@ function shouldUseImportPlugin(options) {
248
251
  return false;
249
252
  }
250
253
 
251
- if (typeof options.import === 'boolean') {
254
+ if (typeof options.import === "boolean") {
252
255
  return options.import;
253
256
  }
254
257
 
@@ -260,7 +263,7 @@ function shouldUseURLPlugin(options) {
260
263
  return false;
261
264
  }
262
265
 
263
- if (typeof options.url === 'boolean') {
266
+ if (typeof options.url === "boolean") {
264
267
  return options.url;
265
268
  }
266
269
 
@@ -268,7 +271,7 @@ function shouldUseURLPlugin(options) {
268
271
  }
269
272
 
270
273
  function shouldUseModulesPlugins(options) {
271
- return options.modules.compileType === 'module';
274
+ return options.modules.compileType === "module";
272
275
  }
273
276
 
274
277
  function shouldUseIcssPlugin(options) {
@@ -293,7 +296,7 @@ function getModulesPlugins(options, loaderContext) {
293
296
  generateScopedName(exportName) {
294
297
  let localIdent;
295
298
 
296
- if (typeof getLocalIdent !== 'undefined') {
299
+ if (typeof getLocalIdent !== "undefined") {
297
300
  localIdent = getLocalIdent(loaderContext, localIdentName, unescape(exportName), {
298
301
  context: localIdentContext,
299
302
  hashPrefix: localIdentHashPrefix,
@@ -303,16 +306,16 @@ function getModulesPlugins(options, loaderContext) {
303
306
  // getLocalIdent method.
304
307
 
305
308
 
306
- if (typeof localIdent === 'undefined' || localIdent === null) {
309
+ if (typeof localIdent === "undefined" || localIdent === null) {
307
310
  localIdent = defaultGetLocalIdent(loaderContext, localIdentName, unescape(exportName), {
308
311
  context: localIdentContext,
309
312
  hashPrefix: localIdentHashPrefix,
310
313
  regExp: localIdentRegExp
311
314
  });
312
- return escapeLocalident(localIdent).replace(/\\\[local\\]/gi, exportName);
315
+ return escapeLocalIdent(localIdent).replace(/\\\[local\\]/gi, exportName);
313
316
  }
314
317
 
315
- return escapeLocalident(localIdent);
318
+ return escapeLocalIdent(localIdent);
316
319
  },
317
320
 
318
321
  exportGlobals: options.modules.exportGlobals
@@ -328,26 +331,26 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
328
331
  const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i;
329
332
 
330
333
  function getURLType(source) {
331
- if (source[0] === '/') {
332
- if (source[1] === '/') {
333
- return 'scheme-relative';
334
+ if (source[0] === "/") {
335
+ if (source[1] === "/") {
336
+ return "scheme-relative";
334
337
  }
335
338
 
336
- return 'path-absolute';
339
+ return "path-absolute";
337
340
  }
338
341
 
339
342
  if (IS_NATIVE_WIN32_PATH.test(source)) {
340
- return 'path-absolute';
343
+ return "path-absolute";
341
344
  }
342
345
 
343
- return ABSOLUTE_SCHEME.test(source) ? 'absolute' : 'path-relative';
346
+ return ABSOLUTE_SCHEME.test(source) ? "absolute" : "path-relative";
344
347
  }
345
348
 
346
349
  function normalizeSourceMap(map, resourcePath) {
347
350
  let newMap = map; // Some loader emit source map as string
348
351
  // Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
349
352
 
350
- if (typeof newMap === 'string') {
353
+ if (typeof newMap === "string") {
351
354
  newMap = JSON.parse(newMap);
352
355
  }
353
356
 
@@ -362,14 +365,14 @@ function normalizeSourceMap(map, resourcePath) {
362
365
  // We should normalize path because previous loaders like `sass-loader` using backslash when generate source map
363
366
  newMap.sources = newMap.sources.map(source => {
364
367
  // Non-standard syntax from `postcss`
365
- if (source.indexOf('<') === 0) {
368
+ if (source.indexOf("<") === 0) {
366
369
  return source;
367
370
  }
368
371
 
369
372
  const sourceType = getURLType(source); // Do no touch `scheme-relative` and `absolute` URLs
370
373
 
371
- if (sourceType === 'path-relative' || sourceType === 'path-absolute') {
372
- const absoluteSource = sourceType === 'path-relative' && sourceRoot ? _path.default.resolve(sourceRoot, normalizePath(source)) : normalizePath(source);
374
+ if (sourceType === "path-relative" || sourceType === "path-absolute") {
375
+ const absoluteSource = sourceType === "path-relative" && sourceRoot ? _path.default.resolve(sourceRoot, normalizePath(source)) : normalizePath(source);
373
376
  return _path.default.relative(_path.default.dirname(resourcePath), absoluteSource);
374
377
  }
375
378
 
@@ -391,9 +394,9 @@ function getPreRequester({
391
394
  }
392
395
 
393
396
  if (number === false) {
394
- cache[number] = '';
397
+ cache[number] = "";
395
398
  } else {
396
- const loadersRequest = loaders.slice(loaderIndex, loaderIndex + 1 + (typeof number !== 'number' ? 0 : number)).map(x => x.request).join('!');
399
+ const loadersRequest = loaders.slice(loaderIndex, loaderIndex + 1 + (typeof number !== "number" ? 0 : number)).map(x => x.request).join("!");
397
400
  cache[number] = `-!${loadersRequest}!`;
398
401
  }
399
402
 
@@ -402,7 +405,7 @@ function getPreRequester({
402
405
  }
403
406
 
404
407
  function getImportCode(imports, options) {
405
- let code = '';
408
+ let code = "";
406
409
 
407
410
  for (const item of imports) {
408
411
  const {
@@ -413,7 +416,7 @@ function getImportCode(imports, options) {
413
416
 
414
417
  if (options.esModule) {
415
418
  if (icss && options.modules.namedExport) {
416
- code += `import ${options.modules.exportOnlyLocals ? '' : `${importName}, `}* as ${importName}_NAMED___ from ${url};\n`;
419
+ code += `import ${options.modules.exportOnlyLocals ? "" : `${importName}, `}* as ${importName}_NAMED___ from ${url};\n`;
417
420
  } else {
418
421
  code += `import ${importName} from ${url};\n`;
419
422
  }
@@ -422,7 +425,7 @@ function getImportCode(imports, options) {
422
425
  }
423
426
  }
424
427
 
425
- return code ? `// Imports\n${code}` : '';
428
+ return code ? `// Imports\n${code}` : "";
426
429
  }
427
430
 
428
431
  function normalizeSourceMapForRuntime(map, loaderContext) {
@@ -430,16 +433,16 @@ function normalizeSourceMapForRuntime(map, loaderContext) {
430
433
 
431
434
  if (resultMap) {
432
435
  delete resultMap.file;
433
- resultMap.sourceRoot = '';
436
+ resultMap.sourceRoot = "";
434
437
  resultMap.sources = resultMap.sources.map(source => {
435
438
  // Non-standard syntax from `postcss`
436
- if (source.indexOf('<') === 0) {
439
+ if (source.indexOf("<") === 0) {
437
440
  return source;
438
441
  }
439
442
 
440
443
  const sourceType = getURLType(source);
441
444
 
442
- if (sourceType !== 'path-relative') {
445
+ if (sourceType !== "path-relative") {
443
446
  return source;
444
447
  }
445
448
 
@@ -448,7 +451,7 @@ function normalizeSourceMapForRuntime(map, loaderContext) {
448
451
  const absoluteSource = _path.default.resolve(resourceDirname, source);
449
452
 
450
453
  const contextifyPath = normalizePath(_path.default.relative(loaderContext.rootContext, absoluteSource));
451
- return `webpack://${contextifyPath}`;
454
+ return `webpack://./${contextifyPath}`;
452
455
  });
453
456
  }
454
457
 
@@ -457,12 +460,12 @@ function normalizeSourceMapForRuntime(map, loaderContext) {
457
460
 
458
461
  function getModuleCode(result, api, replacements, options, loaderContext) {
459
462
  if (options.modules.exportOnlyLocals === true) {
460
- return '';
463
+ return "";
461
464
  }
462
465
 
463
- const sourceMapValue = options.sourceMap ? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}` : '';
466
+ const sourceMapValue = options.sourceMap ? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}` : "";
464
467
  let code = JSON.stringify(result.css);
465
- let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${options.sourceMap ? '___CSS_LOADER_API_SOURCEMAP_IMPORT___' : 'function(i){return i[1]}'});\n`;
468
+ let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${options.sourceMap ? "___CSS_LOADER_API_SOURCEMAP_IMPORT___" : "function(i){return i[1]}"});\n`;
466
469
 
467
470
  for (const item of api) {
468
471
  const {
@@ -470,7 +473,7 @@ function getModuleCode(result, api, replacements, options, loaderContext) {
470
473
  media,
471
474
  dedupe
472
475
  } = item;
473
- beforeCode += url ? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(`@import url(${url});`)}${media ? `, ${JSON.stringify(media)}` : ''}]);\n` : `___CSS_LOADER_EXPORT___.i(${item.importName}${media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ''}${dedupe ? ', true' : ''});\n`;
476
+ beforeCode += url ? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(`@import url(${url});`)}${media ? `, ${JSON.stringify(media)}` : ""}]);\n` : `___CSS_LOADER_EXPORT___.i(${item.importName}${media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ""}${dedupe ? ", true" : ""});\n`;
474
477
  }
475
478
 
476
479
  for (const item of replacements) {
@@ -481,16 +484,16 @@ function getModuleCode(result, api, replacements, options, loaderContext) {
481
484
  } = item;
482
485
 
483
486
  if (localName) {
484
- code = code.replace(new RegExp(replacementName, 'g'), () => options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify(getValidLocalName(localName, options.modules.exportLocalsConvention))}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
487
+ code = code.replace(new RegExp(replacementName, "g"), () => options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify(getValidLocalName(localName, options.modules.exportLocalsConvention))}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
485
488
  } else {
486
489
  const {
487
490
  hash,
488
491
  needQuotes
489
492
  } = item;
490
- const getUrlOptions = [].concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []).concat(needQuotes ? 'needQuotes: true' : []);
491
- const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(', ')} }` : '';
493
+ const getUrlOptions = [].concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []).concat(needQuotes ? "needQuotes: true" : []);
494
+ const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(", ")} }` : "";
492
495
  beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`;
493
- code = code.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`);
496
+ code = code.replace(new RegExp(replacementName, "g"), () => `" + ${replacementName} + "`);
494
497
  }
495
498
  }
496
499
 
@@ -502,8 +505,8 @@ function dashesCamelCase(str) {
502
505
  }
503
506
 
504
507
  function getExportCode(exports, replacements, options) {
505
- let code = '// Exports\n';
506
- let localsCode = '';
508
+ let code = "// Exports\n";
509
+ let localsCode = "";
507
510
 
508
511
  const addExportToLocalsCode = (name, value) => {
509
512
  if (options.modules.namedExport) {
@@ -522,7 +525,7 @@ function getExportCode(exports, replacements, options) {
522
525
  value
523
526
  } of exports) {
524
527
  switch (options.modules.exportLocalsConvention) {
525
- case 'camelCase':
528
+ case "camelCase":
526
529
  {
527
530
  addExportToLocalsCode(name, value);
528
531
  const modifiedName = (0, _camelcase.default)(name);
@@ -534,13 +537,13 @@ function getExportCode(exports, replacements, options) {
534
537
  break;
535
538
  }
536
539
 
537
- case 'camelCaseOnly':
540
+ case "camelCaseOnly":
538
541
  {
539
542
  addExportToLocalsCode((0, _camelcase.default)(name), value);
540
543
  break;
541
544
  }
542
545
 
543
- case 'dashes':
546
+ case "dashes":
544
547
  {
545
548
  addExportToLocalsCode(name, value);
546
549
  const modifiedName = dashesCamelCase(name);
@@ -552,13 +555,13 @@ function getExportCode(exports, replacements, options) {
552
555
  break;
553
556
  }
554
557
 
555
- case 'dashesOnly':
558
+ case "dashesOnly":
556
559
  {
557
560
  addExportToLocalsCode(dashesCamelCase(name), value);
558
561
  break;
559
562
  }
560
563
 
561
- case 'asIs':
564
+ case "asIs":
562
565
  default:
563
566
  addExportToLocalsCode(name, value);
564
567
  break;
@@ -575,7 +578,7 @@ function getExportCode(exports, replacements, options) {
575
578
  const {
576
579
  importName
577
580
  } = item;
578
- localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => {
581
+ localsCode = localsCode.replace(new RegExp(replacementName, "g"), () => {
579
582
  if (options.modules.namedExport) {
580
583
  return `" + ${importName}_NAMED___[${JSON.stringify(getValidLocalName(localName, options.modules.exportLocalsConvention))}] + "`;
581
584
  } else if (options.modules.exportOnlyLocals) {
@@ -585,12 +588,12 @@ function getExportCode(exports, replacements, options) {
585
588
  return `" + ${importName}.locals[${JSON.stringify(localName)}] + "`;
586
589
  });
587
590
  } else {
588
- localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`);
591
+ localsCode = localsCode.replace(new RegExp(replacementName, "g"), () => `" + ${replacementName} + "`);
589
592
  }
590
593
  }
591
594
 
592
595
  if (options.modules.exportOnlyLocals) {
593
- code += options.modules.namedExport ? localsCode : `${options.esModule ? 'export default' : 'module.exports ='} {\n${localsCode}\n};\n`;
596
+ code += options.modules.namedExport ? localsCode : `${options.esModule ? "export default" : "module.exports ="} {\n${localsCode}\n};\n`;
594
597
  return code;
595
598
  }
596
599
 
@@ -598,14 +601,12 @@ function getExportCode(exports, replacements, options) {
598
601
  code += options.modules.namedExport ? localsCode : `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`;
599
602
  }
600
603
 
601
- code += `${options.esModule ? 'export default' : 'module.exports ='} ___CSS_LOADER_EXPORT___;\n`;
604
+ code += `${options.esModule ? "export default" : "module.exports ="} ___CSS_LOADER_EXPORT___;\n`;
602
605
  return code;
603
606
  }
604
607
 
605
608
  async function resolveRequests(resolve, context, possibleRequests) {
606
- return resolve(context, possibleRequests[0]).then(result => {
607
- return result;
608
- }).catch(error => {
609
+ return resolve(context, possibleRequests[0]).then(result => result).catch(error => {
609
610
  const [, ...tailPossibleRequests] = possibleRequests;
610
611
 
611
612
  if (tailPossibleRequests.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "5.0.0",
3
+ "version": "5.1.1",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/css-loader",
@@ -43,56 +43,56 @@
43
43
  "webpack": "^4.27.0 || ^5.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "camelcase": "^6.1.0",
46
+ "camelcase": "^6.2.0",
47
47
  "cssesc": "^3.0.0",
48
- "icss-utils": "^5.0.0",
48
+ "icss-utils": "^5.1.0",
49
49
  "loader-utils": "^2.0.0",
50
- "postcss": "^8.1.1",
50
+ "postcss": "^8.2.6",
51
51
  "postcss-modules-extract-imports": "^3.0.0",
52
52
  "postcss-modules-local-by-default": "^4.0.0",
53
53
  "postcss-modules-scope": "^3.0.0",
54
54
  "postcss-modules-values": "^4.0.0",
55
55
  "postcss-value-parser": "^4.1.0",
56
56
  "schema-utils": "^3.0.0",
57
- "semver": "^7.3.2"
57
+ "semver": "^7.3.4"
58
58
  },
59
59
  "devDependencies": {
60
- "@babel/cli": "^7.11.6",
61
- "@babel/core": "^7.11.6",
62
- "@babel/preset-env": "^7.11.5",
60
+ "@babel/cli": "^7.12.17",
61
+ "@babel/core": "^7.12.17",
62
+ "@babel/preset-env": "^7.12.17",
63
63
  "@commitlint/cli": "^11.0.0",
64
64
  "@commitlint/config-conventional": "^11.0.0",
65
65
  "@webpack-contrib/defaults": "^6.3.0",
66
66
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
67
- "babel-jest": "^26.5.2",
68
- "cross-env": "^7.0.2",
67
+ "babel-jest": "^26.6.3",
68
+ "cross-env": "^7.0.3",
69
69
  "del": "^6.0.0",
70
70
  "del-cli": "^3.0.1",
71
- "es-check": "^5.1.1",
72
- "eslint": "^7.11.0",
73
- "eslint-config-prettier": "^6.12.0",
71
+ "es-check": "^5.2.0",
72
+ "eslint": "^7.20.0",
73
+ "eslint-config-prettier": "^7.2.0",
74
74
  "eslint-plugin-import": "^2.22.1",
75
- "file-loader": "^6.1.1",
76
- "husky": "^4.3.0",
77
- "jest": "^26.5.3",
78
- "less": "^3.12.2",
79
- "less-loader": "^7.0.2",
80
- "lint-staged": "^10.4.0",
75
+ "file-loader": "^6.2.0",
76
+ "husky": "^4.3.8",
77
+ "jest": "^26.6.3",
78
+ "less": "^4.1.1",
79
+ "less-loader": "^7.1.0",
80
+ "lint-staged": "^10.5.4",
81
81
  "memfs": "^3.2.0",
82
- "mini-css-extract-plugin": "^1.0.0",
82
+ "mini-css-extract-plugin": "^1.3.8",
83
83
  "npm-run-all": "^4.1.5",
84
84
  "postcss-loader": "^4.0.4",
85
85
  "postcss-preset-env": "^6.7.0",
86
86
  "prettier": "^2.1.2",
87
- "sass": "^1.27.0",
88
- "sass-loader": "^10.0.3",
89
- "standard-version": "^9.0.0",
87
+ "sass": "^1.32.8",
88
+ "sass-loader": "^10.1.0",
89
+ "standard-version": "^9.1.1",
90
90
  "strip-ansi": "^6.0.0",
91
91
  "style-loader": "^2.0.0",
92
92
  "stylus": "^0.54.8",
93
- "stylus-loader": "^4.1.1",
93
+ "stylus-loader": "^4.3.0",
94
94
  "url-loader": "^4.1.1",
95
- "webpack": "^5.0.0"
95
+ "webpack": "^5.23.0"
96
96
  },
97
97
  "keywords": [
98
98
  "webpack",