Skip to main content

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

  1. Pull latest changes
  2. Create feature branch
  3. Make changes and test
  4. Commit changes
  5. Push and create PR

Branch Naming Convention

  • feature/description: New features
  • fix/description: Bug fixes
  • docs/description: Documentation changes
  • refactor/description: Code refactoring
  • test/description: Test-related changes

Commit Message Format

We follow conventional commit format:
Types:
  • feat: New features
  • fix: Bug fixes
  • docs: Documentation
  • style: Code style changes
  • refactor: Code refactoring
  • test: Testing
  • chore: Maintenance
Examples:

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 the tests/ directory and follow the naming pattern *.test.js.

Writing Tests

Running Tests

Test Coverage

We aim for >80% code coverage. Coverage reports are generated in coverage/ directory.

Code Quality

Linting

We use ESLint for code quality. Configuration is in package.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:
  1. Update version in package.json
  2. Update CHANGELOG.md
  3. Create git tag
  4. Push to main branch
  5. 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
Build failing
  • Check for TypeScript errors: npm run type-check
  • Clear build cache: npm run clean
  • Check disk space
Linting errors
  • 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:
  1. Create directory in src/
  2. Add index.js with exports
  3. Update main src/index.js
  4. Add tests in tests/
  5. Update documentation
  6. 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
This development guide should help you get started and work effectively with the Edge-Utils codebase. Remember to always test your changes and follow the established patterns and conventions.