$fetch using `globalThis` (not the polyfill)
See original GitHub issueCode seems to be doing the polyfill detection, but then $fetch still uses globalThis
(and not the polyfilled variable; Pv
in this case.)
This is macOs high sierra, safari 11 using a prod nuxt3 build (using browserstack to test)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
node-fetch should provide a polyfill entrypoint · Issue #1317
using a library that expects fetch available as a global; working with an ... This is a polyfill for node , not for...
Read more >A horrifying globalThis polyfill in universal JavaScript
This write-up describes the difficulties with writing a proper globalThis polyfill. Such a polyfill has the following requirements:.
Read more >What is globalThis, and why should you start using it?
The globalThis proposal, now in stage 4, aims to consolidate the increasingly fragmented ways of accessing the global object in JavaScript.
Read more >globalThis and Polyfill in Javascript | by Susanne Lundkvist
In web development, a polyfill is code that implements a feature on web browsers that do not support the feature. Polyfills allow web...
Read more >globalThis - JavaScript - MDN Web Docs
With globalThis available, the additional search for the global across environments is not necessary anymore: if (typeof globalThis.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pi0 I’m not adding a polyfill, im referring to the
globalThis
polyfill (or shim?), which is right in the ohmyfetch codebase, and that’s cool, but one place uses the globalThis shim, but another place doesn’t:This line ends up in the nuxt3 build: https://github.com/unjs/ohmyfetch/blob/4b74e45f9989a993e725e7fe4d2e098442e457f1/src/undici.ts#L7
Browsers that dont support globalThis will just fail on that. But this: https://github.com/unjs/ohmyfetch/blob/4b74e45f9989a993e725e7fe4d2e098442e457f1/src/index.ts#L6-L14 uses the polyfill/shim.
So should the following also use the polyfill (basically
_globalThis
vsglobalThis
; and move the shim to some shared util file)? https://github.com/unjs/ohmyfetch/blob/4b74e45f9989a993e725e7fe4d2e098442e457f1/src/undici.ts#L7I was gonna say, it might not even necessarily be that the polyfill is needed, but that that part of the code shouldn’t be part of the client build in general (maybe that’s the issue?) The undici path is leaking into the client build but shouldnt be?
Maybe a boilerplate stackblitz of nuxt3 would repro the issue…
Safari 11.1.2
It’s not urgent, but like I said, it would cool for nuxt and my app to possibly be able to work on a few other browsers if this issue gets fixed; who konws, maybe this is the only issue on this safari version and everything ends up working fine.