rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Split rescript npm package into multiple subpackages

Open cknitt opened this issue 2 years ago • 2 comments

This one is probably for v12 and beyond.

1.) In #6133, the suggestion was made to provide separate npm packages for compiler binaries for each platform, add them as optional dependencies to the rescript package and leverage built-in functionality of the package manager to automatically install only the matching binaries for the current platform similar to how esbuild does it. This would yield the following packages for the compiler binaries:

  • @rescript/darwin-arm64
  • @rescript/darwin-x64
  • @rescript/linux-arm64
  • @rescript/linux-x64
  • @rescript/win32-x64

This change would reduce the amount of disk space used by npm install rescript.

2.) In addition, the runtime / standard libraries could also be extracted from the main rescript package into separate packages:

  • @rescript/runtime (Pervasives, Jsx, Caml_*, etc.)
  • @rescript/core (already a separate package now)
  • @rescript/belt
  • @rescript/js-compat (for the existing Js namespace)
  • ~~@rescript/ocaml-compat (for the existing OCaml standard library modules)~~

Some of these could be installed by default as dependencies of the rescript packages and others could be made optional.

The cmi/cmj caches could then be built only for the relevant installed packages on the first project build, instead of during CI build.

Advantages:

  • Being able to maintain some of these in separate repos and at a separate release cycle from the compiler repo.
  • Dependencies would always built with the projects compiler settings (uncurried true/false).
  • Further reducing the size of a ReScript installation when more compat packages are made optional.
  • Speeding up CI build by having to build and package less stuff.

cknitt avatar Apr 20 '23 17:04 cknitt

Note that this technique only works for optionalDependencies

And probably wouldn't work for bin with some package managers as they don't allow installation from transitive dependency See https://gist.github.com/cometkim/eb2842d67b40e583e4886e9b897a6af0

cometkim avatar May 25 '24 10:05 cometkim

Per-platform binary packages implemented in #7395 for v12.

Splitting up runtime/stdlib will be done in a future version.

cknitt avatar May 05 '25 08:05 cknitt