I have an Angular 4 app using Snap SVG and I get the dredded webpack problem \"Cannot read property \'on\' of undefined\".
Using snapsvg-cjs seems to be the simplest w
Ok, I see what I did now. Using snapsvg-cjs just works. I get typescript support.
I had this same issue. For me, I installed snapsvg-cjs
and @types/snapsvg
, then imported the library as so:
import "snapsvg-cjs"
You only need to import it this way once (maybe in a main.ts
file or something)
Then in the file where you want to use the library, import the types as so:
import * as SNAPSVG_TYPE from "snapsvg"
declare var Snap: typeof SNAPSVG_TYPE
This allowed me to use the typescript types like normal while still employing the webpack compatible version.