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

Fix unsafe of "this" inside module initialization (TypeError: Cannot use 'in' operator to search for 'window' in undefined) #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlonMiz
Copy link

@AlonMiz AlonMiz commented Jun 12, 2021

when using esbuild with vite. this file generates an exception.

TypeError: Cannot use 'in' operator to search for 'window' in undefined
    at reqwest.js:15
    at reqwest.js:8
    at ../node_modules/reqwest/reqwest.js (reqwest.js:10)
    at __require2 (chunk-RDZ5XA5N.js?v=dde87764:17)
    at ../node_modules/auth0-js/index.js (index.js:14)
    at __require2 (chunk-RDZ5XA5N.js?v=dde87764:17)
    at dep:auth0-js:1

this is how it looks like when compiled with esbuild+vite. "this" is now referencing a different context than the intended window.
image

using global this will make it more robust.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis

…e 'in' operator to search for 'window' in undefined)

when using esbuild with vite. this file generates an exception.
```
TypeError: Cannot use 'in' operator to search for 'window' in undefined
    at reqwest.js:15
    at reqwest.js:8
    at ../node_modules/reqwest/reqwest.js (reqwest.js:10)
    at __require2 (chunk-RDZ5XA5N.js?v=dde87764:17)
    at ../node_modules/auth0-js/index.js (index.js:14)
    at __require2 (chunk-RDZ5XA5N.js?v=dde87764:17)
    at dep:auth0-js:1
```
this usage should've

this is how it looks like when compiled with esbuild+vite. "this" is now referencing a different context than the intended window.

using global this will make it more robust.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant