Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix showing of incorrect missing package in customSyntax require handling #5763

Merged
merged 4 commits into from Dec 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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