Node canvas in rescript

I am using node-canvas, but I encountered a bug. If I try to execute the generated JavaScript, it gives me the following error:

image

However, if I add a require("canvas") at the top of my index.res.js, the error disappears. How can I fix this or automatically add this require("canvas") at the top? I tried using raw, but the compiler puts the replacements above it.

The screenshot seems to be cropped too much? Can you try again? Or post the error message text?

Usually,

%%raw(`require("canvas")`)

should work, but if somehow not we also have the @@directive feature which puts its contents above everything else:

@@directive(`require("canvas")`)
2 Likes