-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Enable click to go to error in console part 2! #6502
Changes from 3 commits
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 |
---|---|---|
|
@@ -103,6 +103,7 @@ function printInstructions(appName, urls, useYarn) { | |
|
||
function createCompiler({ | ||
appName, | ||
appPath, | ||
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. Maybe we should give this a default value of 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. if we give it a default value of '' then it somewhat becomes purposeless; I'm beginning to have mixed feelings about the path prefix stripping actually. Whilst it initially seemed like a good idea and reduced "noise" that rather enforces a certain way of working with your codebase. Let me explain: Consider the following (not unusual) project structure:
With this structure it's quite common to want to open up in the root of that structure and work from there, hacking on both Without the stripping path prefixes approach this works fine. The paths that appear in the console are clickable as they are complete paths. However with path stripping in effect VS Code doesn't know where to go when you're working in the root of the project. Where is this We lose click to go to error in console entirely in this scenario due to path prefix stripping. You can work around it by opening up only in the root of the What do you think? My feeling is that users would probably be better served if we dropped the path prefix stripping. 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. Thanks for the detailed explanation. I agree. All of our path stripping solutions so far have had caveats and been somewhat complicated. Maybe the best first implementation is to use full paths. If we can come up with a robust solution in the future, then it will be an improvement. 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. Solid - I'll make it so 👍 |
||
config, | ||
devSocket, | ||
urls, | ||
|
@@ -145,12 +146,13 @@ function createCompiler({ | |
}); | ||
}); | ||
|
||
const formatter = typescriptFormatter(appPath.replace(/\\/g, '/')); | ||
forkTsCheckerWebpackPlugin | ||
.getCompilerHooks(compiler) | ||
.receive.tap('afterTypeScriptCheck', (diagnostics, lints) => { | ||
const allMsgs = [...diagnostics, ...lints]; | ||
const format = message => | ||
`${message.file}\n${typescriptFormatter(message, true)}`; | ||
`${message.file}\n${formatter(message, true)}`; | ||
|
||
tsMessagesResolver({ | ||
errors: allMsgs.filter(msg => msg.severity === 'error').map(format), | ||
|
@@ -209,7 +211,8 @@ function createCompiler({ | |
} | ||
} | ||
|
||
const messages = formatWebpackMessages(statsData); | ||
const filePathToExclude = appPath.replace(/\\/g, '/'); | ||
const messages = formatWebpackMessages(statsData, filePathToExclude); | ||
const isSuccessful = !messages.errors.length && !messages.warnings.length; | ||
if (isSuccessful) { | ||
console.log(chalk.green('Compiled successfully!')); | ||
|
@@ -227,14 +230,14 @@ function createCompiler({ | |
messages.errors.length = 1; | ||
} | ||
console.log(chalk.red('Failed to compile.\n')); | ||
console.log(messages.errors.join('\n\n')); | ||
console.log(messages.errors.join('\n\n').replace('//', '')); | ||
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. What is this and the following 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. This is also related to path prefix stripping - both the console and the Error Overlay are driven from the same information. This removes a double See my other comment but I'm now of the opinion that path prefix stripping might not be a good idea. I'd be happy to back that out. |
||
return; | ||
} | ||
|
||
// Show warnings if no errors were found. | ||
if (messages.warnings.length) { | ||
console.log(chalk.yellow('Compiled with warnings.\n')); | ||
console.log(messages.warnings.join('\n\n')); | ||
console.log(messages.warnings.join('\n\n').replace('//', '')); | ||
|
||
// Teach some ESLint tricks. | ||
console.log( | ||
|
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.
Typo
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.
what's the typo? Looks good to me? I can confirm that "pithier" is a word 😄 https://en.wiktionary.org/wiki/pithier