diff --git a/AGENTS.md b/AGENTS.md index 0fc10c4..792c140 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -812,6 +812,34 @@ The router includes automatic scroll-to-top functionality and a 404 NotFound pag - Comprehensive provider setup with NostrLoginProvider, QueryClientProvider, and custom AppProvider - **Never use the `any` type**: Always use proper TypeScript types for type safety +### Import Extensions + +This project uses ES modules with Node.js-style module resolution (`"type": "module"` and `"moduleResolution": "nodenext"`). **All imports MUST include explicit file extensions**, and specifically **`.js`/`.jsx` extensions must be used** even when importing TypeScript files. + +This is because TypeScript compiles to JavaScript, and the runtime expects the actual file extensions that will exist after compilation. + +#### Examples + +**✅ Correct imports with .js/.jsx extensions:** +```typescript +// Import TypeScript files with .js extension +import { useAuthor } from '@/hooks/useAuthor.js'; +import { Button } from '@/components/ui/button.jsx'; +import { LoginArea } from "@/components/auth/LoginArea.jsx"; +import AppRouter from "./AppRouter.jsx"; +import { cn } from '@/lib/utils.js'; +``` + +**❌ Wrong imports (wrong extensions or no extension):** +```typescript +// These will cause build/runtime errors +import { useAuthor } from '@/hooks/useAuthor'; +import { Button } from '@/components/ui/button.tsx'; +import { LoginArea } from "@/components/auth/LoginArea"; +import AppRouter from "./AppRouter"; +import { cn } from '@/lib/utils.ts'; +``` + ## Loading States **Use skeleton loading** for structured content (feeds, profiles, forms). **Use spinners** only for buttons or short operations.