Proposal to solve the heavy-weight bs-platform issue

Hi all,

Based on the user feedback, there are two long standing issues that we want to address:

The problem comes from the fact that the compiler package called bs-platform is quite large, it cost your disk space and used to take a while to install. If you want to provide your library to regular js users, such dependency is transitive, so your consumer has to install such a large package.

Why the compiler package is so large? It contains a native ocaml compiler, prebuilt compilers for 3 main platform, the js files alone is tiny. (We may add more like IDE binaries in the future)

After we solved the installation time (it now only takes 1 or 2 seconds to install), this issue is mitigated and not a problem any more for learning purpose. However, it still cost a lot of disk space even for casual users.

We want to address such issue, I am proposing a way to allow to customize runtime js library and we are going to release a std package which only contain js files, it is opt-in, so it should not break any existing packages.

Suppose you want to choose such light-weight runtime, in the main package, bsconfig.json

"runtime" : "rescript-std"

The generated js files would be something like:

var Pervasives = require("rescript-std/lib/js/pervasives.js");

Note the name is not decided yet, so the compiler package is just a dev dependency under such settings, it is no longer transitive.

Caveats:

  • It’s the user’s responsibility to make sure the std version match the compiler version, we may add such check during the runtime

Feedback is welcome!

13 Likes

That sounds really good!

1 Like

Seems like a great solution - can’t see any downsides. It’s pretty much the same approach for React

It’s the user’s responsibility to make sure the std version match the compiler version, we may add such check during the runtime

You could use peerDependencies for this - like react-dom does for react (package.json)

You also might find yarn workspaces and/or lerna can help with keeping versions in sync and publishing

landed in master, the config is as below (for advanced users):

"external-stdlib" : "@rescript/std"
9 Likes

What you solved was a sticking point for one of our production projects.
We have just tried out the git master version of bs-platform. It works very well! Thank you very much :gift:

2 Likes