Skip to content

Commit f239682

Browse files
committed
feat: update build system
1 parent 6055ef1 commit f239682

File tree

5 files changed

+68
-14
lines changed

5 files changed

+68
-14
lines changed

bun.lockb

-34.7 KB
Binary file not shown.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
"email": "[email protected]"
99
},
1010
"type": "module",
11-
"exports": {
12-
".": {
13-
"require": "./dist/index.cjs",
14-
"import": "./dist/index.mjs",
15-
"types": "./dist/index.d.ts"
16-
}
17-
},
18-
"main": "./dist/index.cjs",
11+
"main": "./dist/cjs/index.js",
1912
"module": "./dist/index.mjs",
2013
"types": "./dist/index.d.ts",
14+
"exports": {
15+
"./package.json": "./package.json",
16+
".": {
17+
"types": "./dist/index.d.ts",
18+
"import": "./dist/index.mjs",
19+
"require": "./dist/cjs/index.js"
20+
}
21+
},
2122
"files": [
2223
"dist"
2324
],
@@ -36,10 +37,9 @@
3637
"dev": "bun run --watch example/index.ts",
3738
"format": "prettier --write .",
3839
"format:check": "prettier --check .",
39-
"build": "unbuild",
40+
"build": "bun run scripts/build.ts",
4041
"bump": "bun run scripts/bump.ts",
41-
"release": "bun run scripts/release.ts",
42-
"test": "vitest"
42+
"release": "bun run scripts/release.ts"
4343
},
4444
"peerDependencies": {
4545
"elysia": ">=1.2.0"
@@ -49,8 +49,8 @@
4949
"@types/bun": "^1.1.14",
5050
"elysia": "^1.2.6",
5151
"prettier": "^3.4.2",
52-
"typescript": "^5.7.2",
53-
"unbuild": "^3.0.1"
52+
"tsup": "^8.3.5",
53+
"typescript": "^5.7.2"
5454
},
5555
"dependencies": {
5656
"picocolors": "^1.1.1"

scripts/build.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { $ } from "bun";
2+
import pc from "picocolors";
3+
import { build, type Options } from "tsup";
4+
5+
await $`rm -rf dist`;
6+
7+
const tsupConfig: Options = {
8+
entry: ["src/**/*.ts"],
9+
splitting: false,
10+
sourcemap: false,
11+
clean: true,
12+
bundle: true,
13+
} satisfies Options;
14+
15+
await Promise.all([
16+
build({
17+
outDir: "dist",
18+
format: "esm",
19+
target: "node20",
20+
cjsInterop: false,
21+
...tsupConfig,
22+
}),
23+
build({
24+
outDir: "dist/cjs",
25+
format: "cjs",
26+
target: "node20",
27+
...tsupConfig,
28+
}),
29+
]);
30+
31+
await $`tsc --project tsconfig.dts.json`.then(() =>
32+
console.log(pc.magenta("DTS"), "⚡ Files generated"),
33+
);
34+
35+
await Promise.all([$`cp dist/*.d.ts dist/cjs`]);
36+
37+
process.exit();

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const logger = (options: LoggerOptions = {}) => {
6969
return;
7070
}
7171

72-
const ELYSIA_VERSION = import.meta.require("elysia/package.json").version;
72+
const ELYSIA_VERSION = require("elysia/package.json").version;
7373
console.log(`🦊 ${pc.green(`${pc.bold("Elysia")} v${ELYSIA_VERSION}`)}`);
7474

7575
if (typeof options.withBanner === "object") {

tsconfig.dts.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"moduleResolution": "node",
5+
"allowSyntheticDefaultImports": true,
6+
7+
"noEmit": false,
8+
"declaration": true,
9+
"emitDeclarationOnly": true,
10+
11+
"rootDir": "./src",
12+
"outDir": "./dist",
13+
},
14+
"include": [
15+
"./src/**/*.ts",
16+
]
17+
}

0 commit comments

Comments
 (0)