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 of Iterator.prototype.reduce in the core-sdk breaks compatiblity with browsers #268

Open
elee1766 opened this issue Feb 21, 2025 · 1 comment

Comments

@elee1766
Copy link

see here:

https://github.com/morpho-org/sdks/blob/main/packages/blue-sdk/src/vault/Vault.ts#L263-L287
https://github.com/morpho-org/sdks/blob/main/packages/blue-sdk/src/vault/Vault.ts#L305-L319

where Iterator.prototype.reduce (values().reduce) is being called.

this is actually not implemented in all browsers yet:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/reduce

importantly, it is not implemented in both safari and firefox esr (128)

it would probably be good to implement the sdks without Iterator.prototype.reduce to maximize compatibility.

@Rubilmax
Copy link
Collaborator

Hi, thanks for the issue!

IMO, it should not be fixed at the package level because it means package developers need to not use latest ECMAScript features in order to maximize compatibility. But these features turn out to be very handy and efficient (in this case, more efficient than converting to an array and then reducing)

Instead, it should be the responsibility of integrators to make sure used packages are compatible with the runtime environment. In the case of browsers, this is possible thanks to polyfills: https://github.com/zloirock/core-js

@Rubilmax Rubilmax closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2025
@Rubilmax Rubilmax reopened this Feb 22, 2025
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