And the gen.sh file expects a single argument to be passed to it which is the path to the JS file that was generated by the rescript compiler. This is a relative path in the ReScript v11 build system. It’s impossible for me to know to what the path is relative – but if I had to guess, I’d say it’s relative to node_modules/rescript/. All I know is that it starts with ../../.
We use this script to compile a Flow types file from the @genType-generated TypeScript file. This is crucial for us to move forward with our rescript codebase without breaking important business features in our legacy flowtyped JS codebase.
I’ve run into a similar problem with that path resolution and try_package_path when testing ppx updates with relative paths in “ppx-flags”:
"ppx-flags": ["../ppx"]
try_package_path: upward traversal did not find 'spice-ppx-test/../ppx' starting at...
I think it’s because it’s searching for spice-ppx-test, the name field from rescript.json, instead of the actual directory name?
I needed to use like "@greenlabs/ppx-spice": "workspace:../" in package.json so that @greenlabs/ppx-spice gets symlinked and use this instead in rescript.json.
This has nothing to do with “ppx-flags”, “js-post-build” is simply not there.
Please create a GitHub issue for whatever problem you have with ppx-flag.
One twist: it would be easier for us if the ${file} argument were an absolute path. That makes more sense in a monorepo, since you might be building from the repo root or from a package.
This will behave differently from our old build system. That said, it’s something I think we’d change anyway for v13.
Would this block anyone? Most scripts can be adapted to handle absolute paths, but that would be on users.
Yes the path is now absolute but it points to the file under lib/bs, before I think it was relative to the project root.
The script you pass to cmd used to be run with a pwd that I think was node_modules/rescript, now it’s run with the expected pwd of the project root.
It totally swallows console/stdin streams. echo from the script or console.log() from child node processes are swallowed. I had to echo ... >> ./tmp.txt to do some logging.
These are not major issues but might trip people up and would be worth documenting if possible.
In general, MASSIVE THANKS for getting this done, it has allowed us to move fully back to the bleeding edge of ReScript and I hope to contribute bug reports and suggestions etc going forward.
Yes the path is now absolute but it points to the file under lib/bs, before I think it was relative to the project root.
Yeah, the path under the project makes more sense.
The script you pass to cmd used to be run with a pwd that I think was node_modules/rescript, now it’s run with the expected pwd of the project root.
The pwd of the rescript execution makes most sense to me here.
It totally swallows console/stdin streams. echo from the script or console.log() from child node processes are swallowed. I had to echo ... >> ./tmp.txt to do some logging.
Good point, this is annoying, we should pipe the stdout/stderr to the current rescript process.
These points are worth revisiting in v13. Will take a look at this eventually.