svg-to-excalidraw icon indicating copy to clipboard operation
svg-to-excalidraw copied to clipboard

Error while executing

Open ganesshkumar opened this issue 3 years ago • 1 comments

I just ran the example on my machine

import svgToEx from 'svg-to-excalidraw';

const heartSVG = `
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <path d="M 10,30
           A 20,20 0,0,1 50,30
           A 20,20 0,0,1 90,30
           Q 90,60 50,90
           Q 10,60 10,30 z"/>
</svg>
`;

const { hasErrors, errors, content } = svgToEx.convert(heartSVG);

and got the following error,

ReferenceError: self is not defined
    at Object.<anonymous> (<redacted>\node_modules\svg-to-excalidraw\dist\bundle.js:1:242)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:177:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)

Any pointers on how to fix this?

ganesshkumar avatar Jun 12 '21 16:06 ganesshkumar

Thanks for trying this out! This looks like it's ESM related. At the moment I'm in the process of moving, so not able to debug this, but you can try to clone the repo locally and build it, then npm link it into your project. Both UMD and ESM builds should be created. Will try to take a look at this when I can.

brochington avatar Jun 12 '21 19:06 brochington