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

Regression: v3.2.0 generates warnings in rollup #802

Closed
heygrady opened this issue Jul 24, 2020 · 1 comment · Fixed by #815
Closed

Regression: v3.2.0 generates warnings in rollup #802

heygrady opened this issue Jul 24, 2020 · 1 comment · Fixed by #815

Comments

@heygrady
Copy link

heygrady commented Jul 24, 2020

Version 3.2.0 includes a fix for "global" in node environments. Recent versions of rollup enforce a "no top-level this" rule and forces this to be undefined.

I see a message like this:

(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules/whatwg-fetch/fetch.js
2:   return self
3:   // eslint-disable-next-line no-invalid-this
4: })(typeof self !== 'undefined' ? self : this)
                                           ^
5: var support = {
6:   searchParams: 'URLSearchParams' in global,

I'm using Rollup to bundle a polyfill for older browsers.

FWIW, this is the globalThis fallback chain that babel adds to my code any time I use global.

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

I believe that babel just uses whatever cores-js does for globalThis

@JakeChampion
Copy link
Owner

The warning is nothing to worry about, all browsers have a global variable named self, which is what is used first, the fallback to this is only for non-browser environments such as NodeJS, where likely a bundler is not being used.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2021
cr313 added a commit to cr313/fetch-Js-flow that referenced this issue Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants