@zipbul/shared
v0.0.8
Published
Shared library for the @zipbul toolkit
Maintainers
Readme
@zipbul/shared
English | 한국어
Shared library for the @zipbul toolkit.
Provides common definitions — enums, constants, types, and utilities — used across multiple @zipbul packages.
📦 Installation
bun add @zipbul/shared📚 What's Inside
HTTP Enums
Type-safe const enum declarations that eliminate magic strings for HTTP methods, headers, and status codes.
import { HttpMethod, HttpHeader, HttpStatus } from '@zipbul/shared';
if (request.method === HttpMethod.Get) {
headers.set(HttpHeader.AccessControlAllowOrigin, '*');
return new Response('OK', { status: HttpStatus.Ok });
}| Export | Description |
|:-------------|:-------------------------------------|
| HttpMethod | Standard HTTP methods (Get, Post, Put, Patch, Delete, …) |
| HttpHeader | CORS-related HTTP headers (Fetch Standard, lowercase values) |
| HttpStatus | Common HTTP status codes (Ok, NoContent, …) |
Enums are
const enum— withisolatedModules: false, values are inlined at compile time with zero runtime footprint. See Aboutconst enumfor toolchain-specific behavior.
🔬 About const enum
All enums are declared as const enum, which has different behavior depending on your toolchain:
| Environment | Behavior |
|:------------|:---------|
| TypeScript (isolatedModules: false) | Values are inlined at compile time — no runtime object |
| Bundlers (Bun, esbuild, Vite) | Treated as regular enums — runtime object is emitted |
| isolatedModules: true / verbatimModuleSyntax: true | Import is preserved; the bundler resolves it at build time |
This means:
- Bun consumers can use the enums normally —
bun buildhandles the resolution - TypeScript library consumers get the benefit of compile-time inlining (zero runtime cost)
- The
.d.tsfiles preserve theconst enumdeclarations for downstream consumers
Note: When building with
verbatimModuleSyntax: trueandemitDeclarationOnly, you may need to setverbatimModuleSyntax: falseintsconfig.build.jsonto avoid TS2748. This is already handled in the build configuration.
📄 License
MIT