-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble loading ESM from Deno #106
Comments
The problem seems to be the import of fontkit - that's a dependency of svgdom. Maybe the import has to be changed 🤔. Not sure tho. Usually people just use the package by installing into hide modules |
Deno also has npm support, so I tried it: import { SVG, registerWindow, Rect } from "npm:@svgdotjs/[email protected]";
import svgdom from "npm:[email protected]";
Deno.test("svg", () => {
const window = svgdom.createSVGWindow();
const document = window.document;
// register window and document
registerWindow(window, document);
// create canvas
const canvas = SVG(document.documentElement);
// canvas.rect(100, 100);
new Rect().size(100, 100).addTo(canvas);
console.log('hello', canvas.svg());
assertEquals(canvas.svg(), "");
}); It seems a little better, but I think the same problem is still there:
|
Maybe using fontkit 2.0.0 will make this work better? |
I just made this PR: #107 I wonder if that's the trick to solve the issue I mentioned here. |
Looks like this is also necessary for svgdom to work in Deno: |
Adding an explicit import of iconv-lite seems to be a workaround for now (modified version of @duncanmak 's example): import "npm:[email protected]";
import { SVG, registerWindow, Rect } from "npm:@svgdotjs/[email protected]";
import * as svgdom from "npm:[email protected]";
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
Deno.test("svg", () => {
const window = svgdom.createSVGWindow();
const document = window.document;
registerWindow(window, document);
const canvas = SVG(document.documentElement);
new Rect().size(100, 100).addTo(canvas);
assertEquals(
canvas.svg(),
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs"><rect width="100" height="100"></rect></svg>'
);
}); |
My code looks like this:
I get this error:
Is there a problem with the ESM file?
The text was updated successfully, but these errors were encountered: