Okay, in truth that subject was clickbait. We’re not toast. But we do have a potential huge load of work in front of us.
The Problem
Day One has 105k lines of Rescript code that runs its backend that we’ve written over the last few years. And we have a boat load of types that use GitHub - reasonml-labs/decco: Bucklescript PPX which generates JSON (de)serializers for user-defined types to generate JSON encoders and decoders to check and transform JSON into types safely.
When we started using that package it seemed like a pretty safe bet. But that was before Rescript came and the native/js nature of Reason was put on the backburner.
Nowadays I regularly encounter stale build issues that always involve decco. And unsurprisingly, upgrading to Rescript 11 brings breaking changes with that package.
I tried diving into the decco repo since I’ve contributed before. But I was never very familiar with the native OCaml ecosystem, and on top of it Decco uses esy
a build system that I think has also been put on the backburner with the old Reason syntax. I can’t get the ppx to build.
I’m also thinking that I don’t want the PPX to build. Over the years it has become clear that PPXs in Rescript are not the happy path. I think that if we insist on keeping Decco around, we’re going to encounter more trouble than we save by using it.
On Getting Out
So, we have tons of @decco
decorations all through our code on both type definitions and their fields. Does anyone know if there’s any way to use the rescript compiler in a way that will run the ppx, and then spit the source code that was produced back out?
If that’s possible we can keep relying on the Decco rescript module, but remove the use of its PPX, which I think would be acceptable for us.
Otherwise, I think we’re going to have to either re-write all of the encoder/decoders by hand, or write some very complex code parsing/generation script.