Closed justin-hackin closed 1 year ago
Somebody posted a PR with a similar modification. The answer is basically the same: we cannot use the SVG transform property string with DOMMatrix/CSSMatrix, it's a different thing. We always use a certain type of value for consistency.
Instead of
import getSVGMatrix from 'svg-path-commander/src/process/getSVGMatrix';
you should do
import SVGPathCommander from 'svg-path-commander';
const { getSVGMatrix } = SVGPathCommander;
// do your thing
Vite has changed how tree shaking works and this is currently the only way I know to work unfortunately.
Oh, good tip, thanks @thednp . Since I'm maintaining a subset of the SVG commands that are absolute, perhaps I will further constrain it to not use arc command using a conversion to cubic so that all the transforms are straightforward point mappings.
It would be helpful if the transform function would accept the same type as the parameter to
CSSMatrix.fromMatrix
so that native DOMMatrix objects or CSSMatrix could be used. They are useful for rendering transform strings when sharing transforms between SVGPathCommander and native SVG transform attributes.My IDE attempted to import this function as such
but that crashed my build (
"vite": "^3.2.6"
)So I had to copy the file into my project and write a wrapper to do the transformation as such
P.S. Thanks for making this, one of my projects has a fluent interface for building path data and I decided to give this a try for parsing instead of
svgpath
. It's got some extra features that seem quite useful.