Typically when using Webpack I’ve had better luck with
import * as fabric from 'fabric'
than with using the default import as you currently are. Not sure if it will make a difference with this particular library, but it has fixed similar problems I had with moment.
I’ve tried your suggestion but I got the following error:
Page1 ionViewDidEnter error: Cannot read property 'Canvas' of undefined
On the other hand, I think I’ve found the origin of the problem I mentioned in my first post (but I don’t know how to fix it).
I reviewed the source code and I noticed that all objects are generated without fabric namespace (like __WEBPACK_IMPORTED_MODULE_2_fabric___default.a.Canvas). I’ve run the app in Chrome while having enabled devTools and I checked that if .fabric is included, the object is created.
I don’t know how to properly setup my app, or if I have to make any change in the configuration or if I need to make some changes in the library to get the variables generated including “.fabric” just before the name of the class or any method.
I’ve had the same issue, and able to get the code works by following @matthewhw1989’s solution, but when I try to add image to the canvas, it fails with runtime error: Cannot read property ‘canvas’ of undefined again
any idea to solve this? or any recommendation on library as an alternative to fabric.js? My project will allow user to manipulate images (i.e. add, remove, drag, scale, rotate) in the canvas.
Thanks, I always assume 1) function() {} and 2) () => {} , are all the same but only syntax difference…seems i need to go through arrow function basis first…