PPX packaging with postinstall

I’d like to talk about how the ppx is packaged and to hear users’ experiences. Currently, most ppx is built to executable binary and packaged binaries for platforms(darwin, windows, linux, etc), and published to npm. One secret ingredient is postinstall script which is running after npm install. This script would pick the right executable binary for the platform, then rename and(or) remove others.

The problem is here. If one uses the yarn berry without node_modules, one might encounter the build error in CI which are persisting build cache. Because the right binary is renamed or removed in the build cache. In my case, I made a patch-comit with yarn then changed all the renameSync parts to copyFileSync in the postinstall script. I know there would be unnecessary storage usage, but it is a simple solution for me.

How do you handle this problem? Worth considering how to package the ppx modules for the next node package manager?

2 Likes