Publish ReScript for ReScript

I’ve successfully published multiple libraries written in ReScript to npm for use by JavaScript developers.

… however, I’m unsure how to publish ReScript for use by ReScript developers. I’m taking a look at TinyColor: https://github.com/mikaello/rescript-tinycolor and ReScript test: https://github.com/bloodyowl/rescript-test

The test one seems to make sense:

  1. put your code in src
  2. your main module is Capitalized
  3. others can then run open Capitalized and it’ll work for them if they npm install it and put your package.json name in bsconfig.json

… is that it? I ask because somehow TinyColor is different and I get all insecure again. They have open RescriptTinycolor, but, shouldn’t it just be open TinyColor?

Is there anything else I need to do? Both bsconfig.json’s looks basic.

Dude, the compiler litterly told me what I did wrong; the bsconfig.json had like “rescript-project-template” and the ReScript VSCode plugin is like “dude, remove that $schema thing, it’s not allowed”. Boom, works. I mean, I have shadowing conflicts, but whatever, it works.

… why do I even need this dang forum, ReScript is just awesome and works and tells you how to fix things if it breaks!

Holy shit aannnnddd I get code hints for my module? This is ballin’.

1 Like

Note that if your package have multiple modules, you can have a look to the bsconfig “namespace” option (true or a custom string). This allows you to “open” the package and allow to safely avoid module conflict (this is what rescript-tinycolor is using).

Eg for rescript-react-native that is opened as ReactNative:

  • there is no RescriptReactNative module
  • there is no ReacNative module
  • you can open the package with ReactNative thanks to this bsconfig

If true the namespace will be the same as the package name.

Nice!

The $schema was needed before but not anymore. Thanks for the reminder. I’ve removed it.

Aaaand that’s what the forum is for =)

1 Like

Rad, thank you very much, y’all! I’ll test out namespace.