sbt-js-engine
sbt-js-engine copied to clipboard
SbtJsTask.executeJs should add flag to interpret stdout from process as JSON unconditionally
In the comment for executeJs it is mentioned that if an escape character is emitted from the JS task to stdout, it will parse what immediately follows as JSON, which is great. However, many existing node modules (in my case, webpack) have a flag (like --json ) to toggle JSON output vs human readable output. These flags don't by default emit the character SBT JS Engine is looking for. Could you add a flag to SbtJsTask.executeJs to simply attempt to parse whatever the output of the script is in JSON? Could the parser also tolerate whatever whitespace / line-break settings are used to produce the JSON output?
My current workaround for this is to essentially wrap the Webpack CLI with another script which will emit the proper character and also remove all whitespace from the output of Webpack.
That sounds reasonable. You mentioned webpack. I just Googled and saw two sbt-webpack plugins. Do you happen to be using either of them or how are you calling webpack?