๐ ๏ธ 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โ
VS Code Extensions (Recommended)โ
- 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:
- Check the logs for error messages
- Clear dependencies:
rm -rf node_modules && bun install
- Update tools: Ensure latest Node.js and Bun versions
- Ask for help:
- ๐ฌ GitHub Discussions
- ๐ GitHub Issues
๐ฏ Next Stepsโ
Once your development environment is ready:
- Pick an issue from GitHub Issues
- Create a branch for your changes
- Write tests for new functionality
- Update docs if needed
- Submit a PR following our Contributing Guide
Happy coding! ๐ Your development environment is now ready for contributing to use-typewriter-animation.