Skip to main content

๐Ÿ› ๏ธ Development Setup

This guide will help you set up your development environment for contributing to use-typewriter-animation.

๐Ÿš€ Quick Setupโ€‹

Prerequisitesโ€‹

  • Node.js 18.0.0 or higher
  • Bun 1.0.0 or higher (recommended)
  • Git for version control
  • VS Code (recommended) with TypeScript support

Installationโ€‹

# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/use-typewriter-animation.git
cd use-typewriter-animation

# Add the upstream remote
git remote add upstream https://github.com/doguyilmaz/use-typewriter-animation.git

# Install dependencies
bun install

# Verify setup
bun test # Run tests (228 tests should pass)
bun run build # Build project
bun run watch # Start development watcher

๐Ÿ“ Project Structureโ€‹

use-typewriter-animation/
โ”œโ”€โ”€ src/ # Source code
โ”‚ โ”œโ”€โ”€ index.ts # Main exports
โ”‚ โ”œโ”€โ”€ hooks/ # React hooks
โ”‚ โ”œโ”€โ”€ components/ # React components
โ”‚ โ”œโ”€โ”€ utils/ # Utility functions
โ”‚ โ””โ”€โ”€ types/ # TypeScript definitions
โ”œโ”€โ”€ tests/ # Test files
โ”‚ โ”œโ”€โ”€ setup.ts # Test configuration
โ”‚ โ””โ”€โ”€ **/*.test.tsx # Test files
โ”œโ”€โ”€ examples/ # Usage examples
โ”œโ”€โ”€ dist/ # Built files (generated)
โ”œโ”€โ”€ scripts/ # Build scripts
โ”‚ โ”œโ”€โ”€ esbuild.ts # Build configuration
โ”‚ โ””โ”€โ”€ version-bump.ts # Version management
โ”œโ”€โ”€ docs/ # Documentation
โ””โ”€โ”€ package.json # Package configuration

๐Ÿ”ง Development Commandsโ€‹

Core Developmentโ€‹

bun run watch         # Start development with file watching
bun run build # Build the project
bun run clean # Clean build artifacts

Testingโ€‹

bun test              # Run all tests
bun test --watch # Watch mode for development
bun test --coverage # Coverage report
bun test --ui # Open test UI

Code Qualityโ€‹

bun run format        # Format code with Biome
bun run types # TypeScript type checking
bun run analyze # Bundle size analysis

Releaseโ€‹

bun run version       # Interactive version bump
bun run pack # Create package for testing

๐Ÿงช Testingโ€‹

Test Structureโ€‹

Our tests focus on:

  • Structural validation - Module imports/exports
  • Function signatures - React hook conventions
  • TypeScript compliance - Type safety
  • API surface validation - Public interface stability

Writing Testsโ€‹

import { describe, it, expect } from 'vitest';
import { useTypewriter } from '../src';

describe('useTypewriter', () => {
it('should export the hook function', () => {
expect(typeof useTypewriter).toBe('function');
});

it('should follow React hook naming convention', () => {
expect(useTypewriter.name).toBe('useTypewriter');
});
});

๐Ÿ—๏ธ Build Processโ€‹

Build Outputsโ€‹

dist/
โ”œโ”€โ”€ esm/ # ES modules
โ”‚ โ””โ”€โ”€ index.mjs
โ”œโ”€โ”€ cjs/ # CommonJS modules
โ”‚ โ””โ”€โ”€ index.js
โ””โ”€โ”€ types/ # TypeScript declarations
โ””โ”€โ”€ index.d.ts

Bundle Configurationโ€‹

The project uses esbuild for fast builds with:

  • Tree shaking for smaller bundles
  • Source maps for debugging
  • Minification for production
  • External dependencies (React, React DOM)

Bundle Size Targetsโ€‹

  • ESM: ~5.3KB gzipped
  • CJS: ~5.6KB gzipped

๐Ÿ” Common Issues & Solutionsโ€‹

TypeScript Errorsโ€‹

bun run types  # Check TypeScript compilation

Test Failuresโ€‹

  • Check tests/setup.ts configuration
  • Verify React Testing Library setup

Build Issuesโ€‹

  • Verify scripts/esbuild.ts settings
  • Check src/index.ts exports

Import Problemsโ€‹

  • Ensure proper export/import statements
  • Check TypeScript path resolution

๐Ÿ”„ Git Workflowโ€‹

Branch Namingโ€‹

  • Features: feature/description
  • Fixes: fix/description
  • Docs: docs/description

Before Committingโ€‹

bun test           # Ensure tests pass
bun run build # Verify build works
bun run format # Format code

Commit Messagesโ€‹

Use conventional commits:

feat: add concurrent typing support
fix: resolve SSR hydration issue
docs: update API documentation
test: add edge case coverage

๐Ÿ› ๏ธ IDE Setupโ€‹

  • Biome - Code formatting and linting
  • Vitest - Test runner integration
  • TypeScript - Built-in language support

VS Code Settingsโ€‹

{
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"typescript.preferences.importModuleSpecifier": "relative"
}

๐Ÿ“Š Performance Tipsโ€‹

Development Speedโ€‹

  • Use Bun for faster installs and scripts
  • Run bun run watch for live rebuilds
  • Use bun test --watch for test-driven development

Bundle Optimizationโ€‹

bun run analyze  # Check bundle size and composition

๐Ÿ“ž Getting Helpโ€‹

If you encounter issues:

  1. Check the logs for error messages
  2. Clear dependencies: rm -rf node_modules && bun install
  3. Update tools: Ensure latest Node.js and Bun versions
  4. Ask for help:

๐ŸŽฏ Next Stepsโ€‹

Once your development environment is ready:

  1. Pick an issue from GitHub Issues
  2. Create a branch for your changes
  3. Write tests for new functionality
  4. Update docs if needed
  5. Submit a PR following our Contributing Guide

Happy coding! ๐ŸŽ‰ Your development environment is now ready for contributing to use-typewriter-animation.