Closed AlexMax closed 1 year ago
Without reading everything: I run into the same problem yesterday. For some reason I couldnt import {SVG} from '@svgdotjs/svg.js'
. However, it was totally fine with other methods like import {makeInstance, registerWindow} from '@svgdotjs/svg.js'
(in my case node complained).
I think you can resolve your issue by using import * as svghjs from '@svgdotjs/svg.js
and then use const {Point} = svgjs
to get what you want.
My guess is it happends because you cant do {Point} = require(...)
so you also cant import {Point}
. Because the node version of svg.js ofc uses require.
You could force your node to use the esm version of svg.js which might solve your problem, too.
For that you can try import {Point} from '@svgdotjs/svg.js/dist/svg.esm.js'
.
I would like to use SVG.js's matrix math operations in a script that will be used on both the client and server. However, I'm having difficulty constructing esm import that makes both Node and webpack happy.
If I do this, like it says in the documentation:
...webpack gives me no errors, but when I run this in Node, I get a nasty error message:
If I instead change it to this:
I get no errors and the program runs.
But then webpack complains:
And predictably parts of my browser program start breaking.
I wanna say this is a packaging bug, but maybe I'm just not using the right import invocation?
Here's the
package.json
I'm using for this test:And here is the test webpack config file:
EDIT: I have modified this issue because the original example didn't actually work in browsers either, despite compiling correctly. I have fixed it.