You might make this work by using a temporary file.
Using latest v12 alpha you can get the compiler arguments from rewatch
npx rewatch --rescript-version 12.0.0-alpha.13 --compiler-args /Users/nojaf/Projects/my-project/src/Context.res
{
"compiler_args": [
"-bs-ns",
"Kaplay",
"-I",
"../ocaml",
"-uncurried",
"-bs-package-name",
"@nojaf/project-name",
"-bs-package-output",
"esmodule:src:.res.mjs",
"-bs-v",
"12.0.0-alpha.13",
"src/Context.ast"
],
"parser_args": [
"-bs-v",
"12.0.0-alpha.13",
"-uncurried",
"-absname",
"-bs-ast",
"-o",
"src/Context.ast",
"../../src/Context.res"
]
}
Running npx bsc with the sets of arguments should create everything.
(Using your lib/bs as cwd)
And you can read your temp file from disk.
That being said, I’m not sure how you would enable tooling support.
With some compiler changes, it might be possible to get the final output in stdout instead of disk.
That would be interesting to have in general.