-
Notifications
You must be signed in to change notification settings - Fork 628
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
JSDOM port #542
JSDOM port #542
Conversation
I think this is ready to be reviewed now, @ry. One major painpoint, I guess, is that the DOM and JSDOM types are still preliminary. There are also some other future TODOs, for example, investigating whether the bundle size can be improved, testing more of JSDOM's functionality, and rewriting/wrapping some Node specific-parts in JSDOM (for example, |
import { jsdom as instance } from "./vendor/jsdom.js"; | ||
import { jsdom } from "./types/jsdom.ts"; | ||
|
||
export const JSDOM = instance.JSDOM as jsdom.JSDOM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another implementation of this that should also work:
export { jsdom as JSDOM } from "./vendor/jsdom.js";
export { jsdom as JSDOM } from "./types/jsdom.ts";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, @j-f1. Unfortunately, this doesn't work on my machine. When I change it, JSDOM
can't be imported anymore.
$ deno test.ts
Compile file:///Users/marktiedemann/dev/deno_std/jsdom/mod.ts
error: Uncaught SyntaxError: The requested module './mod.ts' does not provide an export named 'JSDOM'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that’s unexpected. Sorry to send you on a wild goose chase!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, @j-f1.
I just tried again, with the same code, and got a different error:
$ deno test.ts
Compile file:///Users/marktiedemann/dev/deno_std/jsdom/mod.ts
error TS2300: Duplicate identifier 'JSDOM'.
► file:///Users/marktiedemann/dev/deno_std/jsdom/mod.ts:1:19
1 export { jsdom as JSDOM } from "./vendor/jsdom.js";
~~~~~
error TS2300: Duplicate identifier 'JSDOM'.
► file:///Users/marktiedemann/dev/deno_std/jsdom/mod.ts:2:19
2 export { jsdom as JSDOM } from "./types/jsdom.ts";
~~~~~
Found 2 errors.
This seems like a more expected error, still unfortunate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect denoland/deno#2746 will fix this (or at least make it possible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kitsonk, awesome! As soon as denoland/deno#2746 is released, I will update the types here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.d.ts support is in 0.16.
I'm having trouble running the tests with the big bundle file... |
Closes #537.
TODOs:
Looking for feedback.
cc @ry