@rescript/core does not support ESM.
When I compile rescript into JavaScript and have Node.js run it, I found that the @rescript/corewas not set as a esmodule. When I manually changed the package.json in the core to type: module, everything worked properly.
(node:46659) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/projects/rescript-message/node_modules/.pnpm/@[email protected][email protected]/node_modules/@rescript/core/src/Core__List.res.js:3
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
You need to set the file extension to .mjs or .res.mjs to opt into ESM for dependent packages. If we were to set "type": "module" in the package.json for Core it would mean ESM would be the default and for CJS support you would need to set the file extension to .cjs. Opting into ESM is probably the best path now, but the docs could probably be clearer around this. Soon this library will be part of the compiler, so it will be easier to keep everything aligned with ESM/CJS.
@jderochervlk Thank you. You've saved me time.
now that core is part of the compiler I guess we can close this one.