Skip to content

Commit

Permalink
improve ESM, avoid using require in the source
Browse files Browse the repository at this point in the history
  • Loading branch information
libotony committed Oct 21, 2022
1 parent aff9f40 commit 9a60da7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"main": "dist/index.js",
"module": "esm/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./esm/index.js",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist",
"esm"
Expand Down Expand Up @@ -74,9 +81,9 @@
"dependencies": {
"@vechain/ethers": "^4.0.27-5",
"bignumber.js": "^7.2.1",
"blakejs": "^1.1.0",
"blakejs": "^1.1.2",
"elliptic": "6.5.4",
"fast-json-stable-stringify": "^2.0.0",
"fast-json-stable-stringify": "^2.1.0",
"js-sha3": "0.5.7",
"rlp": "^2.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/blake2b.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const blake = require('blakejs')
import blake from 'blakejs'

/**
* computes blake2b 256bit hash of given data
* @param data one or more Buffer | string
*/
export function blake2b256(...data: Array<Buffer | string>) {
const ctx = blake.blake2bInit(32, null)
const ctx = blake.blake2bInit(32)
data.forEach(d => {
if (Buffer.isBuffer(d)) {
blake.blake2bUpdate(ctx, d)
Expand Down
3 changes: 1 addition & 2 deletions src/certificate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { address } from './address'
import { blake2b256 } from './blake2b'
import { secp256k1 } from './secp256k1'

const fastJsonStableStringify = require('fast-json-stable-stringify')
import fastJsonStableStringify from 'fast-json-stable-stringify'

/**
* Client side self-signed certificate
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"inlineSourceMap": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": [
Expand Down

0 comments on commit 9a60da7

Please sign in to comment.