Cannot convert image to proper svg using potrace npm module

I am trying to convert an image to a 3d object. I use node potrace ( https://www.npmjs.com/package/potrace ) to convert the image to an svg path and then using THREE I try to generate the mesh based on this THREE example : https://threejs.org/docs/#examples/en/loaders/SVGLoader

The problem is that this implementation of potrace generates a “strange” path, one which THREE cannot work with and in many cases objects have their holes “filled” : https://i.stack.imgur.com/rtyUR.jpg

The strange thing is that the web potrace lib from which this node lib was forked works as a charm with THREE : http://kilobtye.github.io/potrace/

After my research, it seems that node potrace generates the path commands (L,M etc) in a different order than the web potrace lib and that’s why THREE fails to create the correct meshes.

I also tried every parameter of the node potrace and no luck.

Is there a safe way to convert an image to an svg that will work with THREE?

Thanks!!

/cc