Monorepo issues with parallel builds of @rescript/core files

Hello everyone !

I have a monorepo for tilia and @tilia/react and both these projects build @rescript/core files.

My issue is that building these two projects in parallel using pnpm leads to this problem:

tilia prebuild: rescript: [75/217] src/Core__WeakMap.cmj
tilia prebuild: FAILED: src/Core__WeakMap.cmj
tilia prebuild: Fatal error: exception End_of_file
react prebuild: rescript: [71/217] src/Core__WeakMap.cmj

The tilia and react builds touch the same @rescript/core lib folder inside the root node_modules at the same time.

I could remove the parallel build in the monorepo but I am wondering if someone knows of a better idea (like @rescript/core prebuild) ?

Are you using rewatch for this?

1 Like

No, I am still using ReScript v11 and haven’t setup rewatch.

I fixed the issue by creating a prebuild step in the root package.json to run rescript in one of the packages. This compiles @rescript/core once and prevents the race condition with parallel build.

Built artifact:

  • root/foobar/node_modules/@rescript/core which is a symlink to
  • root/node_modules/.pnpm/@rescript+core@1.6.1_rescript@11.1.4/@rescript/core

My CI build is green again.

Okay, might be worth revisiting this once you can upgrade to v12.
This use-case should be covered by it.

3 Likes