Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mjs note for external lib users #861

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pages/docs/manual/latest/build-external-stdlib.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ To solve that, we now publish our runtime as a standalone package at [`@rescript
Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this:

```sh
npm install [email protected] --save-dev
npm install [email protected]
npm install @rescript/[email protected]
```

> Note: When ReScript 12 releases, it will ship with the ReScript Core standard library and `rescript` can be installed as a `--dev` dependency again.

Then add this to `rescript.json`:

```json
Expand All @@ -37,6 +39,21 @@ Then add this to `rescript.json`:
}
```

Make sure you are using commonjs because only `.mjs` files are published with ReScript Core:

```json
{
// ...
"package-specs": [
{
"module": "esmodule",
"in-source": true
}
],
"suffix": ".mjs",
}
```

Now the compiled JS code will import using the path defined by `external-stdlib`. Check the JS output tab:

<CodeTab labels={["ReScript", "JS output"]}>
Expand Down