less-loader 12.1.0 → 12.3.0

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
@@ -78,7 +78,7 @@ type lessOptions = import('less').options | ((loaderContext: LoaderContext) => i
78
78
 
79
79
  Default: `{ relativeUrls: true }`
80
80
 
81
- You can pass any Less specific options to the `less-loader` through the `lessOptions` property in the [loader options](https://webpack.js.org/configuration/module/#rule-options-rule-query). See the [Less documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options in dash-case. Since we're passing these options to Less programmatically, you need to pass them in camelCase here:
81
+ You can pass any Less specific options to the `less-loader` through the `lessOptions` property in the [loader options](https://webpack.js.org/configuration/module/#ruleoptions--rulequery). See the [Less documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options in dash-case. Since we're passing these options to Less programmatically, you need to pass them in camelCase here:
82
82
 
83
83
  #### `object`
84
84
 
@@ -313,7 +313,7 @@ module.exports = {
313
313
  Type:
314
314
 
315
315
  ```ts
316
- type webpackImporter = boolean;
316
+ type webpackImporter = boolean | "only";
317
317
  ```
318
318
 
319
319
  Default: `true`
@@ -633,7 +633,7 @@ module.exports = {
633
633
  };
634
634
  ```
635
635
 
636
- > **Note**
636
+ > [!NOTE]
637
637
  >
638
638
  > Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside the custom plugin can be done using the `pluginManager.webpackLoaderContext` property.
639
639
 
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _path = _interopRequireDefault(require("path"));
8
8
  var _options = _interopRequireDefault(require("./options.json"));
9
9
  var _utils = require("./utils");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  async function lessLoader(source) {
12
12
  const options = this.getOptions(_options.default);
13
13
  const callback = this.async();
package/dist/options.json CHANGED
@@ -35,7 +35,15 @@
35
35
  "webpackImporter": {
36
36
  "description": "Enables/Disables default `webpack` importer.",
37
37
  "link": "https://github.com/webpack-contrib/less-loader#webpackimporter",
38
- "type": "boolean"
38
+ "anyOf": [
39
+ {
40
+ "type": "boolean"
41
+ },
42
+ {
43
+ "type": "string",
44
+ "enum": ["only"]
45
+ }
46
+ ]
39
47
  },
40
48
  "implementation": {
41
49
  "description": "The implementation of the `Less` to be used.",
package/dist/utils.js CHANGED
@@ -9,7 +9,7 @@ exports.getLessOptions = getLessOptions;
9
9
  exports.isUnsupportedUrl = isUnsupportedUrl;
10
10
  exports.normalizeSourceMap = normalizeSourceMap;
11
11
  var _path = _interopRequireDefault(require("path"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  /* eslint-disable class-methods-use-this */
14
14
  const trailingSlash = /[/\\]$/;
15
15
 
@@ -39,6 +39,7 @@ const MODULE_REQUEST_REGEX = /^[^?]*~/;
39
39
  * @returns {LessPlugin}
40
40
  */
41
41
  function createWebpackLessPlugin(loaderContext, implementation) {
42
+ const lessOptions = loaderContext.getOptions();
42
43
  const resolve = loaderContext.getResolve({
43
44
  dependencyType: "less",
44
45
  conditionNames: ["less", "style", "..."],
@@ -99,7 +100,7 @@ function createWebpackLessPlugin(loaderContext, implementation) {
99
100
  async loadFile(filename, ...args) {
100
101
  let result;
101
102
  try {
102
- if (IS_SPECIAL_MODULE_IMPORT.test(filename)) {
103
+ if (IS_SPECIAL_MODULE_IMPORT.test(filename) || lessOptions.webpackImporter === "only") {
103
104
  const error = new Error();
104
105
  error.type = "Next";
105
106
  throw error;
@@ -149,7 +150,7 @@ function getLessOptions(loaderContext, loaderOptions, implementation) {
149
150
  ...options
150
151
  };
151
152
  const plugins = lessOptions.plugins.slice();
152
- const shouldUseWebpackImporter = typeof loaderOptions.webpackImporter === "boolean" ? loaderOptions.webpackImporter : true;
153
+ const shouldUseWebpackImporter = typeof loaderOptions.webpackImporter === "boolean" || loaderOptions.webpackImporter === "only" ? loaderOptions.webpackImporter : true;
153
154
  if (shouldUseWebpackImporter) {
154
155
  plugins.unshift(createWebpackLessPlugin(loaderContext, implementation));
155
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "less-loader",
3
- "version": "12.1.0",
3
+ "version": "12.3.0",
4
4
  "description": "A Less loader for webpack. Compiles Less to CSS.",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/less-loader",
@@ -34,42 +34,51 @@
34
34
  "test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
35
35
  "pretest": "npm run lint",
36
36
  "test": "npm run test:coverage",
37
- "prepare": "husky install && npm run build",
37
+ "prepare": "husky && npm run build",
38
38
  "release": "standard-version"
39
39
  },
40
40
  "files": [
41
41
  "dist"
42
42
  ],
43
43
  "peerDependencies": {
44
+ "@rspack/core": "0.x || 1.x",
44
45
  "less": "^3.5.0 || ^4.0.0",
45
46
  "webpack": "^5.0.0"
46
47
  },
48
+ "peerDependenciesMeta": {
49
+ "@rspack/core": {
50
+ "optional": true
51
+ },
52
+ "webpack": {
53
+ "optional": true
54
+ }
55
+ },
47
56
  "devDependencies": {
48
- "@babel/cli": "^7.23.4",
49
- "@babel/core": "^7.23.7",
50
- "@babel/preset-env": "^7.23.7",
51
- "@commitlint/cli": "^18.4.4",
52
- "@commitlint/config-conventional": "^18.4.4",
57
+ "@babel/cli": "^7.24.7",
58
+ "@babel/core": "^7.24.7",
59
+ "@babel/preset-env": "^7.24.7",
60
+ "@commitlint/cli": "^18.6.1",
61
+ "@commitlint/config-conventional": "^18.6.2",
53
62
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
54
63
  "babel-jest": "^29.7.0",
55
64
  "cross-env": "^7.0.3",
56
- "cspell": "^8.3.2",
65
+ "cspell": "^8.10.0",
57
66
  "del": "^7.1.0",
58
67
  "del-cli": "^5.1.0",
59
- "eslint": "^8.56.0",
68
+ "eslint": "^8.57.0",
60
69
  "eslint-config-prettier": "^9.1.0",
61
70
  "eslint-plugin-import": "^2.29.1",
62
- "husky": "^8.0.3",
71
+ "husky": "^9.1.3",
63
72
  "jest": "^29.7.0",
64
73
  "less": "^4.2.0",
65
74
  "less-plugin-glob": "^3.0.0",
66
- "lint-staged": "^15.2.0",
67
- "memfs": "^4.6.0",
75
+ "lint-staged": "^15.2.7",
76
+ "memfs": "^4.9.3",
68
77
  "npm-run-all": "^4.1.5",
69
- "prettier": "^3.2.2",
78
+ "prettier": "^3.3.2",
70
79
  "standard-version": "^9.3.1",
71
80
  "strip-ansi": "^7.1.0",
72
- "webpack": "^5.89.0"
81
+ "webpack": "^5.92.1"
73
82
  },
74
83
  "keywords": [
75
84
  "webpack",