-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add Deno support #181
Comments
@Stephan-C Does Deno end up using the browser field from |
Interesting. Yeah, I guess it must be loading the browser field, which might be caused by how the package is imported into deno, I have tried skypack, esm.sh and jspm. |
I did some more investigation and came across the following: Looks like Rollup sets the browser one as the default and node is separate. Hence why Deno is loading the browser version. The only reference I could find to something similar was here rollup/rollup#3634 (comment) I sort of found a workaround, but I don't know how to apply this exclusively to html-dom-parser, for a library that depends on html-dom-parser.
So the real question is, how can we configure rollup to serve the server version for deno targets and not the browser version. |
I was able to reproduce the error in https://replit.com/@remarkablemark/html-dom-parser-181#index.ts I believe a potential fix would be to add ES Module support for this package. See https://unpkg.com/[email protected]?module:
The approach will be similar to: |
Added ESM support for |
Upgraded |
Nice. Unfortunately, it still loads the browser version in deno if you try the new |
Got it, then I'm not exactly sure what can be done to resolve this. |
Expected Behavior
html-dom-parser uses a server dom parser implementation on deno, similar to nodejs. But with guards in place if there is no document defined.
Actual Behavior
Throwing exception that
document.implementation
doesn't exist. There is nodocument
defined on deno.Steps to Reproduce
Import html-dom-parser on deno. In my case I used a library that uses html-react-parser, which uses html-dom-parser underneath.
Reproducible Demo
Save this to a file like test.js and then run it on deno:
deno run test.js
The text was updated successfully, but these errors were encountered: