Skip to content

Commit b1ce195

Browse files
authoredOct 13, 2022
fix: handle swc errors (#202)
1 parent cdcd290 commit b1ce195

File tree

3 files changed

+127
-114
lines changed

3 files changed

+127
-114
lines changed
 

‎package-lock.json

+113-113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@commitlint/cli": "^17.0.0",
8080
"@commitlint/config-conventional": "^17.0.0",
8181
"@parcel/css": "^1.8.3",
82-
"@swc/css": "^0.0.16",
82+
"@swc/css": "^0.0.17",
8383
"@types/clean-css": "^4.2.5",
8484
"@types/csso": "^5.0.0",
8585
"@types/serialize-javascript": "^5.0.2",

‎src/utils.js

+13
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,19 @@ async function swcMinify(input, sourceMap, minimizerOptions) {
474474
code: result.code.toString(),
475475
// eslint-disable-next-line no-undefined
476476
map: result.map ? JSON.parse(result.map.toString()) : undefined,
477+
errors: result.errors
478+
? result.errors.map((diagnostic) => {
479+
const error = new Error(diagnostic.message);
480+
481+
// @ts-ignore
482+
error.span = diagnostic.span;
483+
// @ts-ignore
484+
error.level = diagnostic.level;
485+
486+
return error;
487+
})
488+
: // eslint-disable-next-line no-undefined
489+
undefined,
477490
};
478491
}
479492

0 commit comments

Comments
 (0)
Please sign in to comment.