Search code examples
ocamlreasonbucklescript

How are BuckleScript library names generated?


Where do libraries get the name we use in for example open BsReactNavigation?

For example, there is no module in bs-react-navigation named BsReactNavigation?

So how does reason know what we are referring to when we say open BsReactNavigation in a module?


Solution

  • The namespace module is generated when the namespace property in bsconfig.json is set to true. It is generated based on the name field of bsconfig.json, converted to PascalCase. That is, the first letter is capitalized, the letter following every dash is capitalized and the dashes are removed. E.g. my-wacky-library becomes MyWackyLibrary.

    Some not so good documentation exists (which claims the feature is almost mandatory. It is not. While the reasoning is good, the feature is not, so most people use either just a single module or manual namespacing instead)