Following the recommendations on this page Interop with JS Build Systems
We also recommend that you initially check in those ReScript-generated JS files, as this workflow means:
- You can introduce ReScript silently into your codebase without disturbing existing infra.
I tried taking this approach in my project and commited my generated rescript files with the .res.js
extension, but ran into an issue because @rescript/core
is published with just .mjs
.
Running a build locally remakes the files as .res.js inside of node_modules, but when I push my code to CI those don’t exist, and since the file ext is hardcoded in the output src this leads to a “module not found”:
import * as Core__Option from "@rescript/core/src/Core__Option.res.js";
I can update my config to use .mjs
, but now I’ll run into an issue where rescript-react is using .bs.js
For the no-CI approach to work, I think the rescript compiler should use the extension in each package’s rescript.json