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

Use globalThis code in place of global #24

Closed

Conversation

RMacfarlane
Copy link

Fixes #22

@jimmywarting
Copy link
Contributor

should just use globalThis and if it isn't supported one should just do

self.globalThis = self
window.globalThis = window
global.globalThis = global

in top of their script runtime

@calvinmetcalf
Copy link
Contributor

this is intended for use with a bundler which should handle this sort of thing, are you having problems somewhere

@RMacfarlane
Copy link
Author

I'm using webpack and targeting webworker. The bundler does not do any sort of shim for global, in a webworker the only way to access the global object is self.

@calvinmetcalf
Copy link
Contributor

calvinmetcalf commented Sep 3, 2020 via email

@RMacfarlane
Copy link
Author

Perhaps unintentionally.

IMO, I shouldn't have to fiddle with my bundler to get this code to run in a browser context, it should be able to do so without outside intervention.

@calvinmetcalf
Copy link
Contributor

calvinmetcalf commented Sep 3, 2020 via email

@RMacfarlane
Copy link
Author

Thanks!

Here's the webpack config I'm using, I may just be doing something stupid: https://github.com/microsoft/vscode/blob/616afa93e2da5a5a92b14863bab8b339b977edc4/extensions/microsoft-authentication/extension-browser.webpack.config.js

That being said, I think it's pretty easy to misconfigure webpack, and it would be helpful to others if there wasn't direct global usage that needs to be shimmed

@calvinmetcalf
Copy link
Contributor

what version of webpack is this ?

@RMacfarlane
Copy link
Author

4.43.0

@calvinmetcalf
Copy link
Contributor

I think you turned it off here

@RMacfarlane
Copy link
Author

If you don't intend to accept fixes for #22, please close it, then.

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.

Replacing global (node only) with globalThis (cross-platform)
3 participants