Skip to content

Performance Optimization and Cleanup Based on e18e PrinciplesΒ #305

@eins78

Description

@eins78

Performance Optimization and Cleanup Initiative

πŸ“Š Current State Analysis

Technology Stack

  • Monorepo Structure: pnpm workspace with 3 packages
  • Backend: Express.js v5 with TypeScript (using Node.js experimental features)
  • Frontend: Lit Web Components with Server-Side Rendering
  • Testing: Playwright with BDD extension
  • Build Tools: Rollup for lit-ssr-demo, native Node.js for main app
  • Code Quality: ESLint v9 (flat config), Prettier, Knip
  • Runtime: Node.js v22.17.1

Identified Issues

Based on analysis following e18e principles (cleanup, speedup, levelup), here are the key findings:

πŸ”§ Optimization Opportunities

1. Cleanup - Dependency Management

Priority: High | Impact: High | Complexity: Low

  • Issue: Multiple TypeScript versions (5.7.2 in root/app, 5.5.4 in lit-ssr-demo)
  • Issue: Outdated dependencies:
    • dotenv v17 (latest: v16.4.5)
    • debug v4.4.0 (latest: v4.3.7)
  • Issue: Redundant devDependencies across packages
  • Issue: Potential unused dependencies (needs Knip analysis)

Recommendations:

  • Align TypeScript versions across all packages to latest stable
  • Update all outdated dependencies
  • Consolidate common devDependencies to workspace root
  • Run Knip to identify and remove unused dependencies
  • Consider replacing heavy dependencies with lighter alternatives

2. Speedup - Build Performance

Priority: High | Impact: High | Complexity: Medium

  • Issue: No production build optimization for Express app
  • Issue: Rollup configuration lacks minification/optimization plugins
  • Issue: Docker build doesn't utilize layer caching effectively
  • Issue: Missing source maps for production debugging

Recommendations:

  • Add production TypeScript compilation with optimization
  • Configure Rollup with terser/minification for production
  • Optimize Docker multi-stage build with better caching
  • Implement build size tracking and budgets
  • Add parallel build tasks where applicable

3. Speedup - Runtime Performance

Priority: High | Impact: High | Complexity: Low

  • Issue: No compression middleware in Express
  • Issue: Missing caching headers for static assets
  • Issue: No production-specific error handling
  • Issue: Single-threaded execution (no clustering)

Recommendations:

  • Add compression middleware (e.g., compression package)
  • Implement proper cache-control headers
  • Add production error handling middleware
  • Consider PM2 or native cluster module for multi-core utilization
  • Add response time monitoring

4. Levelup - Modern Alternatives

Priority: Medium | Impact: Medium | Complexity: High

  • Issue: Using experimental Node.js TypeScript features
  • Issue: Traditional Express.js could be replaced with faster alternatives
  • Issue: Bundle size could be reduced with modern tools

Recommendations:

  • Evaluate tsx or ts-node-esm for TypeScript execution
  • Consider Fastify or Hono as Express alternatives
  • Explore Vite for development server with HMR
  • Consider SWC or esbuild for faster TypeScript compilation

5. Development Experience

Priority: Medium | Impact: Medium | Complexity: Low

  • Issue: Complex npm script names
  • Issue: Test artifacts accumulating in repository
  • Issue: No hot module replacement for development
  • Issue: Missing VSCode workspace configuration

Recommendations:

  • Simplify npm scripts with clear naming
  • Update .gitignore for Playwright artifacts
  • Add nodemon or similar for auto-restart
  • Create .vscode/settings.json for consistent development

6. Testing & CI Optimization

Priority: Medium | Impact: Medium | Complexity: Medium

  • Issue: E2E tests generate artifacts not properly gitignored
  • Issue: Playwright traces consume significant disk space
  • Issue: CI runs full browser suite for all changes

Recommendations:

  • Configure Playwright to clean up artifacts
  • Add test result caching in CI
  • Implement test matrix optimization
  • Add unit test coverage requirements

πŸ“‹ E18e Performance Rules and Guidelines

Source: https://e18e.dev/ (analyzed on 2025-01-19)
Update Schedule: This section should be reviewed and updated every 3 months

Core Principles from e18e:

  1. Cleanup: Remove redundant dependencies and modernize tools

    • Identify bloated, unmaintained, or outdated packages
    • Use tools like npmgraph and pkg-size for analysis
    • Replace oversized dependencies with lean alternatives
  2. Speedup: Improve performance of critical components

    • Focus on widely-used packages in the dependency tree
    • Optimize build and runtime performance
    • Contribute improvements upstream when possible
  3. Levelup: Adopt modern, lighter alternatives

    • Research alternatives at module-replacements repository
    • Consider tinylibs and unjs ecosystems
    • Test thoroughly before migration

Recommended Analysis Tools:

  • npmgraph - Visualize dependency graphs
  • pkg-size - Analyze package sizes
  • rollup-plugin-visualizer - Bundle composition analysis
  • Knip - Find unused dependencies and exports

Best Practices:

  • Always analyze the full dependency tree, not just direct dependencies
  • Consider the specific context before removing dependencies
  • Collaborate with the community for greater impact
  • Test alternatives extensively before adoption

πŸ“š References

E18e Resources

Alternative Package Resources

Performance Analysis Tools

Performance Optimization Guides


This issue serves as a comprehensive guide for optimizing our application's performance following e18e principles. Each section can be converted into separate issues or PRs as we progress through the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions