Users were unable to import the individual methods from the subfolders within the package dist. This update provides the ability to perform these individual imports, rather than having to import in the full package.
Changes
updated package json with exports field to be able to import subfolders from the package
added a new entry to both npmingnore and gitignore, this was the folder i used for testing the changes to package.json
GitHub Issue or Linear Task
How Has This Been Tested?
created new npm project
linked @entropyxyz/sdk to new project
imported in new package and logged contents
Code:
import Entropy from '@entropyxyz/sdk'; import { getWallet } from '@entropyxyz/sdk/keys'; import * as crypto from '@entropyxyz/sdk/cypto-utils'; import * as utils from '@entropyxyz/sdk/gen-utils'; console.log(Entropy); console.log(getWallet); console.log(crypto); console.log(utils);
Result: [class Entropy] [AsyncFunction (anonymous)] [Module: null prototype] { crypto: {}, cryptoIsLoaded: Promise { <pending> }, loadCryptoLib: [AsyncFunction: loadCryptoLib] } [Module: null prototype] { buf2hex: [Function: buf2hex], hex2buf: [Function: hex2buf], isValidSubstrateAddress: [Function: isValidSubstrateAddress], sendHttpPost: [AsyncFunction: sendHttpPost], stripHexPrefix: [Function: stripHexPrefix], typeofthing: [Function: typeofthing] }
Description
Users were unable to import the individual methods from the subfolders within the package dist. This update provides the ability to perform these individual imports, rather than having to import in the full package.
Changes
GitHub Issue or Linear Task
How Has This Been Tested?
import Entropy from '@entropyxyz/sdk'; import { getWallet } from '@entropyxyz/sdk/keys'; import * as crypto from '@entropyxyz/sdk/cypto-utils'; import * as utils from '@entropyxyz/sdk/gen-utils'; console.log(Entropy); console.log(getWallet); console.log(crypto); console.log(utils);
Result:[class Entropy] [AsyncFunction (anonymous)] [Module: null prototype] { crypto: {}, cryptoIsLoaded: Promise { <pending> }, loadCryptoLib: [AsyncFunction: loadCryptoLib] } [Module: null prototype] { buf2hex: [Function: buf2hex], hex2buf: [Function: hex2buf], isValidSubstrateAddress: [Function: isValidSubstrateAddress], sendHttpPost: [AsyncFunction: sendHttpPost], stripHexPrefix: [Function: stripHexPrefix], typeofthing: [Function: typeofthing] }