Correct import of default property#463
Conversation
Update README.md
EOSJS v20.0.0-beta3
Fixes `TypeError: JsSignatureProvider is not a constructor` for NodeJS and Babel
|
now, I can use those code to get a instance of JsSignatureProvider
but, i can't get instance of JsonRpc: I get a error 'JsonRpc is not a constructor', how can i solve it ? |
|
@Mc01 I'll look into this next week. I want to run through some tests with various environments to figure out the most intuitive way to import and initialize these classes. We want to ensure EOSJS is compatible with a transpiled web bundle, vanilla JS browser code, and NodeJS code out of the box. We don't have tests yet for the latter, so I want to take a deeper look into this before approving the change. Good job taking initiative on this though. |
|
We will be pushing a patch in the near future to remove the usage of default exports altogether to keep import syntax as consistent as possible across all environments. |
Fixes
TypeError: JsSignatureProvider is not a constructorfor NodeJS and Babel.Caused by
export default class JsSignatureProvider.Babel assigns default exports to the default property.
So if you use require to import ES6 modules, you need to access the default property.