External Stdlib
Since 9.0
Your ReScript project depends on the rescript
package as a devDependency
, which includes our compiler, build system and runtime like Belt
. However, you had to move it to dependency
in package.json
if you publish your code:
To Docker or other low-storage deployment devices.
For pure JS/TS consumers who probably won't install
rescript
in their own project.
In these cases, the size or mere presence of rescript
can be troublesome, since it includes not just our necessary runtime like Belt
, but also our compiler and build system.
To solve that, we now publish our runtime as a standalone package at @rescript/std
, whose versions mirror rescript
's. Now you can keep rescript
as a devDependency
and have only @rescript/std
as your runtime dependency
.
This is an advanced feature. Please only use it in the aforementioned scenarios. If you already use a JS bundler with dead code elimination, you might not need this feature.
Configuration
Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this:
SHnpm install rescript@11.0.1 --save-dev npm install @rescript/std@11.0.1
Then add this to rescript.json
:
JSON{
// ...
"external-stdlib" : "@rescript/std"
}
Now the compiled JS code will import using the path defined by external-stdlib
. Check the JS output tab:
Make sure the version number of rescript
and @rescript/std
match in your package.json
to avoid running into runtime issues due to mismatching stdlib assumptions.