sass-loader 10.4.1 → 10.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/dist/SassError.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  class SassError extends Error {
9
8
  constructor(sassError) {
10
9
  super();
@@ -13,20 +12,19 @@ class SassError extends Error {
13
12
  this.loc = {
14
13
  line: sassError.line,
15
14
  column: sassError.column
16
- }; // Keep original error if `sassError.formatted` is unavailable
15
+ };
17
16
 
17
+ // Keep original error if `sassError.formatted` is unavailable
18
18
  this.message = `${this.name}: ${this.originalSassError.message}`;
19
-
20
19
  if (this.originalSassError.formatted) {
21
- this.message = `${this.name}: ${this.originalSassError.formatted.replace(/^Error: /, "")}`; // Instruct webpack to hide the JS stack from the console.
22
- // Usually you're only interested in the SASS stack in this case.
20
+ this.message = `${this.name}: ${this.originalSassError.formatted.replace(/^Error: /, "")}`;
23
21
 
22
+ // Instruct webpack to hide the JS stack from the console.
23
+ // Usually you're only interested in the SASS stack in this case.
24
24
  this.hideStack = true;
25
25
  Error.captureStackTrace(this, this.constructor);
26
26
  }
27
27
  }
28
-
29
28
  }
30
-
31
29
  var _default = SassError;
32
30
  exports.default = _default;
package/dist/cjs.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
 
3
3
  const loader = require("./index");
4
-
5
4
  module.exports = loader.default;
package/dist/index.js CHANGED
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _schemaUtils = require("schema-utils");
11
-
12
9
  var _loaderUtils = require("loader-utils");
13
-
14
10
  var _options = _interopRequireDefault(require("./options.json"));
15
-
16
11
  var _utils = require("./utils");
17
-
18
12
  var _SassError = _interopRequireDefault(require("./SassError"));
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  /**
23
15
  * The sass-loader makes node-sass and dart-sass available to webpack modules.
24
16
  *
@@ -33,23 +25,19 @@ async function loader(content) {
33
25
  });
34
26
  const callback = this.async();
35
27
  const implementation = (0, _utils.getSassImplementation)(this, options.implementation);
36
-
37
28
  if (!implementation) {
38
29
  callback();
39
30
  return;
40
31
  }
41
-
42
32
  const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
43
33
  const sassOptions = await (0, _utils.getSassOptions)(this, options, content, implementation, useSourceMap);
44
34
  const shouldUseWebpackImporter = typeof options.webpackImporter === "boolean" ? options.webpackImporter : true;
45
-
46
35
  if (shouldUseWebpackImporter) {
47
36
  const {
48
37
  includePaths
49
38
  } = sassOptions;
50
39
  sassOptions.importer.push((0, _utils.getWebpackImporter)(this, implementation, includePaths));
51
40
  }
52
-
53
41
  const render = (0, _utils.getRenderFunctionFromSassImplementation)(implementation);
54
42
  render(sassOptions, (error, result) => {
55
43
  if (error) {
@@ -58,21 +46,19 @@ async function loader(content) {
58
46
  // `node-sass` returns POSIX paths
59
47
  this.addDependency(_path.default.normalize(error.file));
60
48
  }
61
-
62
49
  callback(new _SassError.default(error));
63
50
  return;
64
51
  }
52
+ let map = result.map ? JSON.parse(result.map) : null;
65
53
 
66
- let map = result.map ? JSON.parse(result.map) : null; // Modify source paths only for webpack, otherwise we do nothing
67
-
54
+ // Modify source paths only for webpack, otherwise we do nothing
68
55
  if (map && useSourceMap) {
69
56
  map = (0, _utils.normalizeSourceMap)(map, this.rootContext);
70
57
  }
71
-
72
58
  result.stats.includedFiles.forEach(includedFile => {
73
- const normalizedIncludedFile = _path.default.normalize(includedFile); // Custom `importer` can return only `contents` so includedFile will be relative
74
-
59
+ const normalizedIncludedFile = _path.default.normalize(includedFile);
75
60
 
61
+ // Custom `importer` can return only `contents` so includedFile will be relative
76
62
  if (_path.default.isAbsolute(normalizedIncludedFile)) {
77
63
  this.addDependency(normalizedIncludedFile);
78
64
  }
@@ -80,6 +66,5 @@ async function loader(content) {
80
66
  callback(null, result.css.toString(), map);
81
67
  });
82
68
  }
83
-
84
69
  var _default = loader;
85
70
  exports.default = _default;
package/dist/utils.js CHANGED
@@ -10,49 +10,42 @@ exports.getWebpackImporter = getWebpackImporter;
10
10
  exports.getWebpackResolver = getWebpackResolver;
11
11
  exports.isSupportedFibers = isSupportedFibers;
12
12
  exports.normalizeSourceMap = normalizeSourceMap;
13
-
14
13
  var _url = _interopRequireDefault(require("url"));
15
-
16
14
  var _path = _interopRequireDefault(require("path"));
17
-
18
15
  var _semver = _interopRequireDefault(require("semver"));
19
-
20
16
  var _full = require("klona/full");
21
-
22
17
  var _loaderUtils = require("loader-utils");
23
-
24
18
  var _neoAsync = _interopRequireDefault(require("neo-async"));
25
-
26
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
20
  function getDefaultSassImplementation() {
29
21
  let sassImplPkg = "sass";
30
-
31
22
  try {
32
23
  require.resolve("sass");
33
- } catch (error) {
24
+ } catch (ignoreError) {
34
25
  try {
35
26
  require.resolve("node-sass");
36
-
37
27
  sassImplPkg = "node-sass";
38
- } catch (ignoreError) {
39
- sassImplPkg = "sass";
28
+ } catch (_ignoreError) {
29
+ try {
30
+ require.resolve("sass-embedded");
31
+ sassImplPkg = "sass-embedded";
32
+ } catch (__ignoreError) {
33
+ sassImplPkg = "sass";
34
+ }
40
35
  }
41
- } // eslint-disable-next-line import/no-dynamic-require, global-require
42
-
36
+ }
43
37
 
38
+ // eslint-disable-next-line import/no-dynamic-require, global-require
44
39
  return require(sassImplPkg);
45
40
  }
41
+
46
42
  /**
47
43
  * @public
48
44
  * This function is not Webpack-specific and can be used by tools wishing to
49
45
  * mimic `sass-loader`'s behaviour, so its signature should not be changed.
50
46
  */
51
-
52
-
53
47
  function getSassImplementation(loaderContext, implementation) {
54
48
  let resolvedImplementation = implementation;
55
-
56
49
  if (!resolvedImplementation) {
57
50
  try {
58
51
  resolvedImplementation = getDefaultSassImplementation();
@@ -61,59 +54,53 @@ function getSassImplementation(loaderContext, implementation) {
61
54
  return;
62
55
  }
63
56
  }
64
-
65
57
  const {
66
58
  info
67
59
  } = resolvedImplementation;
68
-
69
60
  if (!info) {
70
61
  loaderContext.emitError(new Error("Unknown Sass implementation."));
71
62
  return;
72
63
  }
73
-
74
64
  const infoParts = info.split("\t");
75
-
76
65
  if (infoParts.length < 2) {
77
66
  loaderContext.emitError(new Error(`Unknown Sass implementation "${info}".`));
78
67
  return;
79
68
  }
80
-
81
69
  const [implementationName, version] = infoParts;
82
-
83
70
  if (implementationName === "dart-sass") {
84
71
  if (!_semver.default.satisfies(version, "^1.3.0")) {
85
72
  loaderContext.emitError(new Error(`Dart Sass version ${version} is incompatible with ^1.3.0.`));
86
- } // eslint-disable-next-line consistent-return
87
-
73
+ }
88
74
 
75
+ // eslint-disable-next-line consistent-return
89
76
  return resolvedImplementation;
90
77
  } else if (implementationName === "node-sass") {
91
78
  if (!_semver.default.satisfies(version, "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0")) {
92
79
  loaderContext.emitError(new Error(`Node Sass version ${version} is incompatible with ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0.`));
93
- } // eslint-disable-next-line consistent-return
94
-
80
+ }
95
81
 
82
+ // eslint-disable-next-line consistent-return
83
+ return resolvedImplementation;
84
+ } else if (implementationName === "sass-embedded") {
85
+ // eslint-disable-next-line consistent-return
96
86
  return resolvedImplementation;
97
87
  }
98
-
99
88
  loaderContext.emitError(new Error(`Unknown Sass implementation "${implementationName}".`));
100
89
  }
101
-
102
90
  function isSupportedFibers() {
103
91
  const [nodeVersion] = process.versions.node.split(".");
104
92
  return Number(nodeVersion) < 16;
105
93
  }
106
-
107
94
  function isProductionLikeMode(loaderContext) {
108
95
  return loaderContext.mode === "production" || !loaderContext.mode;
109
96
  }
110
-
111
97
  function proxyCustomImporters(importers, loaderContext) {
112
98
  return [].concat(importers).map(importer => function proxyImporter(...args) {
113
99
  this.webpackLoaderContext = loaderContext;
114
100
  return importer.apply(this, args);
115
101
  });
116
102
  }
103
+
117
104
  /**
118
105
  * Derives the sass options from the loader context and normalizes its values with sane defaults.
119
106
  *
@@ -124,23 +111,18 @@ function proxyCustomImporters(importers, loaderContext) {
124
111
  * @param {boolean} useSourceMap
125
112
  * @returns {Object}
126
113
  */
127
-
128
-
129
114
  async function getSassOptions(loaderContext, loaderOptions, content, implementation, useSourceMap) {
130
115
  const options = (0, _full.klona)(loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === "function" ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {});
131
116
  const isDartSass = implementation.info.includes("dart-sass");
132
-
133
117
  if (isDartSass && isSupportedFibers()) {
134
118
  const shouldTryToResolveFibers = !options.fiber && options.fiber !== false;
135
-
136
119
  if (shouldTryToResolveFibers) {
137
120
  let fibers;
138
-
139
121
  try {
140
122
  fibers = require.resolve("fibers");
141
- } catch (_error) {// Nothing
123
+ } catch (_error) {
124
+ // Nothing
142
125
  }
143
-
144
126
  if (fibers) {
145
127
  // eslint-disable-next-line global-require, import/no-dynamic-require
146
128
  options.fiber = require(fibers);
@@ -153,14 +135,13 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
153
135
  // Don't pass the `fiber` option for `node-sass`
154
136
  delete options.fiber;
155
137
  }
156
-
157
138
  options.file = loaderContext.resourcePath;
158
- options.data = loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content; // opt.outputStyle
139
+ options.data = loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content;
159
140
 
141
+ // opt.outputStyle
160
142
  if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
161
143
  options.outputStyle = "compressed";
162
144
  }
163
-
164
145
  if (useSourceMap) {
165
146
  // Deliberately overriding the sourceMap option here.
166
147
  // node-sass won't produce source maps if the data option is used and options.sourceMap is not a string.
@@ -174,35 +155,35 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
174
155
  options.omitSourceMapUrl = true;
175
156
  options.sourceMapEmbed = false;
176
157
  }
177
-
178
158
  const {
179
159
  resourcePath
180
160
  } = loaderContext;
161
+ const ext = _path.default.extname(resourcePath);
181
162
 
182
- const ext = _path.default.extname(resourcePath); // If we are compiling sass and indentedSyntax isn't set, automatically set it.
183
-
184
-
163
+ // If we are compiling sass and indentedSyntax isn't set, automatically set it.
185
164
  if (ext && ext.toLowerCase() === ".sass" && typeof options.indentedSyntax === "undefined") {
186
165
  options.indentedSyntax = true;
187
166
  } else {
188
167
  options.indentedSyntax = Boolean(options.indentedSyntax);
189
- } // Allow passing custom importers to `sass`/`node-sass`. Accepts `Function` or an array of `Function`s.
190
-
168
+ }
191
169
 
170
+ // Allow passing custom importers to `sass`/`node-sass`. Accepts `Function` or an array of `Function`s.
192
171
  options.importer = options.importer ? proxyCustomImporters(Array.isArray(options.importer) ? options.importer : [options.importer], loaderContext) : [];
193
- options.includePaths = [].concat(process.cwd()).concat( // We use `includePaths` in context for resolver, so it should be always absolute
172
+ options.includePaths = [].concat(process.cwd()).concat(
173
+ // We use `includePaths` in context for resolver, so it should be always absolute
194
174
  (options.includePaths || []).map(includePath => _path.default.isAbsolute(includePath) ? includePath : _path.default.join(process.cwd(), includePath))).concat(process.env.SASS_PATH ? process.env.SASS_PATH.split(process.platform === "win32" ? ";" : ":") : []);
195
175
  return options;
196
- } // Examples:
176
+ }
177
+
178
+ // Examples:
197
179
  // - ~package
198
180
  // - ~package/
199
181
  // - ~@org
200
182
  // - ~@org/
201
183
  // - ~@org/package
202
184
  // - ~@org/package/
203
-
204
-
205
185
  const isModuleImport = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;
186
+
206
187
  /**
207
188
  * When `sass`/`node-sass` tries to resolve an import, it uses a special algorithm.
208
189
  * Since the `sass-loader` uses webpack to resolve the modules, we need to simulate that algorithm.
@@ -217,19 +198,23 @@ const isModuleImport = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+
217
198
  * @param {string} rootContext
218
199
  * @returns {Array<string>}
219
200
  */
220
-
221
- function getPossibleRequests( // eslint-disable-next-line no-shadow
201
+ function getPossibleRequests(
202
+ // eslint-disable-next-line no-shadow
222
203
  url, forWebpackResolver = false, rootContext = false) {
223
- const request = (0, _loaderUtils.urlToRequest)(url, // Maybe it is server-relative URLs
224
- forWebpackResolver && rootContext); // In case there is module request, send this to webpack resolver
204
+ const request = (0, _loaderUtils.urlToRequest)(url,
205
+ // Maybe it is server-relative URLs
206
+ forWebpackResolver && rootContext);
225
207
 
208
+ // In case there is module request, send this to webpack resolver
226
209
  if (forWebpackResolver && isModuleImport.test(url)) {
227
210
  return [...new Set([request, url])];
228
- } // Keep in mind: ext can also be something like '.datepicker' when the true extension is omitted and the filename contains a dot.
229
- // @see https://github.com/webpack-contrib/sass-loader/issues/167
211
+ }
230
212
 
213
+ // Keep in mind: ext can also be something like '.datepicker' when the true extension is omitted and the filename contains a dot.
214
+ // @see https://github.com/webpack-contrib/sass-loader/issues/167
215
+ const ext = _path.default.extname(request).toLowerCase();
231
216
 
232
- const ext = _path.default.extname(request).toLowerCase(); // Because @import is also defined in CSS, Sass needs a way of compiling plain CSS @imports without trying to import the files at compile time.
217
+ // Because @import is also defined in CSS, Sass needs a way of compiling plain CSS @imports without trying to import the files at compile time.
233
218
  // To accomplish this, and to ensure SCSS is as much of a superset of CSS as possible, Sass will compile any @imports with the following characteristics to plain CSS imports:
234
219
  // - imports where the URL ends with .css.
235
220
  // - imports where the URL begins http:// or https://.
@@ -237,19 +222,13 @@ url, forWebpackResolver = false, rootContext = false) {
237
222
  // - imports that have media queries.
238
223
  //
239
224
  // The `node-sass` package sends `@import` ending on `.css` to importer, it is bug, so we skip resolve
240
-
241
-
242
225
  if (ext === ".css") {
243
226
  return [];
244
227
  }
245
-
246
228
  const dirname = _path.default.dirname(request);
247
-
248
229
  const basename = _path.default.basename(request);
249
-
250
230
  return [...new Set([`${dirname}/_${basename}`, request].concat(forWebpackResolver ? [`${_path.default.dirname(url)}/_${basename}`, url] : []))];
251
231
  }
252
-
253
232
  function promiseResolve(callbackResolve) {
254
233
  return (context, request) => new Promise((resolve, reject) => {
255
234
  callbackResolve(context, request, (error, result) => {
@@ -261,10 +240,10 @@ function promiseResolve(callbackResolve) {
261
240
  });
262
241
  });
263
242
  }
264
-
265
- const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/; // `[drive_letter]:\` + `\\[server]\[sharename]\`
266
-
243
+ const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/;
244
+ // `[drive_letter]:\` + `\\[server]\[sharename]\`
267
245
  const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
246
+
268
247
  /**
269
248
  * @public
270
249
  * Create the resolve function used in the custom Sass importer.
@@ -283,42 +262,35 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
283
262
  *
284
263
  * @throws If a compatible Sass implementation cannot be found.
285
264
  */
286
-
287
265
  function getWebpackResolver(resolverFactory, implementation, includePaths = [], rootContext = false) {
288
266
  async function startResolving(resolutionMap) {
289
267
  if (resolutionMap.length === 0) {
290
268
  return Promise.reject();
291
269
  }
292
-
293
270
  const [{
294
271
  possibleRequests
295
272
  }] = resolutionMap;
296
-
297
273
  if (possibleRequests.length === 0) {
298
274
  return Promise.reject();
299
275
  }
300
-
301
276
  const [{
302
277
  resolve,
303
278
  context
304
279
  }] = resolutionMap;
305
-
306
280
  try {
307
281
  return await resolve(context, possibleRequests[0]);
308
282
  } catch (_ignoreError) {
309
283
  const [, ...tailResult] = possibleRequests;
310
-
311
284
  if (tailResult.length === 0) {
312
285
  const [, ...tailResolutionMap] = resolutionMap;
313
286
  return startResolving(tailResolutionMap);
314
- } // eslint-disable-next-line no-param-reassign
315
-
287
+ }
316
288
 
289
+ // eslint-disable-next-line no-param-reassign
317
290
  resolutionMap[0].possibleRequests = tailResult;
318
291
  return startResolving(resolutionMap);
319
292
  }
320
293
  }
321
-
322
294
  const isDartSass = implementation.info.includes("dart-sass");
323
295
  const sassResolve = promiseResolve(resolverFactory({
324
296
  alias: [],
@@ -342,7 +314,6 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
342
314
  return (context, request) => {
343
315
  const originalRequest = request;
344
316
  const isFileScheme = originalRequest.slice(0, 5).toLowerCase() === "file:";
345
-
346
317
  if (isFileScheme) {
347
318
  try {
348
319
  // eslint-disable-next-line no-param-reassign
@@ -352,15 +323,15 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
352
323
  request = request.slice(7);
353
324
  }
354
325
  }
355
-
356
326
  let resolutionMap = [];
357
- const needEmulateSassResolver = // `sass` doesn't support module import
358
- !IS_SPECIAL_MODULE_IMPORT.test(request) && // We need improve absolute paths handling.
327
+ const needEmulateSassResolver =
328
+ // `sass` doesn't support module import
329
+ !IS_SPECIAL_MODULE_IMPORT.test(request) &&
330
+ // We need improve absolute paths handling.
359
331
  // Absolute paths should be resolved:
360
332
  // - Server-relative URLs - `<context>/path/to/file.ext` (where `<context>` is root context)
361
333
  // - Absolute path - `/full/path/to/file.ext` or `C:\\full\path\to\file.ext`
362
334
  !isFileScheme && !originalRequest.startsWith("/") && !IS_NATIVE_WIN32_PATH.test(originalRequest);
363
-
364
335
  if (includePaths.length > 0 && needEmulateSassResolver) {
365
336
  // The order of import precedence is as follows:
366
337
  //
@@ -371,8 +342,9 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
371
342
  // 5. Filesystem imports relative to a `SASS_PATH` path.
372
343
  //
373
344
  // Because `sass`/`node-sass` run custom importers before `3`, `4` and `5` points, we need to emulate this behavior to avoid wrong resolution.
374
- const sassPossibleRequests = getPossibleRequests(request); // `node-sass` calls our importer before `1. Filesystem imports relative to the base file.`, so we need emulate this too
345
+ const sassPossibleRequests = getPossibleRequests(request);
375
346
 
347
+ // `node-sass` calls our importer before `1. Filesystem imports relative to the base file.`, so we need emulate this too
376
348
  if (!isDartSass) {
377
349
  resolutionMap = resolutionMap.concat({
378
350
  resolve: sassResolve,
@@ -380,8 +352,8 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
380
352
  possibleRequests: sassPossibleRequests
381
353
  });
382
354
  }
383
-
384
- resolutionMap = resolutionMap.concat( // eslint-disable-next-line no-shadow
355
+ resolutionMap = resolutionMap.concat(
356
+ // eslint-disable-next-line no-shadow
385
357
  includePaths.map(context => {
386
358
  return {
387
359
  resolve: sassResolve,
@@ -390,7 +362,6 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
390
362
  };
391
363
  }));
392
364
  }
393
-
394
365
  const webpackPossibleRequests = getPossibleRequests(request, true, rootContext);
395
366
  resolutionMap = resolutionMap.concat({
396
367
  resolve: webpackResolve,
@@ -400,9 +371,7 @@ function getWebpackResolver(resolverFactory, implementation, includePaths = [],
400
371
  return startResolving(resolutionMap);
401
372
  };
402
373
  }
403
-
404
374
  const matchCss = /\.css$/i;
405
-
406
375
  function getWebpackImporter(loaderContext, implementation, includePaths) {
407
376
  const resolve = getWebpackResolver(loaderContext.getResolve, implementation, includePaths, loaderContext.rootContext);
408
377
  return (originalUrl, prev, done) => {
@@ -410,12 +379,13 @@ function getWebpackImporter(loaderContext, implementation, includePaths) {
410
379
  // Add the result as dependency.
411
380
  // Although we're also using stats.includedFiles, this might come in handy when an error occurs.
412
381
  // In this case, we don't get stats.includedFiles from node-sass/sass.
413
- loaderContext.addDependency(_path.default.normalize(result)); // By removing the CSS file extension, we trigger node-sass to include the CSS file instead of just linking it.
414
-
382
+ loaderContext.addDependency(_path.default.normalize(result));
383
+ // By removing the CSS file extension, we trigger node-sass to include the CSS file instead of just linking it.
415
384
  done({
416
385
  file: result.replace(matchCss, "")
417
386
  });
418
- }) // Catch all resolving errors, return the original file and pass responsibility back to other custom importers
387
+ })
388
+ // Catch all resolving errors, return the original file and pass responsibility back to other custom importers
419
389
  .catch(() => {
420
390
  done({
421
391
  file: originalUrl
@@ -423,70 +393,64 @@ function getWebpackImporter(loaderContext, implementation, includePaths) {
423
393
  });
424
394
  };
425
395
  }
426
-
427
396
  let nodeSassJobQueue = null;
397
+
428
398
  /**
429
399
  * Verifies that the implementation and version of Sass is supported by this loader.
430
400
  *
431
401
  * @param {Object} implementation
432
402
  * @returns {Function}
433
403
  */
434
-
435
404
  function getRenderFunctionFromSassImplementation(implementation) {
436
405
  const isDartSass = implementation.info.includes("dart-sass");
437
-
438
406
  if (isDartSass) {
439
407
  return implementation.render.bind(implementation);
440
- } // There is an issue with node-sass when async custom importers are used
408
+ }
409
+
410
+ // There is an issue with node-sass when async custom importers are used
441
411
  // See https://github.com/sass/node-sass/issues/857#issuecomment-93594360
442
412
  // We need to use a job queue to make sure that one thread is always available to the UV lib
443
-
444
-
445
413
  if (nodeSassJobQueue === null) {
446
414
  const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);
447
415
  nodeSassJobQueue = _neoAsync.default.queue(implementation.render.bind(implementation), threadPoolSize - 1);
448
416
  }
449
-
450
417
  return nodeSassJobQueue.push.bind(nodeSassJobQueue);
451
418
  }
452
-
453
419
  const ABSOLUTE_SCHEME = /^[A-Za-z0-9+\-.]+:/;
454
-
455
420
  function getURLType(source) {
456
421
  if (source[0] === "/") {
457
422
  if (source[1] === "/") {
458
423
  return "scheme-relative";
459
424
  }
460
-
461
425
  return "path-absolute";
462
426
  }
463
-
464
427
  if (IS_NATIVE_WIN32_PATH.test(source)) {
465
428
  return "path-absolute";
466
429
  }
467
-
468
430
  return ABSOLUTE_SCHEME.test(source) ? "absolute" : "path-relative";
469
431
  }
470
-
471
432
  function normalizeSourceMap(map, rootContext) {
472
- const newMap = map; // result.map.file is an optional property that provides the output filename.
433
+ const newMap = map;
434
+
435
+ // result.map.file is an optional property that provides the output filename.
473
436
  // Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it.
474
437
  // eslint-disable-next-line no-param-reassign
438
+ delete newMap.file;
475
439
 
476
- delete newMap.file; // eslint-disable-next-line no-param-reassign
440
+ // eslint-disable-next-line no-param-reassign
441
+ newMap.sourceRoot = "";
477
442
 
478
- newMap.sourceRoot = ""; // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
443
+ // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
479
444
  // This fixes an error on windows where the source-map module cannot resolve the source maps.
480
445
  // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
481
446
  // eslint-disable-next-line no-param-reassign
482
-
483
447
  newMap.sources = newMap.sources.map(source => {
484
- const sourceType = getURLType(source); // Do no touch `scheme-relative`, `path-absolute` and `absolute` types
448
+ const sourceType = getURLType(source);
485
449
 
450
+ // Do no touch `scheme-relative`, `path-absolute` and `absolute` types
486
451
  if (sourceType === "path-relative") {
487
452
  return _path.default.resolve(rootContext, _path.default.normalize(source));
488
453
  }
489
-
490
454
  return source;
491
455
  });
492
456
  return newMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sass-loader",
3
- "version": "10.4.1",
3
+ "version": "10.5.1",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "peerDependencies": {
42
42
  "fibers": ">= 3.1.0",
43
- "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
43
+ "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
44
44
  "sass": "^1.3.0",
45
45
  "webpack": "^4.36.0 || ^5.0.0"
46
46
  },