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 058df92 commit 4645a2b
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 45 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 }} noble-hashes.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: 2 additions & 2 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# build

The directory is used to build a single file `noble-hashes.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.
3 changes: 1 addition & 2 deletions build/package-lock.json

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

6 changes: 1 addition & 5 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": {
"@noble/hashes": "file:..",
"esbuild": "0.20.1"
},
"scripts": {
"build": "npx esbuild --bundle input.js --outfile=noble-hashes.js --global-name=nobleHashes"
"build:release": "npx esbuild --bundle input.js --outfile=`npx jsbt outfile` --global-name=`npx jsbt global`"
}
}
14 changes: 12 additions & 2 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
"scripts": {
"bench": "node benchmark/index.js noble",
"bench:all": "node benchmark/index.js",
"bench:install": "cd benchmark && npm install && cd ../../",
"bench:install": "cd benchmark && npm install && cd ..",
"build": "npm run build:clean; tsc && tsc -p tsconfig.esm.json",
"build:release": "cd build && npm i && npm run build",
"build:clean": "rm *.{js,d.ts,js.map} esm/*.{js,js.map} 2> /dev/null",
"build:clean": "rm *.{js,d.ts,js.map,d.ts.map} esm/*.{js,js.map,d.ts.map} 2> /dev/null",
"lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"format": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"test": "node test/index.js",
Expand All @@ -35,6 +34,7 @@
"./crypto": "./crypto.js"
},
"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"micro-bmark": "0.3.1",
"micro-should": "0.4.0",
"prettier": "3.1.1",
Expand Down
21 changes: 4 additions & 17 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
{
"extends": "@paulmillr/jsbt/tsconfigs/esm-less-strict.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/hashes/crypto": ["src/crypto.ts"]
},
"module": "Node16",
"outDir": "esm",
"moduleResolution": "Node16"
}
},
"include": ["src"],
"include": ["index.ts", "src"],
"exclude": ["node_modules", "lib"]
}
14 changes: 8 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "./tsconfig.esm.json",
"extends": "@paulmillr/jsbt/tsconfigs/cjs.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node10",
"baseUrl": ".",
"outDir": ".",
"declaration": true,
"declarationMap": true
}
"paths": {
"@noble/hashes/crypto": ["src/crypto.ts"]
}
},
"include": ["index.ts", "src"],
"exclude": ["node_modules", "lib"]
}

0 comments on commit 4645a2b

Please sign in to comment.