I noticed at the top of the generated js file:
import * as Js_list from "rescript/lib/es6/js_list.js";
This leads to an error in the browser:
Uncaught TypeError: Failed to resolve module specifier "rescript/lib/es6/js_list.js". Relative references must start with either "/", "./", or "../".
rescript/lib/es6/js_list.js is in
node_modules, but bare import specifiers aren’t supported in browsers, according to this stackoverflow answer
Should I avoid using Js_list?
ReScript compiles to file paths that are only suitable for local development in a NodeJS environment, so I’d recommend a development server / bundler that understands ES6 modules. E.g. ViteJS / webpack are designed to bundle webapps that can be deployed for browser consumption.
You can also check out esbuild & rollup for straightforward bundling.
Here’s a repo that show-cases bundling with esbuild: GitHub - bobzhang/rescript-repack-demo: A demo to show how to package high quality ReScript libraries for JS users
es6-global what you would need to avoid bundling? It even says so in the docs:
"module": "es6-global" resolves
node_modules using relative paths. Good for development-time usage of ES6 in conjunction with browsers like Safari and Firefox that support ES6 modules today. No more dev-time bundling!
Either that, or a bundler as you said
Yeah, unfortunately there’s so many problems with bundler less setups that I don’t even want to recommend it here…
What should people beware of (in the context of playing around or prototyping)?