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: improve error message if resolve.extensions
is invalid
#16807
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -849,6 +849,17 @@ ${err2.stack}`; | |
err.message += ` | ||
${hints.join("\n\n")}`; | ||
} | ||
|
||
// Check if the extension is missing a leading dot (e.g. "js" instead of ".js") | ||
const specifiedExtensions = Array.from( | ||
resolver.options.extensions | ||
); | ||
specifiedExtensions.forEach(extension => { | ||
if (extension.match(/^[^.]/)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also use |
||
err.message += `\nDid you miss the leading dot in 'resolve.extensions'? Did you mean '.${extension}' instead of '${extension}'?`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's improve this and try to write everything in a line, I saw project with a lot of them and it will be un readable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexander-akait Updated 👍🏻 |
||
} | ||
}); | ||
|
||
callback(err); | ||
} | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoist this RegExp literal into a well-named variable. This reduces memory usage and GC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See
webpack/lib/SourceMapDevToolPlugin.js
Lines 50 to 56 in b604d78