I am using webpack and babel in my development tool chain; when running the following code:
import * as fabric from 'fabric';
var canvas = new fabric.Canvas('canvas');
I get the following error:
_fabric2.default.Canvas is not a constructor
Whereas the same code works fine if I use require('fabric');
instead of
import
.
I tried different ways of calling import
but none of them worked.
My linting tool complains of the undefined fabric
variable, so I would like to have it properly defined. Surprisingly (for me), this code
doesn't work neither:
var fabric = require("fabric");
I get the following error in this case:
fabric.Canvas is not a constructor
What am I doing wrong ?