Skip to content

Regression: v3.2.0 generates warnings in rollup #802

Closed
@heygrady

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions