You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a typical ReScript application, you'd ship a package with an npm dependency to `bs-platform` (`rescript`), which means downloading several tens of megabytes of executables.
13
13
14
-
Whenever a ReScript developer wants to publish a package just for pure JS consumption / lean container deployment, they would be required to use a bundler to bundle up their library / stdlib code, which is not ideal.
14
+
Whenever you'd want to publish a package just for pure JS consumption / lean container deployment (package MB sizes), you'd be required to use a bundler to bundle up all the required stdlib runtime modules with your package source, which is not ideal.
15
15
16
-
To fix this problem, you can just depend on our pre-compiled stdlib JS files, published as a separate npm package called [`@rescript/std`](https://www.npmjs.com/package/@rescript/std). Each new ReScript release has a matching `@rescript/std` release for runtime compatibility.
16
+
To fix this problem, you can configure your ReScript project to use our external stdlib package ([`@rescript/std`](https://www.npmjs.com/package/@rescript/std)) and make `bs-platform` a dev-only dependency.
17
+
18
+
Every ReScript package release has a matching `@rescript/std` release for runtime compatibility.
19
+
20
+
**Important:** To prevent unnecessary complications, only use this feature when...
21
+
- You want to ship a library for JS / TS consumers without making them depend on `bs-platform`
22
+
- You can't depend on `bs-platform` due to toolchain size (docker containers, low-storage deployment devices, etc)
17
23
18
24
## Configuration
19
25
20
-
For example, let's assume we want to build a JS package that is built on ReScript 9.0. We'd first install our `@rescript/std` package:
26
+
For example, let's assume we want to build a JS-only package that is built with ReScript 9.0. First, we would set up our dependencies like this:
The JavaScript output above was compiled with an `es6` target, but will also work with `commonjs`.
66
+
**Important:** When using the `external-stdlib` configuration, always make sure the version numbers of `bs-platform` and `@rescript/std` match in your `package.json` file. Otherwise you might run into runtime problems due to mismatching stdlib behavior.
61
67
62
-
**Important:** When using this option, you need to make sure that the version number of `bs-platform` and `@rescript/std` matches with the same version number in your `package.json` file, otherwise you'll eventually run into runtime problems due to mismatching stdlib behavior!
63
-
64
-
To prevent unnecessary complications, only use this feature when...
65
-
- You want to ship a library for JS / TS consumers without making them depend on `bs-platform`
66
-
- You can't depend on `bs-platform` due to toolchain size (docker containers, low-storage deployment devices, etc)
0 commit comments