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 eb06b72 commit 51b80ab
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 48 deletions.
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 }} micro-eth-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 }}
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.
2 changes: 1 addition & 1 deletion build/input.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { addr, Transaction, messenger } from 'micro-eth-signer';
export { addr, Transaction, messenger } from 'lib';
12 changes: 6 additions & 6 deletions build/package-lock.json

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

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": {
"micro-eth-signer": "file:..",
"lib": "file:..",
"esbuild": "0.20.1"
},
"scripts": {
"build": "npx esbuild --bundle input.js --outfile=micro-eth-signer.js --global-name=ethSigner"
"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.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"micro-packed": "~0.5.3"
},
"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"micro-bmark": "0.3.1",
"micro-should": "0.4.0",
"prettier": "3.1.1",
Expand Down Expand Up @@ -70,10 +71,10 @@
],
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"build:release": "cd build; npm run build",
"build:release": "cd build; npm run build:release",
"bench": "node benchmark/tx.js",
"lint": "prettier --print-width 100 --single-quote --check src",
"format": "prettier --print-width 100 --single-quote --write src",
"test": "node test/index.js"
}
}
}
20 changes: 1 addition & 19 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
{
"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": "src",

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

0 comments on commit 51b80ab

Please sign in to comment.