RFC - Universal monorepo for Rescript Bindings?

There has to be a better way to host and manage all the bindings for different NPM packages.

What if we made a monorepo where each binding is its own module similar to how Typescript handles their @types repo?

We are constantly spinning up new bindings on a weekly basis, but creating a whole new repo and publishing to NPM seems like overkill.

Are there any other ideas out there to improve the distribution and management of Bindings?

3 Likes

No, a monorepo like definitelyTyped doesn’t work with ReScript. TypeScript is an extra layer on top of JS, and ReScript only compiles to a subset of JS and due to its stricter type system it’s hard (or even impossible) to generalize bindings that work for everyone. We need a system that let ppl copy / paste original bindings and modify them to their use-cases if needed.

The ReScript package index has a way to curate non-npm resources. You could publish urls to single Github gists with .res and .resi files, or even point to a single file within a repository. Oftentimes ppl are publishing incomplete bindings, so this approach would help with a more lightweight distribution process that doesn’t involve publishing to npm.

Users should be encouraged to read and modify existing bindings to their use-cases, if needed (e.g. putting files found on the index in their bindings/ directory). Updating those bindings shouldn’t be too hard either, even if modified, since you’d just do a git diff and downstream the changes in the future.

4 Likes

Exactly, this is why i opened this issue

2 Likes

It would be nice to have some notification mechanism when bindings that one has copied have changed. I think this leads back to preferring npm over gists.

My ideal would be to upstream best effort general bindings as a module within the library being bound to.

Leaving this here, FFR:

This seems to explain some similar approach, to auto discover if the signature of 3rd party packages have changed. Since otherwise, there is no automatic way to know whether your external ReScript bindings to 3rd party packages are still correct / in-sync.

https://www.benadamstyles.com/blog/rescript-type-safe-bindings/

2 Likes