glenzli/paperjs-offset

Lib doesnt seem to be working with paper-jsdom

Opened this issue · 1 comments

NoZ4 commented

Hello
Been trying for a while to get the lib to work with paper-jsdom, been having real troubles, managed to get it not to through errors but then i'll call a function and it doesnt actully change the path

spent a couple of days on it and I have no idea whats wrong

Thanks

I know this issue is old, but I did some investigation ... so if somebody stumbles on this, this is what I found:

I believe the issue is, that paperjs-offset lists PaperJS as a normal dependency.
If you use a newer version of PaperJS, paperjs-offset will also install version ^0.12.15, like here:
Screenshot 2021-05-07 at 14 58 22

If I run my code I get the following:

  • Error: TypeError: Cannot read property 'flatMap' of undefined
  • Erroneous code var children = nonSIPath.children.flatMap(function (c) {
  • Error source /node_modules/paperjs-offset/dist/index.umd.js:375

... but ... if I simply delete that node_modules folder within paperjs-offset everything works perfectly fine.

The fix:
I think it's as easy requiring PaperJS as a devDependency in the package.json.
I did this for my own purposes as a fork and it works perfectly fine. (I can now also require it in my package.json as "paperjs-offset": "git://github.com/stephanbogner/paperjs-offset.git#master")

If desired, I'd be happy to make a pull request with the adjusted package.json @glenzli