svgdom icon indicating copy to clipboard operation
svgdom copied to clipboard

Trouble loading ESM from Deno

Open duncanmak opened this issue 1 year ago • 6 comments

My code looks like this:

import { assertEquals } from "@std/testing/asserts.ts";
import { SVG, registerWindow } from "https://cdn.jsdelivr.net/npm/@svgdotjs/[email protected]/dist/svg.esm.js";
import { createSVGWindow } from "https://cdn.jsdelivr.net/npm/[email protected]/+esm";

Deno.test("svg", () => {
  const window = createSVGWindow();
  const document = window.document;

  // register window and document
  registerWindow(window, document);

  // create canvas
  const canvas = SVG(document.documentElement);
  canvas.rect(100, 100);

  console.log('hello', canvas.svg());
  assertEquals(canvas.svg(), "");
});

I get this error:

./tests/canvas.test.ts (uncaught error)
error: SyntaxError: The requested module '/npm/[email protected]/+esm' does not provide an export named 'default'
    at <anonymous> (https://cdn.jsdelivr.net/npm/[email protected]/+esm:7:92)
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.

Is there a problem with the ESM file?

duncanmak avatar Jun 26 '23 19:06 duncanmak