hpq
hpq copied to clipboard
parse doesn't work with Node.js
The current implementation depends on browser APIs like createHTMLDocument
, querySelector
, querySelectorAll
. It's not possible to use this library with Node.js or React Native.
It would be possible to simulate DOM using jsdom as explored in https://github.com/gziolo/hpq/pull/1.
In ReactNative, you miss some Node.js APIs so you can't use the full implementation of jsdom. That's why I tried to use the smallest possible subset of the library.
Hi!
I think this makes sense. As you alluded in https://github.com/gziolo/hpq/pull/1#issuecomment-530793003, I'm curious about the impact on the browser distributed bundle (i.e. can we ensure the built code only includes the relevant code path).
I was thinking about the impact on testing too, but since we basically rely on JSDOM as the "native" implementation for tests, I don't think there's anything we can / should need to do there.
I'll figure out how to do it but it looks like doable with Rollup 👍
I'd be nice to land https://github.com/aduth/hpq/pull/5 first which updates npm dependencies. Well, maybe it will be a good idea to pin jsdom
to one version since we are going to use functionality based on the folder structure which isn't enforced by the public API.
I'd be nice to land #5 first which updates npm dependencies.
Yep, done.
Awesome, thanks. I'll rebase and continue my exploration next week 👍