Skip to content

Commit

Permalink
use esbuild for make dist
Browse files Browse the repository at this point in the history
  • Loading branch information
norbornen committed Jun 19, 2023
1 parent 4dd92c5 commit 77e6d31
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 6 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"homepage": "https://github.com/norbornen/execution-time-decorator#readme",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc --strict",
"build": "npm run build:common && npm run build:types",
"build:common": "esbuild src/index.ts --platform=node --target=es2021 --outdir=dist --sourcemap --bundle --minify",
"build:types": "tsc --emitDeclarationOnly --declaration --project tsconfig.json",
"build:ts": "tsc --strict",
"prepublishOnly": "npm run build",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" && tsc --noEmit",
"test": "jest --verbose --env=node",
Expand All @@ -40,6 +43,7 @@
"@types/node": "20",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"esbuild": "^0.18.4",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
Expand Down
236 changes: 234 additions & 2 deletions pnpm-lock.yaml

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

4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Logger, PerfLogger } from './perf-logger';
import { isPromise } from './utils';

/**
* @example
* "@timer({ logger: pino, logArguments: true, hr: false })"
*/
export function timer({
logger,
logArguments = false,
Expand Down
4 changes: 1 addition & 3 deletions src/utils/is-promise.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import util from 'node:util';

export function isPromise<T = unknown>(p: T | Promise<T>): p is Promise<T> {
if (util.types.isPromise(p)) {
if (p instanceof Promise) {
return true;
}
if (
Expand Down

0 comments on commit 77e6d31

Please sign in to comment.