Development Guide
This guide provides detailed information about setting up a development environment and working with the Edge-Utils codebase.Environment Setup
System Requirements
- Node.js: Version 18.0.0 or higher
- npm: Version 8.0.0 or higher (comes with Node.js)
- Git: Version 2.30.0 or higher
- Operating System: macOS, Linux, or Windows
Development Tools
We recommend using:- VS Code with extensions:
- ESLint
- Prettier
- Jest
- GitLens
- GitHub Desktop or similar Git GUI
- Postman or Insomnia for API testing
Local Development Setup
1. Clone the Repository
2. Install Dependencies
3. Set Up Development Environment
4. Run Initial Tests
Development Workflow
Daily Development Cycle
-
Pull latest changes
-
Create feature branch
-
Make changes and test
-
Commit changes
-
Push and create PR
Branch Naming Convention
feature/description
: New featuresfix/description
: Bug fixesdocs/description
: Documentation changesrefactor/description
: Code refactoringtest/description
: Test-related changes
Commit Message Format
We follow conventional commit format:feat
: New featuresfix
: Bug fixesdocs
: Documentationstyle
: Code style changesrefactor
: Code refactoringtest
: Testingchore
: Maintenance
Code Organization
Directory Structure
File Naming
- Use
kebab-case
for file names:memory-backend.js
- Use
camelCase
for variable and function names - Use
PascalCase
for class names - Use
.js
extension for all JavaScript files
Import/Export Patterns
Testing
Test Structure
Tests are located in thetests/
directory and follow the naming pattern *.test.js
.
Writing Tests
Running Tests
Test Coverage
We aim for >80% code coverage. Coverage reports are generated incoverage/
directory.
Code Quality
Linting
We use ESLint for code quality. Configuration is inpackage.json
.
Code Style Rules
- Use 2 spaces for indentation
- Use single quotes for strings
- Use semicolons
- Max line length: 100 characters
- Use trailing commas in multi-line objects/arrays
Pre-commit Hooks
We use husky for git hooks. These run automatically:- pre-commit: Lint and format code
- pre-push: Run tests
Building and Packaging
Build Process
Bundle Analysis
Publishing
Only maintainers can publish releases. The process is:- Update version in
package.json
- Update CHANGELOG.md
- Create git tag
- Push to main branch
- GitHub Actions publishes to npm
Debugging
Local Debugging
VS Code Debugging
Create.vscode/launch.json
:
Browser Debugging
For client-side code, use browser dev tools or add:Performance Testing
Benchmarking
Memory Leak Testing
Platform-Specific Development
Cloudflare Workers
Vercel Edge Functions
Deno Deploy
Troubleshooting
Common Issues
Tests failing locally but passing in CI- Clear node_modules and reinstall:
rm -rf node_modules && npm install
- Check Node.js version:
node --version
- Update dependencies:
npm update
- Check for TypeScript errors:
npm run type-check
- Clear build cache:
npm run clean
- Check disk space
- Run auto-fix:
npm run lint:fix
- Check ESLint configuration
- Update to latest ESLint rules
Getting Help
- Check existing issues on GitHub
- Ask in GitHub Discussions
- Check the documentation
- Contact maintainers
Advanced Topics
Contributing to Core Modules
Core modules require extra care:- Maintain backward compatibility
- Update TypeScript definitions
- Add comprehensive tests
- Update documentation
- Consider performance impact
Adding New Modules
When adding new modules:- Create directory in
src/
- Add
index.js
with exports - Update main
src/index.js
- Add tests in
tests/
- Update documentation
- Update
package.json
if needed
Performance Considerations
- Minimize bundle size impact
- Use lazy loading when possible
- Optimize for edge environments
- Consider memory usage
- Test on target platforms
Security
Security Checklist
- No sensitive data in logs
- Input validation and sanitization
- Secure defaults
- No hardcoded secrets
- Regular dependency updates
- Security testing
Reporting Security Issues
Report security issues via GitHub Security tab or email maintainers directly.Release Process
Version Management
We follow semantic versioning:- MAJOR: Breaking changes
- MINOR: New features
- PATCH: Bug fixes
Release Checklist
- Update version in package.json
- Update CHANGELOG.md
- Run full test suite
- Build and test bundles
- Update documentation
- Create git tag
- Publish to npm
- Announce release