reasonml / ReasonNativeProject

Reason native compilation starter project
MIT License
203 stars 45 forks source link

Make it so ExampleProject can be shared as a dependency. #6

Open jordwalke opened 7 years ago

jordwalke commented 7 years ago

ExampleProject is a great start for quickly building an app that depends on libraries. It works well with any ocamlfind libraries that are ported to npm packages. But the first question someone asks is: "Now, that I wrote some library code in my ExampleProject fork, I want to share it and turn it into its own package that people can depend on".

background: Ocamlfind is the currently standard "build system interop" which means that if you use the ocamlfind convention, anyone can use your library easily. So if we make ExampleProject generate ocamlfind META files, etc then this accomplishes our goal of making ExampleProject a library that you can publish on npm and then depend on.

For this issue, I propose that we explore using the build system called solvuu-build, which is like a slimmed down ocamlbuild/rebuild that comes with rules to generate that ocamlfind META file and .merlin. We use rebuild for ExampleProject which is also a customized version of ocamlbuild (customized by us) so it could be quite easy to port ExampleProject over to solvuu-build.

Basic steps to get started:

  1. Try out solvuu-build and see if it's really easy to make a library with three or four files. (The goal is just dirt simple, sharable, small projects).
  2. Make it build ExampleProject . If #1 was easy, then it should be very easy to make it work on ExampleProject.
  3. Then enhance ExampleProject's package.json so that the postinstall script doesn't just build, but also does ocamlfind install, which would use the autogenerated META file (that was auto-generated by solvuu-build) to install into our npm sandbox automatically. If you prefix the build command with eval $(dependencyEnv) && nopam then running ocamlfind install should "just work" because the nopam command prepares a place for any package to install their ocamlfind package.

If we can get a good story for making/sharing libraries easily, we can be working on pjc in parallel. Once pjc is done you could still use this build system in your projects and, pjc will work well with it because pjc works with any build system that plays well with ocamlfind.

pjc is a workflow for building many interdependent packages/libraries that all need to know about each other. This solvuu-build build system is just one build system among many other cooperating via pjc. One good thing is we don't need pjc to be done to use solvuu-buildin the example project.

If it turns out solvuu-build doesn't work out, that's fine too, but we should create some basic way to turn ExampleProject into an ocamlfind library.