Should I include or exclude *.bs.js files in git?


This is a pretty common question in Discord chat and I hate to answer it everytime so let’s me type it once and refer to it later.

Should I?


If you’re in the process in introducing ReasonML/Bucklescript into an existing Javascript/Typescript/Flow codebase and you don’t want to change your build process. Everyone who’s not working with ReasonML shouldn’t notice a thing.

The downside of this approach is git conflicts. It’s a real pain.


  • You’re starting a project from scratch with ReasonML.
  • You let everyone working on the project know about it. They must install bs-platform for compiling .re files to *.bs.js

If I’m releasing a library for ReasonML consumers, should I?

Exclude it please.

cc @chenglou Please make this a wiki so others could edit it.


In my company I just added one step to build process - ‘npm run build-reason’. It builds all *.bs.js files, which are later imported by ‘normal’ TS/JS application, without even knowing they come from ReasonML code. This build step takes a second, so no one noticed it.

Also, if you exclude bs.js from git, and add a tiny build step ‘npm run build-reason’, you will never forget to commit *.re files together with updated *.bs.js files! In other cases you might update *.re files but forget to build and commit *.bs.js files :frowning:


This is what I’m talking about in include section. and IHMO, the best time to run the script is on git-hooks. This ensures *.bs.js files are always in sync with *.re code.

husky is an amazing tool for introducing git hooks into your codebase


Made into a wiki. When this is mature, let’s upstream it into or something. Such thing should be part of the official docs!