This is the JS output that I wanted to create.
const fabric = require("fabric").fabric;
let canvas = new fabric.Canvas("c");
however I can’t figure out the proper way to do the bindings.
module Canvas = {
type t
@bs.module("fabric") external fabric: fabric = "fabric"
@bs.new @bs.send external makeCanvas: (fabric, string) => t = "Canvas"
}
This doesn’t work because I can’t use @bs.new with @bs.send
I could use @bs.scope("fabric")
but I don’t think that is the right way to do it because looking at output, fabric
is the result of require
.
@bs.new @bs.scope("fabric") external makeCanvas: string => t = "Canvas"
fabric
will be undefined here.