From 1175907bdf0e42a49c511b7ccaa32a1ddd155e78 Mon Sep 17 00:00:00 2001 From: Tristan de Cacqueray Date: Tue, 14 May 2024 14:40:16 +0000 Subject: [PATCH] Update build-external-stdlib.mdx Fixes: https://github.com/rescript-lang/rescript-compiler/issues/6754 --- .../manual/latest/build-external-stdlib.mdx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pages/docs/manual/latest/build-external-stdlib.mdx b/pages/docs/manual/latest/build-external-stdlib.mdx index ae796932c..2f29e4b7a 100644 --- a/pages/docs/manual/latest/build-external-stdlib.mdx +++ b/pages/docs/manual/latest/build-external-stdlib.mdx @@ -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 rescript@11.0.1 --save-dev +npm install rescript@11.0.1 npm install @rescript/std@11.0.1 ``` +> 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 @@ -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: