Skip to content

Commit

Permalink
Fix showing of incorrect missing package in customSyntax require hand…
Browse files Browse the repository at this point in the history
…ling (#5763)
  • Loading branch information
dlaub3 committed Dec 8, 2021
1 parent 0d2303e commit f77a009
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/getPostcssResult.js
Expand Up @@ -94,10 +94,16 @@ function getCustomSyntax(customSyntax) {
try {
resolved = require(customSyntax);
} catch (error) {
// @ts-expect-error -- TS2571: Object is of type 'unknown'.
if (error && typeof error === 'object' && error.code === 'MODULE_NOT_FOUND') {
if (
error &&
typeof error === 'object' &&
// @ts-expect-error -- TS2571: Object is of type 'unknown'.
error.code === 'MODULE_NOT_FOUND' &&
// @ts-expect-error -- TS2571: Object is of type 'unknown'.
error.message.includes(customSyntax)
) {
throw new Error(
`Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.`,
`Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.\n\nCaused by: ${error}`,
);
}

Expand Down

0 comments on commit f77a009

Please sign in to comment.