-
Notifications
You must be signed in to change notification settings - Fork 585
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
Implement polyfill for globalThis #4653
Conversation
c4476af
to
7d4931d
Compare
@@ -181,6 +181,7 @@ const Person = { | |||
* Logging out too quickly can cause an error if the timeout behavior is set to `openLocalRealm` ([#4453](https://github.com/realm/realm-js/issues/4453), since v10.0.0) | |||
* Released `realm-network-transport` to adopt the changes published to fix `globalThis` undefined issue for older devices. ([#4350](https://github.com/realm/realm-js/issues/4350), since v10.0.0) | |||
* Fixed flexible sync crash when updating subscriptions after token expiry. ([#4421](https://github.com/realm/realm-js/issues/4421), since v10.12.0) | |||
* Fixed remaining uses of `globalThis` undefined issue, causing Realm to not load on iOS 11/12. ([#4350](https://github.com/realm/realm-js/issues/4350)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know if it has always been an issue - or was the bug introduced in a specific version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I will check the git history and see if I can tell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we could simplify the solution, but simply documenting the use of the @babel/preset-env Babel preset?
As in we say to users that they need to use |
Yeah. Or perhaps https://www.npmjs.com/package/babel-plugin-transform-globalthis? Since I don't see |
Regardless: If we choose to discourage the explicit usage of |
I was following the pattern of what we've already done for @kneth @takameyer any thoughts? Good suggestion re: the lint rule |
I agree - and ideally we would apply this in a build step before publishing our package for consumption. |
Got it, this would be the ideal (we use the Babel plugin on our code before publish). In the interim until we have the infra in place to do that (or can we do it right now?), are you OK with this solution? |
I think we should do the work for our users here. If it's possible that we implement the babel plugin in our own codebase, I would prefer this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I agree with @takameyer |
@tomduncalf Add eslint rule |
@tomduncalf Plan: merge this PR, rebase v11 against master, rebase v11 PR to remove cherrypick commit and merge |
4725209
to
b92a7f8
Compare
@kraenhansen I added the eslint rule in all public facing packages: b92a7f8 |
If everyone is happy with this, I'll publish the new common version and rerun CI |
I think it should be enough to add it to the root package and have the other packages inherit? |
Ah I didn't realist that they inherited! Even better, I'll update |
What, How & Why?
This closes #4350. I decided to replace the existing inline implementations with a more robust polyfill taken from core-js, and to put it in
realm.io/common
so we don't need to always repeat the same snippet☑️ ToDos
Compatibility
label is updated or copied from previous entryBreaking
label has been applied or is not necessaryIf this PR adds or changes public API's: