Why bs-platform is devDependency instead of peerDependency?

bsb

#1

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:

  1. Make a call to the specific bs-platform JS file in my code that does include bs-platform in dependencies.
  2. Manually modify the package.json in the reason packages in node_modules to include bs-platform in peerDependencies.

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?


#2

Bucklescript isn’t designed to be deployed as a dependency at the moment. If you do, you’ll be carrying around the entire compiler. The design at the moment is for apps where you bundle the developed code and publish that.

I’m really hoping we one day see a library deployment mode, where the lib/* folders are available in a separate “stdlib” NPM package for library authors to depend on. It’s the last remaining feature that is holding me back from using reasonml more at work. There’s been discussion about this for nearly 12 months: