xmldom icon indicating copy to clipboard operation
xmldom copied to clipboard

Document Deno example

Open brodycj opened this issue 3 years ago • 7 comments

We should investigate what needs to be done to support deno

brodycj avatar May 09 '21 18:05 brodycj

I think this is related to the discussion in #214 Not sure if we want to have a single issue for every potentially supported env before agreeing on a general strategy. What do you think?

karfau avatar May 14 '21 06:05 karfau

Reopening, since it makes more sense to discuss support for any specific environment in specific issues.

karfau avatar Sep 04 '21 07:09 karfau

for Deno users! https://github.com/xmldom/xmldom/issues/316#issuecomment-1159579203

taisukef avatar Jun 18 '22 23:06 taisukef

@taisukef thx for providing an example of what needs to be done to switch to modules and support deno.

I still think we need to find a way to additionally continue to support ES5.

I'm guessing that we could migrate the code like you did but put it into mjs files and add a build/transpilation step to continue to support ES5? Ideally in a way that it doesn't break existing usages.

karfau avatar Jun 19 '22 07:06 karfau

i typically don’t have any problem with

import { DOMParser, XMLSerializer } from "https://esm.sh/@xmldom/[email protected]";

(using esm.sh to handle the transpiling/compiling). i don’t use typescript though, so i can’t make any guarantees there.

native deno support would be nice, but the above might be useful for people trying to make this work as‐is.

marrus-sh avatar Jul 31 '22 22:07 marrus-sh

Deno supports importing from npm directly now; for example:

import { DOMParser, XMLSerializer } from "npm:@xmldom/[email protected]";

I’m not sure what the state of TypeScript support is, but as far as JS is concerned, the above works for me.

marrus-sh avatar Jun 28 '23 23:06 marrus-sh

That is true and awesome.

So it basically boils down to adding an example to the examples folder for documentation purposes.

PRs welcome.

karfau avatar Jun 29 '23 02:06 karfau