less-loader 11.1.0 → 11.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/README.md +3 -3
- package/dist/index.js +9 -4
- package/dist/utils.js +29 -10
- package/package.json +23 -17
- package/dist/LessError.js +0 -38
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[![node][node]][node-url]
|
|
9
9
|
[![tests][tests]][tests-url]
|
|
10
10
|
[![cover][cover]][cover-url]
|
|
11
|
-
[![
|
|
11
|
+
[![discussion][discussion]][discussion-url]
|
|
12
12
|
[![size][size]][size-url]
|
|
13
13
|
|
|
14
14
|
# less-loader
|
|
@@ -633,7 +633,7 @@ Please take a moment to read our contributing guidelines if you haven't yet done
|
|
|
633
633
|
[tests-url]: https://github.com/webpack-contrib/less-loader/actions
|
|
634
634
|
[cover]: https://codecov.io/gh/webpack-contrib/less-loader/branch/master/graph/badge.svg
|
|
635
635
|
[cover-url]: https://codecov.io/gh/webpack-contrib/less-loader
|
|
636
|
-
[
|
|
637
|
-
[
|
|
636
|
+
[discussion]: https://img.shields.io/github/discussions/webpack/webpack
|
|
637
|
+
[discussion-url]: https://github.com/webpack/webpack/discussions
|
|
638
638
|
[size]: https://packagephobia.now.sh/badge?p=less-loader
|
|
639
639
|
[size-url]: https://packagephobia.now.sh/result?p=less-loader
|
package/dist/index.js
CHANGED
|
@@ -11,14 +11,19 @@ var _options = _interopRequireDefault(require("./options.json"));
|
|
|
11
11
|
|
|
12
12
|
var _utils = require("./utils");
|
|
13
13
|
|
|
14
|
-
var _LessError = _interopRequireDefault(require("./LessError"));
|
|
15
|
-
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
async function lessLoader(source) {
|
|
19
17
|
const options = this.getOptions(_options.default);
|
|
20
18
|
const callback = this.async();
|
|
21
|
-
|
|
19
|
+
let implementation;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
implementation = (0, _utils.getLessImplementation)(this, options.implementation);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
callback(error);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
22
27
|
|
|
23
28
|
if (!implementation) {
|
|
24
29
|
callback(new Error(`The Less implementation "${options.implementation}" not found`));
|
|
@@ -71,7 +76,7 @@ async function lessLoader(source) {
|
|
|
71
76
|
this.addDependency(_path.default.normalize(error.filename));
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
callback(
|
|
79
|
+
callback((0, _utils.errorFactory)(error));
|
|
75
80
|
return;
|
|
76
81
|
} finally {
|
|
77
82
|
// Fix memory leaks in `less`
|
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.getLessImplementation = getLessImplementation;
|
|
7
8
|
exports.getLessOptions = getLessOptions;
|
|
8
9
|
exports.isUnsupportedUrl = isUnsupportedUrl;
|
|
@@ -19,7 +20,7 @@ const trailingSlash = /[/\\]$/; // This somewhat changed in Less 3.x. Now the fi
|
|
|
19
20
|
// automatically added extension whereas the extension is passed in as `options.ext`.
|
|
20
21
|
// So, if the file name matches this regexp, we simply ignore the proposed extension.
|
|
21
22
|
|
|
22
|
-
const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/; // `[drive_letter]:\` + `\\[server]\[
|
|
23
|
+
const IS_SPECIAL_MODULE_IMPORT = /^~[^/]+$/; // `[drive_letter]:\` + `\\[server]\[share_name]\`
|
|
23
24
|
|
|
24
25
|
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i; // Examples:
|
|
25
26
|
// - ~package
|
|
@@ -215,18 +216,36 @@ function getLessImplementation(loaderContext, implementation) {
|
|
|
215
216
|
let resolvedImplementation = implementation;
|
|
216
217
|
|
|
217
218
|
if (!implementation || typeof implementation === "string") {
|
|
218
|
-
const lessImplPkg = implementation || "less";
|
|
219
|
+
const lessImplPkg = implementation || "less"; // eslint-disable-next-line import/no-dynamic-require, global-require
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
222
|
-
resolvedImplementation = require(lessImplPkg);
|
|
223
|
-
} catch (error) {
|
|
224
|
-
loaderContext.emitError(error); // eslint-disable-next-line consistent-return
|
|
225
|
-
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
221
|
+
resolvedImplementation = require(lessImplPkg);
|
|
228
222
|
} // eslint-disable-next-line consistent-return
|
|
229
223
|
|
|
230
224
|
|
|
231
225
|
return resolvedImplementation;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function getFileExcerptIfPossible(error) {
|
|
229
|
+
if (typeof error.extract === "undefined") {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const excerpt = error.extract.slice(0, 2);
|
|
234
|
+
const column = Math.max(error.column - 1, 0);
|
|
235
|
+
|
|
236
|
+
if (typeof excerpt[0] === "undefined") {
|
|
237
|
+
excerpt.shift();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
excerpt.push(`${new Array(column).join(" ")}^`);
|
|
241
|
+
return excerpt;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function errorFactory(error) {
|
|
245
|
+
const message = ["\n", ...getFileExcerptIfPossible(error), error.message.charAt(0).toUpperCase() + error.message.slice(1), error.filename ? ` Error in ${_path.default.normalize(error.filename)} (line ${error.line}, column ${error.column})` : ""].join("\n");
|
|
246
|
+
const obj = new Error(message, {
|
|
247
|
+
cause: error
|
|
248
|
+
});
|
|
249
|
+
obj.stack = null;
|
|
250
|
+
return obj;
|
|
232
251
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less-loader",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.1",
|
|
4
4
|
"description": "A Less loader for webpack. Compiles Less to CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/less-loader",
|
|
@@ -24,7 +24,11 @@
|
|
|
24
24
|
"security": "npm audit --production",
|
|
25
25
|
"lint:prettier": "prettier --list-different .",
|
|
26
26
|
"lint:js": "eslint --cache .",
|
|
27
|
+
"lint:spelling": "cspell \"**/*.*\"",
|
|
27
28
|
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
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",
|
|
28
32
|
"test:only": "cross-env NODE_ENV=test jest",
|
|
29
33
|
"test:watch": "npm run test:only -- --watch",
|
|
30
34
|
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
|
@@ -41,33 +45,35 @@
|
|
|
41
45
|
"webpack": "^5.0.0"
|
|
42
46
|
},
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"klona": "^2.0.
|
|
48
|
+
"klona": "^2.0.6",
|
|
49
|
+
"v": "^0.3.0"
|
|
45
50
|
},
|
|
46
51
|
"devDependencies": {
|
|
47
|
-
"@babel/cli": "^7.
|
|
48
|
-
"@babel/core": "^7.
|
|
49
|
-
"@babel/preset-env": "^7.
|
|
50
|
-
"@commitlint/cli": "^17.1
|
|
51
|
-
"@commitlint/config-conventional": "^17.1
|
|
52
|
+
"@babel/cli": "^7.21.5",
|
|
53
|
+
"@babel/core": "^7.21.5",
|
|
54
|
+
"@babel/preset-env": "^7.21.5",
|
|
55
|
+
"@commitlint/cli": "^17.6.1",
|
|
56
|
+
"@commitlint/config-conventional": "^17.6.1",
|
|
52
57
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
53
|
-
"babel-jest": "^29.
|
|
58
|
+
"babel-jest": "^29.5.0",
|
|
54
59
|
"cross-env": "^7.0.3",
|
|
60
|
+
"cspell": "^6.31.1",
|
|
55
61
|
"del": "^6.1.1",
|
|
56
62
|
"del-cli": "^4.0.1",
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-config-prettier": "^8.
|
|
59
|
-
"eslint-plugin-import": "^2.
|
|
60
|
-
"husky": "^8.0.
|
|
61
|
-
"jest": "^29.
|
|
63
|
+
"eslint": "^8.39.0",
|
|
64
|
+
"eslint-config-prettier": "^8.8.0",
|
|
65
|
+
"eslint-plugin-import": "^2.27.5",
|
|
66
|
+
"husky": "^8.0.3",
|
|
67
|
+
"jest": "^29.5.0",
|
|
62
68
|
"less": "^4.1.3",
|
|
63
69
|
"less-plugin-glob": "^2.0.2",
|
|
64
|
-
"lint-staged": "^
|
|
65
|
-
"memfs": "^3.
|
|
70
|
+
"lint-staged": "^13.2.2",
|
|
71
|
+
"memfs": "^3.5.1",
|
|
66
72
|
"npm-run-all": "^4.1.5",
|
|
67
|
-
"prettier": "^2.
|
|
73
|
+
"prettier": "^2.8.8",
|
|
68
74
|
"standard-version": "^9.3.1",
|
|
69
75
|
"strip-ansi": "^7.0.0",
|
|
70
|
-
"webpack": "^5.
|
|
76
|
+
"webpack": "^5.81.0"
|
|
71
77
|
},
|
|
72
78
|
"keywords": [
|
|
73
79
|
"webpack",
|
package/dist/LessError.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
class LessError extends Error {
|
|
13
|
-
constructor(error) {
|
|
14
|
-
super();
|
|
15
|
-
this.message = ["\n", ...LessError.getFileExcerptIfPossible(error), error.message.charAt(0).toUpperCase() + error.message.slice(1), error.filename ? ` Error in ${_path.default.normalize(error.filename)} (line ${error.line}, column ${error.column})` : ""].join("\n");
|
|
16
|
-
this.hideStack = true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static getFileExcerptIfPossible(lessError) {
|
|
20
|
-
if (typeof lessError.extract === "undefined") {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const excerpt = lessError.extract.slice(0, 2);
|
|
25
|
-
const column = Math.max(lessError.column - 1, 0);
|
|
26
|
-
|
|
27
|
-
if (typeof excerpt[0] === "undefined") {
|
|
28
|
-
excerpt.shift();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
excerpt.push(`${new Array(column).join(" ")}^`);
|
|
32
|
-
return excerpt;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var _default = LessError;
|
|
38
|
-
exports.default = _default;
|