-
-
Notifications
You must be signed in to change notification settings - Fork 109
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 globalThis.fetch #934
Add globalThis.fetch #934
Conversation
🦋 Changeset detectedLatest commit: c0b0b1b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I am wondering if I should include the following DOMParser in the globalThis.DOMParser = new (require("jsdom").JSDOM)("").window.DOMParser; |
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.
This should be done in WMR's prerender rather than preact-iso: https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/prerender.js
We set a couple other things on globalThis
there, as you can see.
Edit: To expand a little, preact-iso
isn't tied to WMR. It very well could be used in other environments. As such, if we want to fix a shortcoming in WMR specifically, we'll want to move this into WMR's prerender script.
This also allows us to pass config values, like the output directory, easily.
Okay, I was a little mistaken. I thought this was all inclusive. |
Totally fair! To be honest it's in a bit of a weird spot right now. We'd like people to use it for more than just WMR, but, being buried in this monorepo, a lot of people don't even know it exists (we're working on fixing that though). Could we add a test case for this? Super simple fetch for markdown, like you do in your blog, would be awesome! You can add a test fixture here: https://github.com/preactjs/wmr/tree/main/packages/wmr/test/fixtures Just need to build & prerender the fixture then check that the prerendered HTML contains our markdown content. |
@rschristian |
@rschristian |
Nearly forgot, needs a changeset. You can run I can get around to doing this later & merging too. Edit: Indeed, we seem to have a flakey test. Took me a few reruns before everything passed without issue. |
@rschristian |
Thanks! |
Possibly related? |
@danielweck Actually no, I haven't seen segfaults in ages. Looks to be fixed on Node's side? Not sure if others share that experience or I somehow got lucky. The flakey tests here were unrelated. HMR issues. |
Thanks @rschristian I'll check my Node / segfault status. |
I had this conversation with @developit on Twitter.
https://twitter.com/_developit/status/1558610677157269504
wmr gives an error if there is no fetch when prerendering.
To work around this, define
globalThis.fetch
in preact-iso's prerender.