From da247eabfd1f1933b888c8d6dc2fb90af0f5565c Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Sun, 17 Mar 2024 13:22:10 +0000 Subject: [PATCH] Use jsbt for tsconfig and building --- .github/funding.yml | 1 - .github/workflows/nodejs.yml | 2 +- .github/workflows/publish-npm.yml | 2 +- .github/workflows/upload-release.yml | 11 ++- build/README.md | 4 +- build/package-lock.json | 133 +-------------------------- build/package.json | 6 +- package-lock.json | 10 ++ package.json | 1 + tsconfig.esm.json | 21 +---- tsconfig.json | 14 +-- 11 files changed, 35 insertions(+), 170 deletions(-) diff --git a/.github/funding.yml b/.github/funding.yml index 43f16ab..09d9be7 100644 --- a/.github/funding.yml +++ b/.github/funding.yml @@ -1,2 +1 @@ github: paulmillr -# custom: https://paulmillr.com/funding/ \ No newline at end of file diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9b2c2c0..81bf353 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,4 +1,4 @@ -name: Node CI +name: Run node.js tests on: - push - pull_request diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 339e831..cd57db8 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -1,4 +1,4 @@ -name: Publish Package to npm +name: Publish package to npm on: release: types: [created] diff --git a/.github/workflows/upload-release.yml b/.github/workflows/upload-release.yml index bde7db8..b8c2ca9 100644 --- a/.github/workflows/upload-release.yml +++ b/.github/workflows/upload-release.yml @@ -15,13 +15,14 @@ jobs: node-version: 20 registry-url: 'https://registry.npmjs.org' cache: npm + - run: npm install -g npm + - run: npm ci + - run: npm run build - run: | - npm install -g npm - npm ci - npm run build cd build npm ci - npm run build - gh release upload ${{ github.event.release.tag_name }} noble-ciphers.js + npm run build:release + cd .. + - run: gh release upload ${{ github.event.release.tag_name }} build/`npx jsbt outfile` env: GH_TOKEN: ${{ github.token }} diff --git a/build/README.md b/build/README.md index 70e1182..c1752b2 100644 --- a/build/README.md +++ b/build/README.md @@ -1,7 +1,7 @@ # build -The directory is used to build a single file `noble-ciphers.js` which contains everything. +The directory is used to build a single file which contains everything. -The output file uses iife wrapper and can be used in browsers as-is. +The single file uses iife wrapper and can be used in browsers as-is. Don't use it unless you can't use NPM/ESM, which support tree shaking. diff --git a/build/package-lock.json b/build/package-lock.json index 37c8eae..c799706 100644 --- a/build/package-lock.json +++ b/build/package-lock.json @@ -7,18 +7,17 @@ "": { "name": "build", "version": "1.0.0", - "license": "MIT", "devDependencies": { "@noble/ciphers": "file:..", "esbuild": "0.20.1" } }, "..": { - "name": "@noble/ciphers", "version": "0.5.1", "dev": true, "license": "MIT", "devDependencies": { + "@paulmillr/jsbt": "0.1.0", "@scure/base": "1.1.3", "fast-check": "3.0.0", "micro-bmark": "0.3.1", @@ -30,136 +29,6 @@ "url": "https://paulmillr.com/funding/" } }, - "../node_modules/.pnpm/@scure+base@1.1.1/node_modules/@scure/base": { - "version": "1.1.1", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "license": "MIT", - "devDependencies": { - "micro-should": "0.2.0", - "prettier": "2.6.2", - "typescript": "4.7.3" - } - }, - "../node_modules/.pnpm/fast-check@3.0.0": { - "dev": true - }, - "../node_modules/.pnpm/fast-check@3.0.0/node_modules/fast-check": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "pure-rand": "^5.0.1" - }, - "engines": { - "node": ">=8.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - }, - "../node_modules/.pnpm/fast-check@3.0.0/node_modules/pure-rand": { - "resolved": "../node_modules/.pnpm/pure-rand@5.0.5/node_modules/pure-rand", - "link": true - }, - "../node_modules/.pnpm/micro-bmark@0.3.1/node_modules/micro-bmark": { - "version": "0.3.1", - "dev": true, - "license": "MIT" - }, - "../node_modules/.pnpm/micro-should@0.4.0/node_modules/micro-should": { - "version": "0.4.0", - "dev": true, - "license": "MIT" - }, - "../node_modules/.pnpm/prettier@2.8.4/node_modules/prettier": { - "version": "2.8.4", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "../node_modules/.pnpm/pure-rand@5.0.5/node_modules/pure-rand": { - "version": "5.0.5", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "license": "MIT", - "devDependencies": { - "@types/jest": "^27.0.1", - "@types/node": "^18.6.3", - "cross-env": "^7.0.3", - "fast-check": "^3.1.1", - "jest": "^26.1.0", - "prettier": "2.7.1", - "replace-in-file": "^6.1.0", - "source-map-support": "^0.5.16", - "tinybench": "^2.3.1", - "ts-jest": "^26.1.2", - "ts-node": "^10.0.0", - "typescript": "^4.0.2" - } - }, - "../node_modules/.pnpm/typescript@5.0.2": { - "dev": true - }, - "../node_modules/.pnpm/typescript@5.0.2/node_modules/typescript": { - "version": "5.0.2", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=12.20" - } - }, - "../node_modules/@scure/base": { - "resolved": "../node_modules/.pnpm/@scure+base@1.1.1/node_modules/@scure/base", - "link": true - }, - "../node_modules/fast-check": { - "resolved": "../node_modules/.pnpm/fast-check@3.0.0/node_modules/fast-check", - "link": true - }, - "../node_modules/micro-bmark": { - "resolved": "../node_modules/.pnpm/micro-bmark@0.3.1/node_modules/micro-bmark", - "link": true - }, - "../node_modules/micro-should": { - "resolved": "../node_modules/.pnpm/micro-should@0.4.0/node_modules/micro-should", - "link": true - }, - "../node_modules/prettier": { - "resolved": "../node_modules/.pnpm/prettier@2.8.4/node_modules/prettier", - "link": true - }, - "../node_modules/typescript": { - "resolved": "../node_modules/.pnpm/typescript@5.0.2/node_modules/typescript", - "link": true - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.20.1", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.1.tgz", diff --git a/build/package.json b/build/package.json index 6222a20..96df46d 100644 --- a/build/package.json +++ b/build/package.json @@ -2,17 +2,13 @@ "name": "build", "private": true, "version": "1.0.0", - "description": "Used to build a single file", "main": "input.js", - "keywords": [], "type": "module", - "author": "", - "license": "MIT", "devDependencies": { "@noble/ciphers": "file:..", "esbuild": "0.20.1" }, "scripts": { - "build": "npx esbuild --bundle input.js --outfile=noble-ciphers.js --global-name=nobleCiphers" + "build:release": "npx esbuild --bundle input.js --outfile=`npx jsbt outfile` --global-name=`npx jsbt global`" } } diff --git a/package-lock.json b/package-lock.json index 8b89578..afc5b0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.5.1", "license": "MIT", "devDependencies": { + "@paulmillr/jsbt": "0.1.0", "@scure/base": "1.1.3", "fast-check": "3.0.0", "micro-bmark": "0.3.1", @@ -20,6 +21,15 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/@paulmillr/jsbt": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@paulmillr/jsbt/-/jsbt-0.1.0.tgz", + "integrity": "sha512-TdowoHD36hkZARv6LW4jenkVTdK2vP0sy4ZM8E9MxaqAAIRdwmn3RlB+zWkEHi4hKTgLqMGkURfNkFtt0STX2Q==", + "dev": true, + "bin": { + "jsbt": "jsbt.js" + } + }, "node_modules/@scure/base": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", diff --git a/package.json b/package.json index 5f8b9c7..daee43e 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "license": "MIT", "sideEffects": false, "devDependencies": { + "@paulmillr/jsbt": "0.1.0", "@scure/base": "1.1.3", "fast-check": "3.0.0", "micro-bmark": "0.3.1", diff --git a/tsconfig.esm.json b/tsconfig.esm.json index ac89181..e205140 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,25 +1,12 @@ { + "extends": "@paulmillr/jsbt/tsconfigs/esm.json", "compilerOptions": { - "target": "es2020", - "lib": ["es2020"], - "strict": true, - "sourceMap": true, - "allowSyntheticDefaultImports": false, - "allowUnreachableCode": false, - "esModuleInterop": false, - "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "noUncheckedIndexedAccess": false, - "noUnusedLocals": true, - "noUnusedParameters": true, + "outDir": "esm", "baseUrl": ".", "paths": { "@noble/ciphers/crypto": ["src/crypto.ts"] - }, - "module": "Node16", - "outDir": "esm", - "moduleResolution": "Node16" + } }, - "include": ["src"], + "include": ["index.ts", "src"], "exclude": ["node_modules", "lib"] } diff --git a/tsconfig.json b/tsconfig.json index 763639d..918e6e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,12 @@ { - "extends": "./tsconfig.esm.json", + "extends": "@paulmillr/jsbt/tsconfigs/cjs.json", "compilerOptions": { - "module": "commonjs", - "moduleResolution": "node10", "outDir": ".", - "declaration": true, - "declarationMap": true - } + "baseUrl": ".", + "paths": { + "@noble/ciphers/crypto": ["src/crypto.ts"] + } + }, + "include": ["index.ts", "src"], + "exclude": ["node_modules", "lib"] }