Following along in my journey of learning ReScript, I decided to rewrite a little helper I have written in plain JS for my blog and make a ReScript module out of it.
Nothing too fancy, just a function that given a text then it counts out the number of words and estimates the reading time.
So far so good, migrating to ReScript also allowed me to find some bugs here and there (mostly edge cases). Now I thought it would be nice to publish it as a JavaScript/TypeScript package and make it available for non-ReScript users.
The only problem I’m having is that, as you can see from the generated JavaScript file, var Caml_int32 = require("rescript/lib/js/caml_int32.js"); is included as an external resource and not bundled within the output file. This is not really convenient as it requires the user to have ReScript installed nonetheless; also I would like to output it as UMD as well as CJS and ESM. Is that possible without a bundler? If not, do you have anything light to suggest? I would like to not use webpack for such small project but I’m kinda outdated on this topic
As a side question, do you have any testing library to suggest? Would like to add some tests both for robustness and learning purposes. I read there was a plan of making an official testing library but didn’t managed to find that much.
If you don’t use any third-party dependencies ReScript has a standalone standard library which can be added as a dependency.
This is a topic dear to me[1], and I’d love to see some solution where you could easily create more complex libraries or applications without the need for specialised bundling.
So, I did as suggested here and as pointed out by @lessp in previous comments.
I couldn’t make microbundle work as I wanted so I just switched to rollup and now it works like a charm.
I would probably write a guide about it, because why not!