Closed jchavarri closed 3 years ago
Thanks a lot for looking into it @jchavarri!
That completely removes the overhead I was mentioning in the issue, so exactly what I thought 🎉
For reference, here's a dune configuration I tried that uses both the Webpack setup and the Jsoo-only setup:
(executable
(name index)
(modules (:standard \ index_dev))
(modes js)
(libraries jsoo-react.lib my_lib)
(preprocess
(pps jsoo-react.ppx)))
(executable
(name index_dev)
(modules (:standard \ index))
(modes js)
(js_of_ocaml
(javascript_files react.js react-dom.js))
(libraries jsoo-react.lib my_lib)
(preprocess
(pps jsoo-react.ppx)))
thanks for the examples @tmattio ! I added some instructions to set up the library with or without Webpack in the readme: https://github.com/jchavarri/jsoo-react/blob/bdecac1d9685afdc705fbd2c2c9d9e49a84cda48/README.md#existing-project
Gonna merge this now, but if you think there are better ways to solve this, please let me know :)
Originated by #47.
There is no good reason why the
require()
calls are part of the library dune files. Consumers can decide how React will be provided, as long as it is on the globals that are expected to be read.Webpack
Can add
(javascript_files react.js react-dom.js)
to their applicationdune
files, and thenrequire
inside (orimport
, whatever they choose).UMD
Can add
<script>
tags before loading the js file generated by jsoo (what this PR shows)@tmattio Does this go in the right direction? If yes, I think I could just remove the
__LIB__
prefixes (which never convinced me tbh 😄 ) so that there's no need to alias anything.