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

Do you have a plant to update node-fetch to v3? #445

Closed
yumetodo opened this issue Oct 6, 2021 · 5 comments
Closed

Do you have a plant to update node-fetch to v3? #445

yumetodo opened this issue Oct 6, 2021 · 5 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@yumetodo
Copy link

yumetodo commented Oct 6, 2021

Already, renovate-bot create #426 to introduce node-fetch v3 and it was rejected.

I'm interested in node-fetch/node-fetch#667 and it is fixed in node-fetch v3.

Do you have a plant to update node-fetch to v3?

@chingor13 chingor13 added the type: question Request for information or clarification. Not an issue. label Oct 6, 2021
@chingor13
Copy link

We need to wait until we can drop support for Node 10. When that happens, we will look into updating node-fetch to v3, but it appears to be a non-trivial upgrade.

Dropping of Node 10 is planned, but there is not an official timeline yet.

@dobromyslov
Copy link

@chingor13 node 10 has been dropped already. Here is the official timeline https://github.com/nodejs/Release

And I agree it's not trivial because it requires all packages depending on the node-fetch 3 to be migrated from CommonJS to ESM.

Why don't you just make a new gaxios v3 beta branch and release it with ESM support to kick off the migration?

@yumetodo
Copy link
Author

migrated from CommonJS to ESM.

That is exactly what I missed when I create this issue. creating a beta branch looks good to me.

@dobromyslov
Copy link

dobromyslov commented Dec 19, 2021

@yumetodo here is a workaround I use:

  1. Migrate your own project to the ESM.
  2. Import gaxios 2.x. ESM allows import CommonJS modules.
  3. Default import node-fetch 3.1 which is ESM already.
  4. Set GaxiosOptions fetchImplementation to the imported fetch.
  5. Run your gaxios request with the custom fetchImplementation.
  6. If you need to set custom node-fetch options just set them to the GaxiosOptions object. And they will be passed to the fetch request under the hood.

This was referenced Dec 23, 2021
@jimmywarting
Copy link

And I agree it's not trivial because it requires all packages depending on the node-fetch 3 to be migrated from CommonJS to ESM.

Well, you can still import esm only modules from cjs without switching to ESM yourself
doe you have to use async import... we got a bunch of examples in node-fetch/node-fetch#1279 of how to go about it...

once such example could be to do:

const fetchPromise = import('node-fetch').then(mod => mod.default)
const fetch = (...args) => fetchPromise.then(fetch => fetch(...args))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants