sass-loader 13.3.0 → 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/dist/index.js +13 -6
- package/dist/utils.js +27 -22
- package/package.json +1 -1
- package/dist/SassError.js +0 -31
- package/dist/SassWarning.js +0 -21
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
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;
|
package/dist/SassWarning.js
DELETED
|
@@ -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;
|