diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 29495df..146a71b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [ 14, 16, 18, 19 ] + node-version: [ 16, 18, 20 ] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} diff --git a/Makefile b/Makefile index 4865c3b..5897963 100755 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ ALL=\ all: $(ALL) +# ES5 - CommonJS for browsers dist/sha256-uint8array.min.js: build/bundle.js @mkdir -p dist node_modules/.bin/terser -c -m --mangle-props "regex=/^_/" --ecma 5 -o $@ $< @@ -18,12 +19,15 @@ build/bundle.js: build/es5/sha256-uint8array.js echo '})(SHA256)' >> $@ perl -i -pe 's#^("use strict"|Object.defineProperty|exports.*= void 0)#// $$&#' $@ +# ES5 - CommonJS build/es5/%.js: lib/%.ts node_modules/.bin/tsc -p tsconfig-es5.json +# ES2021 - ES Module build/esm/%.js: node_modules/.bin/tsc -p tsconfig-esm.json +# ES2021 - ES Module dist/%.mjs: build/esm/%.js cp $^ $@ @@ -33,11 +37,12 @@ build/test.js: all node_modules/.bin/browserify -o $@ test/*.js \ -t [ browserify-sed 's#(require\("(?:../)+)("\))#$$1browser/import$$2#' ] +# ES2021 - CommonJS lib/%.js: lib/%.ts node_modules/.bin/tsc -p tsconfig.json clean: - /bin/rm -fr build dist/*.js lib/*.js test/*.js + /bin/rm -fr $(ALL) build/ lib/*.js test/*.js sizes: wc -c dist/sha256-uint8array.min.js diff --git a/package.json b/package.json index 0a683cc..b7cdcd9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sha256-uint8array", "description": "Fast SHA-256 digest hash based on Uint8Array, pure JavaScript.", - "version": "0.10.5", + "version": "0.10.6", "author": "Yusuke Kawasaki ", "bugs": { "url": "https://github.com/kawanet/sha256-uint8array/issues" @@ -19,15 +19,20 @@ "crypto-js": "^4.1.1", "hash.js": "^1.1.7", "jshashes": "^1.0.8", - "jssha": "^3.3.0", + "jssha": "^3.3.1", "mocha": "^10.2.0", "sha.js": "^2.4.11", - "terser": "^5.16.4", - "typescript": "^4.9.5" + "terser": "^5.19.2", + "typescript": "^5.1.6" }, "exports": { - "require": "./lib/sha256-uint8array.js", - "import": "./dist/sha256-uint8array.mjs" + ".": { + "require": "./lib/sha256-uint8array.js", + "import": { + "default": "./dist/sha256-uint8array.mjs", + "types": "./types/sha256-uint8array.d.ts" + } + } }, "files": [ "LICENSE", diff --git a/test/99.benchmark.ts b/test/99.benchmark.ts index bd1aed4..93f5a5b 100644 --- a/test/99.benchmark.ts +++ b/test/99.benchmark.ts @@ -8,7 +8,7 @@ const TITLE = __filename.split("/").pop()!!; const isBrowser = ("undefined" !== typeof window); const isLegacy = ("function" !== typeof TextEncoder); -const REPEAT = process.env.REPEAT || (isBrowser ? (isLegacy ? 1000 : 10000) : 10000); +const REPEAT = +(process.env.REPEAT || (isBrowser ? (isLegacy ? 1000 : 10000) : 10000)); const SLEEP = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); const stringToArray = (str: string) => [].map.call(unescape(encodeURIComponent(str)), (c: string) => c.charCodeAt(0)) diff --git a/tsconfig-esm.json b/tsconfig-esm.json index db152ee..b8ab595 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -14,6 +14,6 @@ "removeComments": false, "skipLibCheck": true, "strictNullChecks": true, - "target": "ES2020" + "target": "ES2021" } } diff --git a/tsconfig.json b/tsconfig.json index 0ce7bfd..8db64d1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,6 @@ "removeComments": false, "skipLibCheck": true, "strictNullChecks": true, - "target": "ES2020" + "target": "ES2021" } }