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

Stop using globalThis #2053

Closed
1 task done
iowxy opened this issue Jul 12, 2023 · 4 comments
Closed
1 task done

Stop using globalThis #2053

iowxy opened this issue Jul 12, 2023 · 4 comments

Comments

@iowxy
Copy link

iowxy commented Jul 12, 2023

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React Redux: 8.1.1

What is the current behavior?

globalThis is not defined

foca-js/foca#40
NervJS/taro#14082

According the documentation, keyword globalThis is disabled on alipay mini-program and polyfill is helpless, could you please replace it?

What is the expected behavior?

Replace globalThis

Which browser and OS are affected by this issue?

Chinese alipay mini-program

Did this work in previous versions of React Redux?

  • Yes
@iowxy
Copy link
Author

iowxy commented Jul 12, 2023

The documentation is here: https://opendocs.alipay.com/mini/framework/implementation-detail

@phryneas
Copy link
Member

globalThis is part of the ECMAScript standard since ECMAScript 2020 - and has been implemented in most runtimes well before that.

We are at an impasse here, if we want to access a global value: there are runtimes that only have window and other runtimes that have global or self - usually not all of them. globalThis has been added to address that.

It is sad to see that there are still runtimes out there that do not adhere to the standard - or in this case, if my chinese translator is correct, outright disable this feature on purpose.

If I read that correctly, they deliberately disable any kind of global access, which would explain why the polyfill is not working for you - but that also means that we could not fall back to window, global or self, since they also disabled all of those.
If I am honest, this is a ridiculous choice on their side. Is there any way you can define a global variable in that runtime?

phryneas added a commit that referenced this issue Jul 12, 2023
@phryneas
Copy link
Member

I guess we can in that case fall back to module scope, essentially going back to pre-8.1 behavior. See b37e57e .

Could you please try if this build solves your problem and still works without anything breaking?

npm i https://pkg.csb.dev/reduxjs/react-redux/commit/b37e57e9/react-redux

@phryneas
Copy link
Member

This should be solved in v8.1.2.

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

No branches or pull requests

2 participants