-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Show Fable errors in IDE #412
Comments
That should be pretty easy to add on VSCode side. The interesting question is how user workflow should look like:
It's obviously your decision but maybe we should create "silent, error checking mode" in Fable that only checks the errors, and prints them to console, without printing all other stuff and without outputing js files? |
That could be interesting, but the main problem is Fable doesn't have a light mode like the F# compiler just to check for errors, so we'd have to create the full AST everytime (well, we could save the Babel part, but that's usually pretty fast). Because devs usually run Fable in watch mode, it could be a waste of computing resources to have two Fable processes running to do basically the same thing... For now, I'd just let users start Fable in watch mode through a command in VS Code (the convention is to use |
I actually wonder if we need to do anything.... Have you tried using |
OK, that's bit unfortunate but we can solve it. In last VSCode update they've added ability to define problem matchers on plugin level. Do you think it would be enough to provide Fable problem matcher (so people can do |
Thanks @Krzysztof-Cieslak. Yes, that could probably be enough. I gave it a try and got it working using the following task configuration: {
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "fable",
"suppressTaskName": true,
"args": [ "build/fable/dotnet-fable.dll", "npm-run", "webpack", "--args", "-w" ],
"isBuildCommand": true,
"showOutput": "always",
"problemMatcher": {
"owner": "fsharp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*)\\((\\d+),(\\d+),(\\d+),(\\d+)\\)\\s*:\\s*(warning|error)\\s+(\\w+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"endLine": 4,
"endColumn": 5,
"severity": 6,
"code": 7,
"message": 8
}
}
}
]
} The main problem is it's not playing well with the watch mode :/ The VS Code task watching config requires both start and end patterns but for some reason it's tremendously difficult to get Webpack to output a message after a compilation and all errors/warnings have been printed, at least I haven't managed to do it even using plugins. |
I think custom implementation would have same problem - we need to know when last run ended and we're getting new errors |
@alfonsogarciacaro Can you hack me |
For now I think we can just use "Fable loader sent", but we can also add some state to the fable-loader to try to decide when a watch compilation has started and output a more recognizable pattern. It's a bit tricky because Webpack recommends not to add state to the loaders, but we can think of a way. It's also easy to use a plugin for this. About the end pattern, I've tried to contact Webpack and VS Code teams without success. The problem is Wepback outputs all warnings and errors after the compilation has finished, but we could output messages both in the console and as Webpack warnings. With parallel compilation and Webpack calculating the dependencies it's difficult to know what's exactly the last compiled file, but we could do some hacking (like using a timeout). |
I've played a bit with latest default Fable template ( And it should be possible to provide problem matched for it, will take a look at it tomorrow |
This |
Another problem is fact that Fable also reports normal F# syntax error [which are reported anyway by FSAC] which means that it makes some errors reported multiple times. I wonder if there would be a way of marking Fable specific errors (cannot find replacement, etc) so we can match only on those. |
Hi @Krzysztof-Cieslak! Yes, I don't know exactly when but I also noticed that Webpack is outputting messages at the start and end of recompilation. I swear that was not the case when I reported this issue (I also tried to contact the Webpack developers in the Gitter room and SO but got no answer). I didn't try again because I was busy with Fable 1.1 release. I will do and see if I have the same issues as you. About the FSHARP/FABLE errors, as seen here Fable adds a tag to the error message to identify the origin of the error. So you should be able to filter Fable errors by editing the Regex as follows: (.*)\\((\\d+),(\\d+),(\\d+),(\\d+)\\)\\s*:\\s*(warning|error) FABLE:\\s*(.*)$ Thanks a lot for your help, Krzysztof! We can close this issue if you want. |
Sometimes I'm stupid and blind.
I think I'll leave it open for a moment - we should be able to add problem matcher to Ionide, so people can use |
OK, latest Ionide should include Fable problem matcher. The following
Could we add it to the template, maybe? |
Awesome, I'll do it! 👏 👏 👏 |
@Krzysztof-Cieslak I have a couple of suggestions for the problem matcher: "background": {
"beginsPattern":{
"regexp": "webpack: Compiling"
},
"endsPattern":{
"regexp": "webpack: (Compiled successfully|Failed to compile)"
}
}, Using "Parsing F# project" for the beginsPattern is problematic, first it already changed in latest Fable version to "Parsing <PROJECT_RELATIVE_PATH>" and also it's coming from the Fable daemon itself. Meaning that if you are running webpack and Fable daemon in different terminals you won't see the message. ("webpack: Compiling" doesn't appear in the first compilation, not sure if that's a problem). Also, I would call the problem matcher something like |
Fixed in |
Sorry again! When updating the template to call
Which matches something like: For now I just wrote the problem matcher directly in the template, we can update it later 👍 |
After merging fable-compiler/Fable#806 now Fable can output multiple errors
It'd be very nice if Ionide could mark these errors in the IDE. What would be needed to that? I guess we should add a command to start Fable watching and then a regular expression to match the error messages in the process output. I can try to PR it if you could provide some guidance 👍
The text was updated successfully, but these errors were encountered: