Compiler ยท Jun 26, 2019

Announcing BuckleScript 5.0.5 and 6.0.2

Hongbo Zhang
Compiler Team

bs-platform 5.0.5 (for OCaml 4.02.3) and 6.0.2 (for OCaml 4.06.1) is released.

A detailed list of changes is available here

It has some critical bug fixes that we suggest users to upgrade.

Some feature enhancement is described as below:

User land C stubs polyfill

Previously, for existing OCaml libraries which rely on some C primitives, it has to be patched in source level. In this release, user can provide such support independently without patching the source code.

Suppose you have a Reason module which relies on an C primitive as below:

external ff : (int,int) => int = "caml_fancy_add" ;

caml_fancy_add is a C function for native code, now we can provide this support in a js files, what user needs to do is adding caml_fancy_add to a global variable like this

/** * @param {int} x * @param {int} y * @returns {int} * */ require('bs-platform/lib/js/caml_external_polyfill.js').register('caml_fancy_add',function(x,y){ return + ((""+x ) + (""+y)) })

Note this is an experimental feature that we don't suggest users to use it extensively, it is provided as an escape hatch. We are also expecting feedback to see how we could improve it, so there might be some backward incompatible changes.

A new warning number 105

Previously, there are some scenarios that the Js function name is inferred during the interop.

For example

external f : int -> int = "" [@@bs.val]
[@bs.val] external f : int => int = ""

Here the JS function name is inferred as f which is the same as OCaml function name.

Such ffi declaration is fragile to refactoring when changing names of f, it will also change the name of js function name which is probably not what user expected.

105 warning number is to help warn against this case (turned on by default).

Simplified debugger mode

Previously, user has to add -bs-g flag to bsc-flags in bsconfig.json and add one line code to the main module. Such code change is no longer needed, only the flag is needed.

Build performance improvement

We improved the build performance and simplified the design of the build significantly in this release, we will have a separate post about it.

Happy hacking!

This article was originally released on
Want to read more?
Back to Overview