Skip to content

Commit 19c9172

Browse files
committed
version 1.0.1, minimize size and fix deprecation messages not shown
1 parent 6532dfe commit 19c9172

File tree

8 files changed

+66
-37
lines changed

8 files changed

+66
-37
lines changed

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "better-status-codes",
33
"description": "A much better way to handle HTTP status codes in your applications. Zero dependencies, batteries included.",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"license": "BSD-3-Clause",
66
"author": "Md. Touhidur Rahman",
77
"main": "dist/index.js",
@@ -16,19 +16,20 @@
1616
"url": "https://github.com/touhidurrr/better-status-codes/issues"
1717
},
1818
"scripts": {
19-
"build": "tsup",
20-
"lint": "tsc",
21-
"format": "prettier --write ."
19+
"lint": "tsc --noEmit",
20+
"format": "prettier --write .",
21+
"build:esm": "tsc -p tsconfig.esm.json",
22+
"build:cjs": "tsc -p tsconfig.cjs.json",
23+
"build:dts": "tsc -p tsconfig.dts.json",
24+
"build": "bun scripts/build.ts"
2225
},
2326
"devDependencies": {
24-
"@swc/core": "^1.4.17",
2527
"@types/bun": "latest",
2628
"@types/http-status-codes": "^1.2.0",
2729
"@types/statuses": "^2.0.5",
2830
"http-status-codes": "^2.3.0",
2931
"prettier": "^3.2.5",
3032
"statuses": "^2.0.1",
31-
"tsup": "^8.0.2",
3233
"typescript": "^5.4.5"
3334
}
3435
}

scripts/build.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Glob, spawn, spawnSync } from "bun";
2+
import { rename } from "node:fs/promises";
3+
4+
const glob = new Glob("dist/*.js");
5+
6+
(async () => {
7+
spawnSync(["bun", "build:esm"]);
8+
9+
const renameTasks = [];
10+
for await (const file of glob.scan(".")) {
11+
const task = rename(file, file.replace(/\.js$/, ".mjs"));
12+
renameTasks.push(task);
13+
}
14+
await Promise.all(renameTasks);
15+
16+
spawn(["bun", "build:cjs"]);
17+
spawn(["bun", "build:dts"]);
18+
})();

src/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { StatusCodes } from "./codes";
22
import { StatusTexts } from "./texts";
33

44
// aliases of StatusCodes
5-
export const Status = StatusCodes;
6-
export const Code = StatusCodes;
5+
export { StatusCodes as Status, StatusCodes as Code };
76

87
// aliases of StatusTexts
9-
export const Text = StatusTexts;
10-
export const Reason = StatusTexts;
11-
export const Message = StatusTexts;
12-
export const StatusText = StatusTexts;
13-
export const StatusMessage = StatusTexts;
14-
export const ReasonPhrase = StatusTexts;
8+
export {
9+
StatusTexts as Text,
10+
StatusTexts as Reason,
11+
StatusTexts as Message,
12+
StatusTexts as StatusText,
13+
StatusTexts as StatusMessage,
14+
StatusTexts as ReasonPhrase,
15+
};

tsconfig.cjs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"target": "ES5",
5+
"module": "CommonJS",
6+
"moduleResolution": "Classic"
7+
},
8+
"include": ["src"]
9+
}

tsconfig.dts.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"emitDeclarationOnly": true
6+
},
7+
"include": ["src"]
8+
}

tsconfig.esm.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"target": "ES5",
5+
"module": "ES6"
6+
},
7+
"include": ["src"]
8+
}

tsconfig.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
{
2-
"include": ["src", "tests"],
32
"compilerOptions": {
43
// Enable latest features
54
"lib": ["ESNext"],
6-
"target": "ESNext",
7-
"module": "ESNext",
8-
"moduleDetection": "force",
9-
10-
// Bundler mode
11-
"moduleResolution": "bundler",
12-
"allowImportingTsExtensions": true,
13-
"verbatimModuleSyntax": true,
14-
"noEmit": true,
155

166
// Best practices
177
"strict": true,
@@ -21,6 +11,12 @@
2111
// Some stricter flags (disabled by default)
2212
"noUnusedLocals": false,
2313
"noUnusedParameters": false,
24-
"noPropertyAccessFromIndexSignature": false
14+
"noPropertyAccessFromIndexSignature": false,
15+
16+
// Others
17+
"outDir": "dist",
18+
"target": "ESNext",
19+
"esModuleInterop": true,
20+
"moduleResolution": "Bundler"
2521
}
2622
}

tsup.config.ts

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

0 commit comments

Comments
 (0)