sbt-js-engine icon indicating copy to clipboard operation
sbt-js-engine copied to clipboard

SbtJsTask.executeJs should add flag to interpret stdout from process as JSON unconditionally

Open jclyons opened this issue 9 years ago • 1 comments

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.

jclyons avatar Dec 02 '15 20:12 jclyons

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?

benmccann avatar Mar 11 '17 05:03 benmccann