Skip to content
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

Replace got w/ node-fetch #110

Merged
merged 1 commit into from
Mar 9, 2022
Merged

Replace got w/ node-fetch #110

merged 1 commit into from
Mar 9, 2022

Conversation

jensmeindertsma
Copy link
Contributor

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
Owner

wooorm commented Mar 8, 2022

Can you rebase? I fixed the unrelated error on main

Copy link
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.

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
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
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
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
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