Skip to content

IDE integration #222

Closed
Closed
@use-strict

Description

@use-strict

My goal is to have seamless integration with insert_favorite_IDE_here while developing. This means having the compilation errors exposed and mapped to file/line/col in the IDE. I have achieved this to some degree, at the cost of having to hack the dev server, which is less than ideal to say the least.

I will explain what I tried and hope you can help me find a solution that would fit with the existing use cases, so I can get rid of this hack.

First attempt:
  • Use webpack Node.JS API with 'watch' option (performance is v. bad without watch)
  • Get the errors after each compile, format them nicely and spit them out to the console.
  • Add labels for compilation start/end events.

This worked like a charm with VSCode, without having to hack webpack or webpack-dev-server in any way. However, this means I cannot benefit from the dev-server features. Also, this doesn't work with PHPStorm/WebStorm, because its file watchers are supposed to execute on every save and it can't keep a single instance running in the background.

Second attempt:
  • Use dev-server to do the build.
  • Add another HTTP route that spits out compilation errors (for the last compilation). This should work because the request is delayed until there is no pending compilation.
  • Extract useful info about the errors and output them as JSON. Have another "client" script that connects from CLI over HTTP and formats them for the IDE to consume. This script is called from PHPStorm/other IDE.
Problems:
  • Knowing what exactly to collect from the error objects. For instance, the location (line/col) is found differently per type of error. I need to make sure that every error has a file path, line, column and message.
  • dev-server uses the middleware which keeps bundles in memory. This should be ideal, but due to some limitations (current environment setup complexity, legacy app), I have to rely on serving the files from disk (at least for now). Something like this was already proposed in the middleware thread, but it was rejected at some point, probably because it didn't seem a valid use case.

I'm linking the commit which contains the changes that I made to the dev-server. This doesn't include the actual formatting of the errors or the client script.
use-strict@3f58f60

I found no clean way of exporting/serializing the errors (which are also circular objects) other than nitpicking each bit of information.

What are your thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions