RangerMauve / webrun

Run Web-first ESM modules outside of the browser
https://webrun-presentation.hashbase.io/
MIT License
77 stars 8 forks source link

jsdom/like for DOM? #28

Closed dy closed 4 years ago

dy commented 4 years ago

Just curious, is DOM planned to be supported? browser-env for example takes it as a base. The drawback of jsdom is missing support for web-components and ranges.

RangerMauve commented 4 years ago

I haven't looked into dom APIs much since I've mostly been focused on running ESM scripts rather than web pages.

What sort of stuff would you expect the dom to do or how would it be populated?

dy commented 4 years ago

The main case I'd expect - running browser tests in travis. Now for that purpose I do https://github.com/spectjs/spect/blob/master/test/register.js and node -r ./test/register.js ./test/index.js. Tbh I don't know many browser-only packages without dom.

RangerMauve commented 4 years ago

Would Webrun have any benefits to running browser tests compared to regular JSDOM based test runners?

I was modelling the structure a bit closer to deno, or cloudflare workers which don't seem to provide a DOM API either.

Would an example of loading JSDOM in Webrun help for the testing use case?

dy commented 4 years ago

regular JSDOM based test runners

Tbh I don't know (many) jsdom-based test runners, that's why the setup.

I think I don't realize completely the project's goal:

  1. is that the opposite to browserify, making any browser-module run in node.
  2. that's the alternative to esm, making browser imports work in node.
  3. it intends to provide worker-like browser-less environment, as the mentioned cloudflare workers.

If 2 or 3 is the case - then no need for jsdom and other browser API, or that can be hidden by flags.

RangerMauve commented 4 years ago

Yeah, I think I've been leaning mostly towards 3.

The main idea I had was to create reusable libraries that are browser-first and having a browser-like environment to run them. Mostly focusing on ESM modules and APIs that'd be useful in workers / WebRTC.

dy commented 4 years ago

Ok, that's separate concern then. Thanks for the explanation.