It seems the standard best practice for reason packages is to include bs-platform in the devDependencies of package.json (e.g. https://github.com/reasonml/reason-react/blob/master/package.json#L25). However, my current JavaScript build tool (brunch) does not include any dependencies in the final JavaScript build unless they are listed as dependencies or peerDependencies in each specific project that calls the bs-platform runtime code. The I end up with errors in the browser console when trying to run the built JavaScript:
Uncaught Error: Cannot find module 'bs-platform/lib/js/caml_builtin_exceptions.js' from 'reason-react/src/ReactDOMRe.js'
My two current hacks to get the system to work are:
- Make a call to the specific
bs-platformJS file in my code that does includebs-platformindependencies. - Manually modify the
package.jsonin the reason packages innode_modulesto includebs-platforminpeerDependencies.
My question is: if the final runtime of the built JavaScript requires JS scripts from bs-platform, why would bs-platform not be listed in package.json under dependencies or peerDependencies? Is there a better way to ensure that the bs-platform runtime JS is included in the build?