Skip to content

Conversation

koistya
Copy link
Member

@koistya koistya commented Sep 10, 2025

Summary

Adds a predev script to the API workspace that automatically builds the email package before starting the development server. This resolves the "Cannot find module '@repo/email'" error that occurs when developers fresh clone the repository and run bun dev without manually building the email package first.

Fixes #2112 (introduced in #2110)

Changes

Problem

When users clone the repository and run bun dev, the API server fails to start with:

error: Cannot find module '@repo/email' from 'apps/api/lib/email.ts'

This happens because:

  • The API imports email templates from @repo/email
  • The email package exports from ./dist/ (compiled TypeScript output)
  • The dist folder is gitignored and doesn't exist on fresh clone
  • Users had to manually run bun email:build first

Solution

The predev script leverages npm/Bun's lifecycle hooks to automatically build the email package before the dev script runs. This works with both:

  • Direct API commands: bun dev (from apps/api/)
  • Root shortcuts: bun api:dev (from repository root)

Testing

Verified the fix by:

  1. Removing the apps/email/dist folder to simulate fresh clone state
  2. Running bun api:dev and bun dev (from API directory)
  3. Confirming the predev script builds the email package automatically
  4. Verifying the API starts without errors

Result: Developers can now run bun dev immediately after cloning without any manual setup steps.

Code Quality Integration

lint-staged Configuration: The repository uses lint-staged with Husky pre-commit hooks for automated code quality checks:

  • Pre-commit hook: Runs bunx lint-staged on all staged files
  • ESLint: Validates JavaScript/TypeScript files with zero warnings policy
  • Prettier: Ensures consistent formatting across all files
  • File patterns: Covers *.{js,jsx,ts,tsx,mjs,cjs} for linting and * for formatting

This integration ensures all commits maintain consistent code style and pass linting rules before reaching the repository.

@koistya koistya merged commit 397a7ce into main Sep 10, 2025
5 checks passed
@koistya koistya deleted the dev branch September 10, 2025 13:23
@koistya koistya added the bug Something isn't working label Sep 10, 2025
@koistya koistya moved this to Done in React Starter Kit Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Cannot find module '@repo/email'
1 participant