Description
Right now, jsoo-react calls require
to bring react.js libraries:
Lines 9 to 11 in 6f9eba0
This means that users of the library are forced to use some JavaScript bundler like Webpack to resolve these requires with the actual library code.
But we could instead vendor a version of React.js and connect OCaml bindings with the JavaScript library objects internally, without exposing all this connection details to end users. This is what some OCaml projects have been doing, like virtual_dom, that uses browserify to bundle the JavaScript library.
Upsides of vendoring:
- No need to use Webpack or any bundler on client
- More controlled environment (less chances of things going wrong as less parts required)
- Simpler setup, templates, etc
- Faster iteration loops
Downsides:
- Vendoring would require to put React.js entry points (library objects) in some field under global
jsoo_global_object
with all the downsides that relying on globals bring. - It also means that there is less flexibility for users to decide which version of React.js they want to use. E.g. right now jsoo-react supports v16, but some user could start using v17 for some reason just by updating their
package.json
.
I guess it all comes down to how "close" to JavaScript ecosystem a project is: for projects leveraging a lot of JS related tooling, using Webpack or other bundler is not a pain (actually helps). But for projects leaning more on OCaml side, with very few JavaScript dependencies, adding bundler is actually overkill.
Any other things? What do you think?