Closed robflop closed 1 year ago
omg how did that happen??
Just had a look at the git blame, and it seems this was introduced in the latest commit:
So the only reason we needed a cjs build anyway was the non-support of import.meta.url. But nowadays this is fixed. So I think I can just get rid of that and webpack and all ugly things that come with it and serve esm to node
Sure! Sounds good.
If you'll permit me an unrelated question: Does this lib support creating paths manually? I know there's a plugin for the web version of svg.js, but don't know if I can use that in node in any way.
what do you mean with manually? It is just a dom replacement. So I guess the answer is yes(?). Do you have an example? :)
@robflop can you try the current master and see if it works for you?
@robflop can you try the current master and see if it works for you?
Yup, the previous error about paths is gone now - however, using require
itself doesn't work now, you have to import
it.
If you try to use the former, the following error is thrown:
Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\svgdom\main-module.js not supported. Instead change the require of main-module.js in \<filename>.js to a dynamic import() which is available in all CommonJS modules.
And regarding paths:
what do you mean with manually? It is just a dom replacement. So I guess the answer is yes(?). Do you have an example? :)
Ah, true, my bad. I was talking about something like the following, which is not suppored by svg.js by default as far as I know:
var rect = draw.path().M({x: 100, y: 100})
(from the https://github.com/otm/svg.path.js examples)
Yes, thats the downside of having a full esm package. you have to import it via async import. However, the upside for me as maintainer is quite huge so I am ok to role with it if there is no major backleash.
The path plugin you are refering to is not maintained by me and therefore I couldnt update it. So no, unfortunately you have to write your paths the old way. However template strings help quite a lot here:
const path = `M ${x} ${y}`
a bit more finger gymnastics tho :D
Gotcha. Alright, thank you!
I get the following error whenever I try to require svgdom (both 2.x and 3.x), whether it be in the console or in an actual JS file.
The line this error points to in the
main-require.cjs
file is the following, where I suspect the last part of the path:https://github.com/svgdotjs/svgdom/blob/6e9257c2ff55447d5d5ca0708e1fa30676b644a3/main-require.cjs#L3986
Removing the line does fix the import crash (ignoring whatever breaks as a result of removint it), so it certainly has to do with the path contained in it.