ReScript v12 js-post-build confusion

I’m trying to upgrade our massive production codebase to v12, so please expect several new topics :sweat_smile:

I just got this in the compiler terminal output:

The field ‘js-post-build’ found in the package config of ‘pace’ is not supported by ReScript 12’s new build system.

Yet, the docs still have it.

I really hope it’s not gone away because if it has, we will be stuck on v11 probably for ever :sob:

IIRC we haven’t said we aren’t going to have it. I just think it hasn’t been built yet for Rewatch.

Ah ok, that’s a relief. Thanks. The docs/blog read like the new build system is “done”.

I’ll try using the legacy build system for now.

See https://github.com/rescript-lang/rescript/blob/master/rewatch/CompilerConfigurationSpec.md#rescript-build-configuration

Most of it is there, could you give an example of what kind of command you are using right now?

Of course, this is our config in rescript.json:

"js-post-build": {
  "cmd": "./tools/gen.sh"
},

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.

  "ppx-flags": ["@greenlabs/ppx-spice/ppx"]

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.