rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.67k stars 444 forks source link

Split rescript npm package into multiple subpackages #6183

Open cknitt opened 1 year ago

cknitt commented 1 year ago

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:

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:

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:

cometkim commented 4 months ago

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