Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Correct import of default property#463

Merged
c0d3ster merged 5 commits intoEOSIO:developfrom
Mc01:patch-1
Jan 11, 2019
Merged

Correct import of default property#463
c0d3ster merged 5 commits intoEOSIO:developfrom
Mc01:patch-1

Conversation

@Mc01
Copy link
Copy Markdown
Contributor

@Mc01 Mc01 commented Dec 20, 2018

Fixes TypeError: JsSignatureProvider is not a constructor for 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.

Velua and others added 5 commits November 21, 2018 20:09
Fixes `TypeError: JsSignatureProvider is not a constructor` for NodeJS and Babel
@skanger
Copy link
Copy Markdown

skanger commented Dec 27, 2018

now, I can use those code to get a instance of JsSignatureProvider

const signatureProvider = new JsSignatureProvider.default(privateKeys);

but, i can't get instance of JsonRpc:

const {Api, JsonRpc} = require('eosjs');

const fetch = require('node-fetch');

const rpc = new JsonRpc('http://127.0.0.1:8888', { fetch });

//  const rpc = new JsonRpc.default('http://127.0.0.1:8888', { fetch });

I get a error 'JsonRpc is not a constructor', how can i solve it ?

@c0d3ster
Copy link
Copy Markdown
Contributor

c0d3ster commented Jan 3, 2019

@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.

@c0d3ster c0d3ster changed the base branch from master to develop January 11, 2019 21:29
Copy link
Copy Markdown
Contributor

@c0d3ster c0d3ster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@c0d3ster c0d3ster merged commit ae00a08 into EOSIO:develop Jan 11, 2019
@c0d3ster
Copy link
Copy Markdown
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants