core-js icon indicating copy to clipboard operation
core-js copied to clipboard

window.fetch method implementation

Open chicoxyzzy opened this issue 9 years ago • 25 comments

just noticed core-js missing fetch polyfill subjectively best existing implemetation https://github.com/github/fetch

chicoxyzzy avatar Jan 27 '15 23:01 chicoxyzzy

It's missing because currently core-js adds only cross-platform features, not browser-only or server-only. I will add it if i will add modules for network and DOM.

zloirock avatar Jan 28 '15 07:01 zloirock

this makes sense. thoughts: environment-specific features can be bundled as optional modules. than one will be able to import browser-shim.js or node-shim.js (or server-shim.js with respect to iojs). or is it sounds as a standalone project I better should start by myself?

chicoxyzzy avatar Jan 28 '15 12:01 chicoxyzzy

I'll think about it.

zloirock avatar Jan 28 '15 13:01 zloirock

@chicoxyzzy Think about what else can be added to the client and server shims.

zloirock avatar Jan 28 '15 14:01 zloirock

It would be really nice to have core-js shim this function in both node and the browser. All the current polyfill's either don't browserify nice or don't do commonjs (polluting window.fetch and Promise without permission).

nelix avatar Mar 23 '15 10:03 nelix

Because of the large number of requests, I reopen it. Maybe I will add it, but it's not priority task.

zloirock avatar Mar 24 '15 09:03 zloirock

I'm not sure what I am getting my self into, but perhaps I could help out with this..? Since I care about it.

nelix avatar Mar 24 '15 10:03 nelix

Yep, you can add PR with implementation as modules/web.fetch.js. Module should be as compact as possible - library is already too bloated.

zloirock avatar Mar 24 '15 10:03 zloirock

Why you need fetch people? It does not even have abort capabilities for request and will never be able to polyfill network streams such they as they will be present in fetch. All other functional is just wrap XHR with Promise.

NekR avatar Apr 06 '15 21:04 NekR

I think core-js should continue to provide an ES6 environment, at least by default; fetch is a DOM standard so that would be vastly different. If you start polyfilling the DOM, the library will get much larger.

In any case, GitHub has a fetch polyfill that's fairly popular.

mgol avatar Aug 24 '15 07:08 mgol

Please don't add any DOM related stuff since it would break non DOM js enviroments.

steida avatar Sep 20 '15 01:09 steida

It might make sense to have a separate core-dom report for DOM related polyfills. I say this after having requested NodeList[Symbol.iterator] be added a while back. I think the reason why people make requests here is that there doesn't seem to be a corresponding repo for polyfilling DOM stuff. There are a bunch of little repos that polyfill different DOM things, but people don't want to have to go find each of these individual repos.

kevinbarabash avatar May 15 '16 03:05 kevinbarabash

It's 2017 and still no updates regarding this. Yeah, it's not a big problem since fetch-polyfill is available, but imo it's more convenient to have one package installed rather that two.

elliolir avatar Jun 28 '17 14:06 elliolir

It'd be also much more convenient because then babel-polyfill could automatically polyfill fetch depending on your browserlist so you wouldn't have to add/remove the fetch polyfill depending on your target browsers...

jonaskuske avatar Feb 06 '18 12:02 jonaskuske

Actually babel-polyfill could do this using any other polyfill. Not sure that it should though but it's better to create such issue (if it doesn't exist yet) in Babel repo

chicoxyzzy avatar Feb 06 '18 15:02 chicoxyzzy

It's 2018 and still no updates regarding this. Yeah, it's not a big problem since fetch-polyfill is available, but imo it's more convenient to have one package installed rather that two.

imprfekt avatar Oct 17 '18 22:10 imprfekt

@precompiled I think the original logic still holds. The fetch API is not part of the ECMAScript spec, so it doesn't really make sense to have in this repository. For the same reason, it's also not something I'd expect to be part of @babel/polyfill. Babel's objective is to polyfill language-standard features. Adding this would be no different than if core-js tried to polyfill require('url') or require('path') modules, or MutationObserver or any number of other environment-specific APIs.

loganfsmyth avatar Oct 19 '18 00:10 loganfsmyth

@loganfsmyth BTW core-js already includes polyfills for non-ES things https://github.com/zloirock/core-js#web-standards

chicoxyzzy avatar Oct 19 '18 04:10 chicoxyzzy

That's true, but I also think the average dev considers setTimeout/setImmediate to be part of ECMAScript even while that may not technically be the case. I guess what I should say is that I'd consider the bar extremely high as far as cross-environment expectations go, and I don't think fetch meets those requirements.

loganfsmyth avatar Oct 19 '18 04:10 loganfsmyth

IMO developers expect that babel-polyfill will cover everything based on browserslist config. I see the reason why fetch is not in core-js, but considering that timeouts and DOM iterations are covered, missing fetch becomes non obvious issue.

chicoxyzzy avatar Oct 19 '18 06:10 chicoxyzzy

same issue + 1

lake2 avatar Dec 27 '20 15:12 lake2

It's missing because currently core-js adds only cross-platform features, not browser-only or server-only.

fetch has now (experimentally) been added to node in https://github.com/nodejs/node/commit/6ec225392675c92b102d3caad02ee3a157c9d1b7.

  • https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V17.md#2022-02-10-version-1750-current-ruyadorno
  • https://github.com/nodejs/node/issues/19393
  • https://github.com/nodejs/node/pull/41749
  • https://github.com/nodejs/undici#undicifetchinput-init-promise

Schweinepriester avatar Feb 24 '22 22:02 Schweinepriester

Expect this polyfills

1593292349 avatar Feb 09 '23 09:02 1593292349

Expect this polyfills

https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md

lekoaf avatar Feb 14 '23 08:02 lekoaf

@1593292349 what is your use case? Otherwise I think the issue should be closed.

Bessonov avatar Feb 14 '23 21:02 Bessonov