Skip to content

Commit

Permalink
Use jsbt for tsconfig and building
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Mar 17, 2024
1 parent bc2f01f commit 6604c65
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 49 deletions.
1 change: 0 additions & 1 deletion .github/funding.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github: paulmillr
# custom: https://paulmillr.com/funding/
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node CI
name: Run node.js tests
on:
- push
- pull_request
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Package to npm
name: Publish package to npm
on:
release:
types: [created]
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/upload-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} scure-btc-signer.js
npm run build:release
cd ..
- run: gh release upload ${{ github.event.release.tag_name }} build/`npx jsbt outfile`
env:
GH_TOKEN: ${{ github.token }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
/build/scure-btc-signer.js
/lib
/index.js
/index.d.ts
/index.d.ts
/index.d.ts.map
/index.map
7 changes: 7 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# build

The directory is used to build a single file which contains everything.

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.
14 changes: 7 additions & 7 deletions build/input.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export { Transaction } from '../lib/esm/index.js';
export { Transaction } from 'lib';
export {
p2pk, p2pkh, p2sh, p2ms, p2wsh, p2wpkh, p2tr, p2tr_ns, p2tr_ms, p2tr_pk,
} from '../lib/esm/index.js';
export { OP, RawTx, CompactSize, Script, ScriptNum } from '../lib/esm/index.js';
export { selectUTXO } from '../lib/esm/index.js';
export { NETWORK, TAPROOT_UNSPENDABLE_KEY } from '../lib/esm/index.js';
export { Address, getAddress, WIF, OutScript } from '../lib/esm/index.js';
export { Decimal, bip32Path, SigHash, PSBTCombine } from '../lib/esm/index.js';
} from 'lib';
export { OP, RawTx, CompactSize, Script, ScriptNum } from 'lib';
export { selectUTXO } from 'lib';
export { NETWORK, TAPROOT_UNSPENDABLE_KEY } from 'lib';
export { Address, getAddress, WIF, OutScript } from 'lib';
export { Decimal, bip32Path, SigHash, PSBTCombine } from 'lib';
8 changes: 2 additions & 6 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
"@scure/btc-signer": "file:..",
"lib": "file:..",
"esbuild": "0.20.1"
},
"scripts": {
"build:release": "npx esbuild --bundle input.js --outfile=scure-btc-signer.js --global-name=btcSigner"
"build:release": "npx esbuild --bundle input.js --outfile=`npx jsbt outfile` --global-name=`npx jsbt global`"
}
}
10 changes: 10 additions & 0 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"micro-packed": "~0.5.3"
},
"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"@scure/bip32": "~1.3.3",
"micro-should": "0.4.0",
"prettier": "3.1.1",
Expand All @@ -42,7 +43,6 @@
},
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"build:release": "cd build && npm run build:release",
"lint": "prettier --check index.ts",
"format": "prettier --write index.ts",
"test": "node test/index.test.js && node test/psbt-test/bip174-psbt-extended.test.js",
Expand All @@ -66,4 +66,4 @@
"p2tr"
],
"funding": "https://paulmillr.com/funding/"
}
}
21 changes: 3 additions & 18 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
{
"extends": "@paulmillr/jsbt/tsconfigs/esm.json",
"compilerOptions": {
"target": "es2020",
"lib": ["es2020"],
"strict": true,
"sourceMap": false,
"allowSyntheticDefaultImports": false,
"allowUnreachableCode": false,
"esModuleInterop": false,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"baseUrl": ".",

"module": "es2020",
"outDir": "lib/esm",
"moduleResolution": "bundler"
"outDir": "lib/esm"
},
"include": ["index.ts"],
"include": ["index.ts", "src"],
"exclude": ["node_modules", "lib"]
}
12 changes: 5 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"extends": "./tsconfig.esm.json",
"extends": "@paulmillr/jsbt/tsconfigs/cjs.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node10",
"outDir": "lib",
"declaration": true,
"declarationMap": true
}
"outDir": "lib"
},
"include": ["index.ts", "src"],
"exclude": ["node_modules", "lib"]
}

0 comments on commit 6604c65

Please sign in to comment.