Package Configuration & Build
Relevant source files
The following files were used as context for generating this wiki page:
The @cellarnode/auth package is a shared TypeScript library providing OTP-based authentication utilities, including a token store, an API client, and React UI components designed for CellarNode dashboards. It is configured as a modern ES module with high-level type safety and strict build requirements to ensure compatibility across various frontend environments.
Sources: package.json:1-5, README.md:1-3
Package Architecture and Exports
The package is structured to provide both framework-agnostic core logic and framework-specific React components. It uses a dual-entry point strategy defined in package.json to separate core logic from React dependencies, allowing consumers to import only what is necessary.
Sources: package.json:14-25, src/index.ts:1-24, src/react/index.ts:1-17
Export Strategy
The package exposes two primary entry points:
- Core (
.): Contains the auth store, API client, and type definitions. - React (
./react): Contains UI components likeLoginForm,RegisterForm, andUnauthorizedPage.
| Entry Point | Description | Key Exports |
|---|---|---|
@cellarnode/auth | Core Logic | createAuthStore, createAuthClient, createAuthApi, AuthError |
@cellarnode/auth/react | UI Components | LoginForm, RegisterForm, UnauthorizedPage, SquircleShift |
Sources: package.json:15-22, README.md:32-34
Dependency Management
The library distinguishes between internal dependencies and peer dependencies to minimize bundle size and avoid version conflicts in host applications.
- Dependencies: Only
clsxis listed as a hard dependency. - Peer Dependencies: Required for the React components and 3D visual effects. These include
react,lucide-react,input-otp,@react-three/fiber, andthree. - Optional Peers: All peer dependencies are marked as optional to allow the core logic to be used in non-React environments without forcing the installation of the entire UI stack.
Sources: package.json:34-60
Build Pipeline and Scripting
The project utilizes the TypeScript compiler (tsc) for its build process, targeting the ES2022 specification and using NodeNext for module resolution.
Build Lifecycle Flow
The following diagram illustrates the build and publication lifecycle:
The build process is managed via standard NPM scripts:
build: Runstscto compile source files fromsrcinto thedistdirectory.prepublishOnly: Ensures a fresh build is generated before the package is published.check-exports: Usespublintand@arethetypeswrong/clito verify that the exports defined inpackage.jsonare compatible with various Node.js versions and module systems.typecheck: Runs the compiler without emitting files to verify type integrity.
Sources: package.json:28-33, tsconfig.json:17-18
TypeScript Configuration
The tsconfig.json specifies the environment constraints and output format for the library.
Compiler Settings
| Option | Value | Description |
|---|---|---|
target | ES2022 | Sets the output JavaScript version. |
module | NodeNext | Enables modern Node.js module resolution. |
strict | true | Enables all strict type-checking options. |
declaration | true | Generates .d.ts files for type safety in consumers. |
jsx | react-jsx | Enables the modern React JSX transform. |
outDir | dist | Sets the target directory for compiled files. |
Sources: tsconfig.json:1-16
Testing Infrastructure
Testing is handled by Vitest, configured to include all .test.ts files within the __tests__ directory.
The testing suite covers core modules such as the auth-store, auth-client, and auth-api, ensuring that token refreshing and authentication logic remain robust across versions.
Sources: package.json:31-32, vitest.config.ts:1-7
Summary
The @cellarnode/auth package configuration emphasizes modularity and modern development standards. By utilizing TypeScript's NodeNext resolution and a careful peer dependency strategy, the library provides a flexible integration path for both core authentication logic and rich React-based UI components. The build pipeline includes rigorous export validation and type checking to ensure high reliability when consumed by external CellarNode dashboards.