Exposing global.HermesInternal
As of RN 0.60, Hermes JS engine can be used on Android. To check whether that engine is enabled, RN provides the global.HermesInternal variable which could/should go in Global (name pending further discussion) along with __DEV__.
However, adding proper bindings is a bit non-sensical. What you have is a variable which has the value undefined when Hermes is disabled and {} when enabled (really!).
So the bindings can be either
module Hermes = { type t; [@bs.val] [@bs.scope "global"] external status: t = "HermesInternal"; external disabled : unit => t = "#undefined" [@bs.obj] external enabled: unit => t = ""; };
using the established way to create an empty object, as used on Js.Dict.empty(), etc. In use, one might have
Hermes.status == Hermes.enabled()
such a function call may be avoided as below
module Hermes = { type t; [@bs.val] external status: t = "HermesInternal"; external disabled : t = "#undefined" [@bs.val] external enabled: ([@bs.as {json|{}|json}] _) => t = "Object.assign"; };
which would be used as
Hermes.status == Hermes.enabled
The latter introduces a bit of noise due to Object.assign on the JS side.
IMO, it's better to simply add a function (not zero-cost, per se but that cost would be incurred at the call site anyway) as below
let (isHermesEnabled: bool) = [%bs.raw {| global.HermesInternal != null |}];
(it really should be compared to undefined, but perhaps following documentation may be more future proof).
Any opinions?