EOSIO / eosjs2

Library to talk to the eos api
MIT License
29 stars 21 forks source link

Using eosjs2 in IE11 and got ReferenceError: 'TextEncoder' is undefined #56

Closed sytong closed 6 years ago

sytong commented 6 years ago

I tried to use eosjs2 in IE11 and got this error:

ReferenceError: 'TextEncoder' is undefined

I notice that TextEncoder is an experimental feature in JavaScript is currently not supported in Internet Explorer. Do you have any suggestion about this?

Reference: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder#Browser_compatibility

tbfleming commented 6 years ago

Does this polyfill work on IE11? https://github.com/inexorabletash/text-encoding/blob/master/README.md

chris-allnutt commented 6 years ago

It's experimental in IE not Javascript It looks like IE is the minority in support of TextEncoder https://caniuse.com/#search=TextEncoder . I've seen the above polyfill referenced by others as a workaround. Is there a reason why you need to specifically need to support IE?

ChristianDunst commented 6 years ago

Is there a reason why you need to specifically need to support IE?

According to:

screen shot 2018-09-07 at 10 35 11 am

IE is the second most used browser on desktop/laptop. We must support it.

sytong commented 6 years ago

It's experimental in IE not Javascript It looks like IE is the minority in support of TextEncoder https://caniuse.com/#search=TextEncoder .

By the definition of Experimental Technology in the MDN Web Docs, TextEncoder is considered experimental because of either reason:

  1. It is implemented and enabled by default in less than two modern major browsers.
  2. Its defining spec is not stable and likely to change significantly. Its syntax and behavior is therefore subject to change in future versions of browsers as the specification changes.
chris-allnutt commented 6 years ago

@sytong did the polyfill work for you?

I'm not going to argue semantics; or how broadly used IE is. Ultimately this library is dependent on TextEncoder and will not operate without it.

If the polyfill does work we'll update our documentation to inform developers in need of IE support that it is an option.

chris-allnutt commented 6 years ago

@sytong @ChristianDunst Re-opening this FYI. I've done some initial testing and as of eosjs2@0.0.12 you can provide custom encoding and decoding. I've tested and confirmed the polyfill https://github.com/inexorabletash/text-encoding works in IE11, I'm going to test in Edge and if it works there as well I will update the documentation to aid other developers in the future.

chris-allnutt commented 6 years ago

@sytong and @ChristianDunst Resolved in #64 documentation update. We've verified the polyfill works on IE11 and Edge.

terrylks commented 6 years ago

I have added the text-encoding polyfill. It works on both IE11 and Edge.

However, there is an another issue with IE11.

In /src/ripemd.js, Proxy is used and IE11 is not supporting Proxy and it cannot be polyfilled.

So eosjs now is NOT working on IE11.

chris-allnutt commented 6 years ago

@terrylks can you please share the code you're using? When I used our reference project I had no issues using the reference containers provided by Microsoft for signing transactions. Is this something other than transaction signing?

Thanks!

chris-allnutt commented 6 years ago

@terrylks it would also be helpful if this could be opened under a new issue. This was related to TextEncoder, please include the detailed error message and sample code to help reproduce.