Skip to content

Replace got w/ node-fetch#110

Merged
wooorm merged 1 commit intowooorm:mainfrom
fern64:replace-got
Mar 9, 2022
Merged

Replace got w/ node-fetch#110
wooorm merged 1 commit intowooorm:mainfrom
fern64:replace-got

Conversation

@fern64
Copy link
Copy Markdown
Contributor

@fern64 fern64 commented Feb 26, 2022

This pull request fixes #109. It replaces the got package which is only used once, with an alternative ( node-fetch, which against intuitions does not depend on @types/node where got did ).

This means that there are now not any issues when running tsc in a Cloudflare Workers project which uses xdm. This came up specifically while building a Remix application, as @remix-run/dev depends on xdm.

I made sure to replicate the existing caching set up, as that is not included in node-fetch.

Thanks for this awesome project 🙏

@wooorm
Copy link
Copy Markdown
Owner

wooorm commented Mar 8, 2022

Can you rebase? I fixed the unrelated error on main

Copy link
Copy Markdown
Collaborator

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jensmeindertsma!

Comment on lines +104 to +110
const cachedContents = cache.get(href)
if (cachedContents) {
contents = cachedContents
} else {
contents = await (await fetch(href)).text()
cache.set(href, contents)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue may have already existed before, but now is more visible.
It's a bit worrying that the caching system doesn't have memory management (max cached items, max memory usable, etc).
On massive projects, caching could become an issue exceeding the memory node is allowed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not sure whether that should be improved as part of this PR though, might be better do to it in a separate PR?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not too worried about it. Could use something smarter in the future (an LRU cache?), but this is probably fine for now in build scripts

@wooorm wooorm changed the title Replace got with Cloudflare-friendly alternative Replace got w/ node-fetch Mar 9, 2022
@wooorm wooorm merged commit 6276fcc into wooorm:main Mar 9, 2022
@wooorm
Copy link
Copy Markdown
Owner

wooorm commented Mar 9, 2022

Released, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace got with alternative that doesn't depend on @types/node

3 participants