Skip to content

Commit 51c9e1a

Browse files
build(package): use tsup for building
1 parent d06071c commit 51c9e1a

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

bun.lockb

21.2 KB
Binary file not shown.

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
"files": [
88
"dist/**/*"
99
],
10-
"main": "dist/index.js",
11-
"module": "dist/index.mjs",
12-
"types": "dist/index.d.ts",
10+
"main": "./dist/cjs/index.js",
11+
"module": "./dist/esm/index.mjs",
1312
"exports": {
1413
".": {
15-
"import": "./dist/index.mjs",
16-
"require": "./dist/index.js",
17-
"types": "./dist/index.d.ts"
14+
"import": {
15+
"default": "./dist/esm/index.mjs",
16+
"types": "./dist/esm/index.d.mts"
17+
},
18+
"require": {
19+
"default": "./dist/cjs/index.js",
20+
"types": "./dist/cjs/index.d.ts"
21+
}
1822
},
1923
"./package.json": "./package.json"
2024
},
@@ -32,17 +36,14 @@
3236
"bun"
3337
],
3438
"scripts": {
35-
"build": "bun exec 'rm -rf dist' && bun build:code && bun build:types",
36-
"build:code": "bun build:code:base --format=esm --out-extension:.js=.mjs && bun build:code:base --format=cjs",
37-
"build:code:base": "bun --bun esbuild src/index.ts --target=es6 --bundle --minify --outdir=dist",
38-
"build:types": "bun --bun tsc --emitDeclarationOnly --project tsconfig.build.json",
39+
"build": "bun --bun tsup",
3940
"check-all": "bun test && bun lint && bun type-check && bun format:check",
4041
"test": "bun test",
4142
"format": "bun format:base --write",
4243
"format:check": "bun format:base --check",
4344
"format:base": "bun --bun prettier . --cache",
4445
"lint": "bun --bun eslint . --cache",
45-
"type-check": "bun --bun tsc --noEmit",
46+
"type-check": "bun --bun tsc",
4647
"clean-pakage-json": "npm pkg delete scripts devDependencies"
4748
},
4849
"devDependencies": {
@@ -52,13 +53,13 @@
5253
"@types/semver": "^7.5.8",
5354
"@typescript-eslint/eslint-plugin": "^7.11.0",
5455
"@typescript-eslint/parser": "^7.11.0",
55-
"esbuild": "^0.21.4",
5656
"eslint": "^8.57.0",
5757
"eslint-config-prettier": "^9.1.0",
5858
"husky": "^9.0.11",
5959
"prettier": "^3.3.0",
6060
"semantic-release": "^24.0.0",
6161
"semver": "^7.6.2",
62+
"tsup": "SunsetTechuila/tsup#dist",
6263
"typescript": "^5.4.5"
6364
}
6465
}

tsconfig.build.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"moduleDetection": "force",
88
"verbatimModuleSyntax": true,
99
"esModuleInterop": true,
10+
"noEmit": true,
1011

1112
"skipLibCheck": true,
1213
"strict": true,

tsup.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig, type Options } from "tsup";
2+
3+
const baseConfig = {
4+
entry: ["src/index.ts"],
5+
target: "es2019",
6+
dts: true,
7+
clean: true,
8+
} satisfies Options;
9+
10+
const cjsConfig = {
11+
...baseConfig,
12+
format: "cjs",
13+
outDir: "dist/cjs",
14+
} satisfies Options;
15+
16+
const esmConfig = {
17+
...baseConfig,
18+
format: "esm",
19+
outDir: "dist/esm",
20+
} satisfies Options;
21+
22+
export default defineConfig([cjsConfig, esmConfig]);

0 commit comments

Comments
 (0)