sass-loader 13.2.2 → 13.3.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
@@ -11,7 +11,7 @@
11
11
  [![node][node]][node-url]
12
12
  [![tests][tests]][tests-url]
13
13
  [![coverage][cover]][cover-url]
14
- [![chat][chat]][chat-url]
14
+ [![discussion][discussion]][discussion-url]
15
15
  [![size][size]][size-url]
16
16
 
17
17
  # sass-loader
@@ -952,7 +952,7 @@ Please take a moment to read our contributing guidelines if you haven't yet done
952
952
  [tests-url]: https://github.com/webpack-contrib/sass-loader/actions
953
953
  [cover]: https://codecov.io/gh/webpack-contrib/sass-loader/branch/master/graph/badge.svg
954
954
  [cover-url]: https://codecov.io/gh/webpack-contrib/sass-loader
955
- [chat]: https://badges.gitter.im/webpack/webpack.svg
956
- [chat-url]: https://gitter.im/webpack/webpack
955
+ [discussion]: https://img.shields.io/github/discussions/webpack/webpack
956
+ [discussion-url]: https://github.com/webpack/webpack/discussions
957
957
  [size]: https://packagephobia.now.sh/badge?p=sass-loader
958
958
  [size-url]: https://packagephobia.now.sh/result?p=sass-loader
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ var _url = _interopRequireDefault(require("url"));
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
  var _options = _interopRequireDefault(require("./options.json"));
10
10
  var _utils = require("./utils");
11
- var _SassError = _interopRequireDefault(require("./SassError"));
12
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
12
  /**
14
13
  * The sass-loader makes node-sass and dart-sass available to webpack modules.
@@ -19,9 +18,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
18
  async function loader(content) {
20
19
  const options = this.getOptions(_options.default);
21
20
  const callback = this.async();
22
- const implementation = (0, _utils.getSassImplementation)(this, options.implementation);
23
- if (!implementation) {
24
- callback();
21
+ let implementation;
22
+ try {
23
+ implementation = (0, _utils.getSassImplementation)(this, options.implementation);
24
+ } catch (error) {
25
+ callback(error);
25
26
  return;
26
27
  }
27
28
  const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
@@ -38,7 +39,13 @@ async function loader(content) {
38
39
  sassOptions.importers.push((0, _utils.getModernWebpackImporter)(this, implementation));
39
40
  }
40
41
  }
41
- const compile = (0, _utils.getCompileFn)(implementation, options);
42
+ let compile;
43
+ try {
44
+ compile = (0, _utils.getCompileFn)(implementation, options);
45
+ } catch (error) {
46
+ callback(error);
47
+ return;
48
+ }
42
49
  let result;
43
50
  try {
44
51
  result = await compile(sassOptions, options);
@@ -53,7 +60,7 @@ async function loader(content) {
53
60
  // `node-sass` returns POSIX paths
54
61
  this.addDependency(_path.default.normalize(error.file));
55
62
  }
56
- callback(new _SassError.default(error));
63
+ callback((0, _utils.errorFactory)(error));
57
64
  return;
58
65
  }
59
66
  let map =
package/dist/utils.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.errorFactory = errorFactory;
6
7
  exports.getCompileFn = getCompileFn;
7
8
  exports.getModernWebpackImporter = getModernWebpackImporter;
8
9
  exports.getSassImplementation = getSassImplementation;
@@ -15,7 +16,6 @@ var _url = _interopRequireDefault(require("url"));
15
16
  var _path = _interopRequireDefault(require("path"));
16
17
  var _full = require("klona/full");
17
18
  var _neoAsync = _interopRequireDefault(require("neo-async"));
18
- var _SassWarning = _interopRequireDefault(require("./SassWarning"));
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
  function getDefaultSassImplementation() {
21
21
  let sassImplPkg = "sass";
@@ -45,35 +45,21 @@ function getDefaultSassImplementation() {
45
45
  function getSassImplementation(loaderContext, implementation) {
46
46
  let resolvedImplementation = implementation;
47
47
  if (!resolvedImplementation) {
48
- try {
49
- resolvedImplementation = getDefaultSassImplementation();
50
- } catch (error) {
51
- loaderContext.emitError(error);
52
- return;
53
- }
48
+ resolvedImplementation = getDefaultSassImplementation();
54
49
  }
55
50
  if (typeof resolvedImplementation === "string") {
56
- try {
57
- // eslint-disable-next-line import/no-dynamic-require, global-require
58
- resolvedImplementation = require(resolvedImplementation);
59
- } catch (error) {
60
- loaderContext.emitError(error);
61
-
62
- // eslint-disable-next-line consistent-return
63
- return;
64
- }
51
+ // eslint-disable-next-line import/no-dynamic-require, global-require
52
+ resolvedImplementation = require(resolvedImplementation);
65
53
  }
66
54
  const {
67
55
  info
68
56
  } = resolvedImplementation;
69
57
  if (!info) {
70
- loaderContext.emitError(new Error("Unknown Sass implementation."));
71
- return;
58
+ throw new Error("Unknown Sass implementation.");
72
59
  }
73
60
  const infoParts = info.split("\t");
74
61
  if (infoParts.length < 2) {
75
- loaderContext.emitError(new Error(`Unknown Sass implementation "${info}".`));
76
- return;
62
+ throw new Error(`Unknown Sass implementation "${info}".`);
77
63
  }
78
64
  const [implementationName] = infoParts;
79
65
  if (implementationName === "dart-sass") {
@@ -86,7 +72,7 @@ function getSassImplementation(loaderContext, implementation) {
86
72
  // eslint-disable-next-line consistent-return
87
73
  return resolvedImplementation;
88
74
  }
89
- loaderContext.emitError(new Error(`Unknown Sass implementation "${implementationName}".`));
75
+ throw new Error(`Unknown Sass implementation "${implementationName}".`);
90
76
  }
91
77
 
92
78
  /**
@@ -152,7 +138,10 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
152
138
  builtMessage += `\n\n${loggerOptions.stack}`;
153
139
  }
154
140
  if (needEmitWarning) {
155
- loaderContext.emitWarning(new _SassWarning.default(builtMessage, loggerOptions));
141
+ const warning = new Error(builtMessage);
142
+ warning.name = "SassWarning";
143
+ warning.stack = null;
144
+ loaderContext.emitWarning(warning);
156
145
  } else {
157
146
  logger.warn(builtMessage);
158
147
  }
@@ -623,4 +612,20 @@ function normalizeSourceMap(map, rootContext) {
623
612
  return source;
624
613
  });
625
614
  return newMap;
615
+ }
616
+ function errorFactory(error) {
617
+ let message;
618
+ if (error.formatted) {
619
+ message = error.formatted.replace(/^Error: /, "");
620
+ } else {
621
+ // Keep original error if `sassError.formatted` is unavailable
622
+ ({
623
+ message
624
+ } = error);
625
+ }
626
+ const obj = new Error(message, {
627
+ cause: error
628
+ });
629
+ obj.stack = null;
630
+ return obj;
626
631
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sass-loader",
3
- "version": "13.2.2",
3
+ "version": "13.3.1",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
@@ -26,6 +26,9 @@
26
26
  "lint:js": "eslint --cache .",
27
27
  "lint": "npm-run-all -l -p \"lint:**\"",
28
28
  "test:only": "cross-env NODE_ENV=test jest",
29
+ "fix:js": "npm run lint:js -- --fix",
30
+ "fix:prettier": "npm run lint:prettier -- --write",
31
+ "fix": "npm-run-all -l fix:js fix:prettier",
29
32
  "lint:spelling": "cspell \"**/*.*\"",
30
33
  "test:watch": "npm run test:only -- --watch",
31
34
  "test:manual": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
@@ -40,7 +43,7 @@
40
43
  ],
41
44
  "peerDependencies": {
42
45
  "fibers": ">= 3.1.0",
43
- "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
46
+ "node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
44
47
  "sass": "^1.3.0",
45
48
  "sass-embedded": "*",
46
49
  "webpack": "^5.0.0"
@@ -64,11 +67,11 @@
64
67
  "neo-async": "^2.6.2"
65
68
  },
66
69
  "devDependencies": {
67
- "@babel/cli": "^7.21.0",
68
- "@babel/core": "^7.21.3",
69
- "@babel/preset-env": "^7.20.2",
70
- "@commitlint/cli": "^17.5.0",
71
- "@commitlint/config-conventional": "^17.4.4",
70
+ "@babel/cli": "^7.21.5",
71
+ "@babel/core": "^7.21.5",
72
+ "@babel/preset-env": "^7.21.5",
73
+ "@commitlint/cli": "^17.6.1",
74
+ "@commitlint/config-conventional": "^17.6.1",
72
75
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
73
76
  "babel-jest": "^29.5.0",
74
77
  "bootstrap-sass": "^3.4.1",
@@ -79,8 +82,8 @@
79
82
  "css-loader": "^6.7.3",
80
83
  "del": "^6.1.1",
81
84
  "del-cli": "^4.0.1",
82
- "enhanced-resolve": "^5.12.0",
83
- "eslint": "^8.36.0",
85
+ "enhanced-resolve": "^5.13.0",
86
+ "eslint": "^8.39.0",
84
87
  "eslint-config-prettier": "^8.8.0",
85
88
  "eslint-plugin-import": "^2.27.5",
86
89
  "fibers": "^5.0.3",
@@ -89,19 +92,19 @@
89
92
  "husky": "^8.0.3",
90
93
  "jest": "^29.5.0",
91
94
  "jest-environment-node-single-context": "^29.0.0",
92
- "lint-staged": "^12.5.0",
93
- "material-components-web": "^8.0.0",
94
- "memfs": "^3.4.13",
95
+ "lint-staged": "^13.2.2",
96
+ "material-components-web": "^9.0.0",
97
+ "memfs": "^3.5.1",
95
98
  "node-sass": "^8.0.0",
96
99
  "node-sass-glob-importer": "^5.3.2",
97
100
  "npm-run-all": "^4.1.5",
98
- "prettier": "^2.8.7",
99
- "sass": "^1.58.0",
100
- "sass-embedded": "^1.57.1",
101
- "semver": "^7.3.8",
101
+ "prettier": "^2.8.8",
102
+ "sass": "^1.62.1",
103
+ "sass-embedded": "^1.62.0",
104
+ "semver": "^7.5.0",
102
105
  "standard-version": "^9.3.1",
103
- "style-loader": "^3.2.1",
104
- "webpack": "^5.76.3"
106
+ "style-loader": "^3.3.2",
107
+ "webpack": "^5.81.0"
105
108
  },
106
109
  "keywords": [
107
110
  "sass",
package/dist/SassError.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- class SassError extends Error {
8
- constructor(sassError) {
9
- super();
10
- this.name = "SassError";
11
-
12
- // Instruct webpack to hide the JS stack from the console.
13
- // Usually you're only interested in the SASS error in this case.
14
- this.hideStack = true;
15
- Error.captureStackTrace(this, this.constructor);
16
- if (typeof sassError.line !== "undefined" || typeof sassError.column !== "undefined") {
17
- this.loc = {
18
- line: sassError.line,
19
- column: sassError.column
20
- };
21
- }
22
-
23
- // Keep original error if `sassError.formatted` is unavailable
24
- this.message = `${this.name}: ${typeof sassError.message !== "undefined" ? sassError.message : sassError}`;
25
- if (sassError.formatted) {
26
- this.message = `${this.name}: ${sassError.formatted.replace(/^Error: /, "")}`;
27
- }
28
- }
29
- }
30
- var _default = SassError;
31
- exports.default = _default;
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- class SassWarning extends Error {
8
- constructor(warning, options) {
9
- super(warning);
10
- this.name = "SassWarning";
11
- this.hideStack = true;
12
- if (options.span) {
13
- this.loc = {
14
- line: options.span.start.line,
15
- column: options.span.start.column
16
- };
17
- }
18
- }
19
- }
20
- var _default = SassWarning;
21
- exports.default = _default;