diff --git a/CHANGELOG.md b/CHANGELOG.md index 94681f90..474b727d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [6.8.1](https://github.com/webpack-contrib/css-loader/compare/v6.8.0...v6.8.1) (2023-05-28) + + +### Bug Fixes + +* use `cause` for original errors and warnings ([#1526](https://github.com/webpack-contrib/css-loader/issues/1526)) ([ae3d8ae](https://github.com/webpack-contrib/css-loader/commit/ae3d8ae54ecb5706fe9c3449487cc8306699469f)) + ## [6.8.0](https://github.com/webpack-contrib/css-loader/compare/v6.7.4...v6.8.0) (2023-05-27) diff --git a/package-lock.json b/package-lock.json index a82c9201..1958b6ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "6.8.0", + "version": "6.8.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f5c0324f..e86611d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "6.8.0", + "version": "6.8.1", "description": "css loader module for webpack", "license": "MIT", "repository": "webpack-contrib/css-loader", diff --git a/src/utils.js b/src/utils.js index 678304ac..cc8021e6 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1345,55 +1345,55 @@ function combineRequests(preRequest, url) { : preRequest + url; } -function warningFactory(obj) { +function warningFactory(warning) { let message = ""; - if (typeof obj.line !== "undefined") { - message += `(${obj.line}:${obj.column}) `; + if (typeof warning.line !== "undefined") { + message += `(${warning.line}:${warning.column}) `; } - if (typeof obj.plugin !== "undefined") { - message += `from "${obj.plugin}" plugin: `; + if (typeof warning.plugin !== "undefined") { + message += `from "${warning.plugin}" plugin: `; } - message += obj.text; + message += warning.text; - if (obj.node) { - message += `\n\nCode:\n ${obj.node.toString()}\n`; + if (warning.node) { + message += `\n\nCode:\n ${warning.node.toString()}\n`; } - const warning = new Error(message); + const obj = new Error(message, { cause: warning }); - warning.stack = null; + obj.stack = null; - return warning; + return obj; } -function syntaxErrorFactory(obj) { +function syntaxErrorFactory(error) { let message = "\nSyntaxError\n\n"; - if (typeof obj.line !== "undefined") { - message += `(${obj.line}:${obj.column}) `; + if (typeof error.line !== "undefined") { + message += `(${error.line}:${error.column}) `; } - if (typeof obj.plugin !== "undefined") { - message += `from "${obj.plugin}" plugin: `; + if (typeof error.plugin !== "undefined") { + message += `from "${error.plugin}" plugin: `; } - message += obj.file ? `${obj.file} ` : " "; - message += `${obj.reason}`; + message += error.file ? `${error.file} ` : " "; + message += `${error.reason}`; - const code = obj.showSourceCode(); + const code = error.showSourceCode(); if (code) { message += `\n\n${code}\n`; } - const error = new Error(message); + const obj = new Error(message, { cause: error }); - error.stack = null; + obj.stack = null; - return error; + return obj; } export {