Package Management (Bun)
Relevant source files
The following files were used as context for generating this wiki page:
The @pcstyle/auth project utilizes Bun as its primary package manager and runtime environment for local development and installation. It serves as a unified authentication SDK for PCSTYLE services, integrating heavily with WorkOS AuthKit and Next.js.
The project structure is designed to be highly modular, using tsup for bundling TypeScript source code into multiple formats (CJS and ESM) and entry points. This ensures compatibility across different environments while maintaining a strict type system via TypeScript.
Sources: package.json:2-4, README.md:1-5, tsup.config.ts:3-15
Dependency Ecosystem
The project differentiates between runtime dependencies, peer dependencies (required from the consuming application), and development-only tools.
Installation and Usage
Consumers are instructed to use Bun for adding the SDK to their projects. This ensures consistent dependency resolution within the PCSTYLE ecosystem.
bun add @pcstyle/auth @workos-inc/authkit-nextjs
Sources: README.md:9-11
Dependency Categories
The following table outlines the package dependencies as defined in the project configuration:
| Category | Package | Version | Purpose |
|---|---|---|---|
| Peer | @workos-inc/authkit-nextjs | ^2.13.0 | Core authentication provider |
| Peer | next | >=14.0.0 | Target framework |
| Peer | react | >=18.0.0 | UI library |
| Dev | tsup | ^8.0.0 | Bundle and build tool |
| Dev | typescript | ^5 | Type safety and compilation |
| Dev | @types/node | ^20 | Node.js type definitions |
Sources: package.json:25-37
Build and Distribution Pipeline
The project uses tsup to manage the compilation of TypeScript files into distributable assets.
Entry Points
The package is configured with multiple entry points to allow consumers to import only the necessary modules (e.g., standard hooks vs. middleware vs. Convex integration).
The diagram above shows how source files are mapped to distribution files via the build process.
Sources: tsup.config.ts:4-8, package.json:7-22
Package Scripts
Standard lifecycle scripts are defined to handle development and production builds:
- build: Runs
tsupto generate thedistfolder containing CJS, ESM, and type definition files. - dev: Runs
tsupin watch mode for active development. - typecheck: Executes the TypeScript compiler (
tsc) without emitting files to verify type integrity.
Sources: package.json:20-24, tsup.config.ts:9-14
Development Configuration
The environment is configured to support modern JavaScript features and strict type checking.
TypeScript Configuration
The project targets ES2020 and uses the bundler module resolution strategy, which is optimal for tools like Bun and tsup.
| Option | Value | Description |
|---|---|---|
target | ES2020 | Modern JS output |
moduleResolution | bundler | Optimized for modern bundlers |
strict | true | Enables all strict type-checking options |
jsx | react-jsx | Supports React components without explicit imports |
Sources: tsconfig.json:3-16
Export Mapping
The package.json uses the exports field to define subpath exports, ensuring that deep imports (like @pcstyle/auth/middleware) are correctly resolved to the appropriate build artifact.
This mapping ensures environment-agnostic module resolution for consumers.
Sources: package.json:7-22
Summary
The package management strategy leverages Bun for speed and modern developer experience, while using tsup to provide a robust, multi-format distribution. By defining clear peer dependencies and modular entry points, the SDK maintains a lightweight footprint while ensuring compatibility with Next.js and React ecosystems.