Skip to content

Commit d972d51

Browse files
committed
Add initial CLAUDE.md
1 parent 923f988 commit d972d51

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

CLAUDE.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This project compares implementations of webpages with increasing complexity across multiple JavaScript frameworks (React, Preact, Vue, Svelte, Solid, lit-html). Each framework implements the same set of applications (e.g., "hello-world", "7GUIs-counter", "7GUIs-flight-booker") to enable direct comparison of bundle sizes, code patterns, and complexity.
8+
9+
## Project Structure
10+
11+
- **`frameworks/`**: Contains separate workspace packages for each framework
12+
- Each framework folder has `src/` with app implementations (one folder per app)
13+
- Each framework has its own `rollup.config.js` and build configuration
14+
- Uses `bundleHelpers.js` to generate Rollup configs that create both development and minified production builds
15+
16+
- **`scripts/`**: Build tooling and website generation
17+
- `build.js`: Main build script - compiles frameworks, generates static site with bundle analysis
18+
- `dev.js`: Development server with hot reload watching for framework changes
19+
- `data.js`: Collects bundle sizes (raw, minified, gzip, brotli) and source code for comparison
20+
- `components/`: Preact components for the comparison website UI
21+
- `routes/`: Page generators for intro, summary, and app comparison views
22+
- `bundles/`: Shared CSS/JS bundles for the static site
23+
24+
- **`lib/`**: Shared utility code used across all framework implementations (e.g., CRUD logic, date utilities)
25+
26+
- **`tests/`**: Jest + Puppeteer end-to-end tests organized by app and framework
27+
28+
- **`dist/`**: Build output (not committed to git)
29+
- `frameworks/[framework-name]/[app-name]/`: Compiled app bundles with stats
30+
- Static HTML pages showing comparisons
31+
32+
## Common Commands
33+
34+
### Development
35+
```bash
36+
npm start # Start dev server with no watchers
37+
npm run dev [framework...] # Start dev server and watch specific framework(s)
38+
npm run dev all # Watch all frameworks and rebuild site on changes
39+
npm run dev scripts # Only watch and rebuild site assets
40+
npm run dev react preact # Watch only React and Preact frameworks
41+
```
42+
43+
### Building
44+
```bash
45+
npm run build # Build all frameworks and generate comparison site
46+
npm run build [framework] # Build specific framework(s) by package name prefix
47+
npm run serve # Serve built site from dist/ directory
48+
```
49+
50+
### Testing and Type Checking
51+
```bash
52+
npm test # Run all Puppeteer tests (requires built site)
53+
npm run test:debug # Run tests with Puppeteer debug output
54+
npm run tsc # Type check all workspaces with TypeScript
55+
```
56+
57+
### Code Quality
58+
```bash
59+
npm run format # Format all code with Prettier
60+
npm run lint-staged # Run pre-commit hooks manually
61+
```
62+
63+
## Build System Architecture
64+
65+
The build system has two main phases:
66+
67+
1. **Framework Builds** (parallel per framework):
68+
- Each framework workspace has a Rollup config generated by `bundleHelpers.js`
69+
- For each app in `src/`, creates two bundles: unminified (`.js`) and minified (`.min.js`)
70+
- Outputs to `dist/frameworks/[framework]/[app]/` with bundle visualization HTML
71+
- The `generateConfigs()` helper automatically discovers app folders and creates configs
72+
73+
2. **Site Generation** (in `scripts/build.js`):
74+
- Scans all framework build outputs and extracts bundle sizes (raw, gzip, brotli)
75+
- Compiles Preact components for the comparison UI
76+
- Generates static HTML pages:
77+
- Intro page (landing)
78+
- Summary view (tables comparing all frameworks)
79+
- Individual app views (side-by-side source and bundle comparisons)
80+
- Builds and minifies shared CSS/JS bundles
81+
- Outputs `sizes.json` with all bundle size data
82+
83+
## Key Implementation Details
84+
85+
- **Monorepo Structure**: Uses npm workspaces - root package.json defines workspaces for `frameworks/*`, `scripts/`, and `tests/`
86+
87+
- **Framework Independence**: Each framework workspace is self-contained with its own dependencies and build config
88+
89+
- **Shared Code**: The `lib/` folder contains framework-agnostic utilities that all implementations can use (e.g., CRUD operations, date parsing)
90+
91+
- **Consistent App Names**: All frameworks implement the same apps with identical folder names (e.g., `hello-world`, `7GUIs-counter`). This enables automated comparison.
92+
93+
- **Bundle Analysis**: Each build produces:
94+
- Development bundle (readable, with source maps)
95+
- Production bundle (minified with Terser)
96+
- Bundle visualization HTML (via rollup-plugin-visualizer)
97+
- Size metrics (raw, minified, gzip, brotli) collected by `data.js`
98+
99+
- **Watch Mode**: `dev.js` uses nodemon to watch framework source and rebuild site when changes are detected. Individual frameworks use Rollup's watch mode.
100+
101+
## Adding a New Framework
102+
103+
1. Create a new folder in `frameworks/[new-framework]/`
104+
2. Add `package.json` with name `[framework]-apps` and build/watch scripts
105+
3. Create `rollup.config.js` using `bundleHelpers.js` (see existing frameworks for examples)
106+
4. Implement apps in `src/[app-name]/index.js` or `index.jsx`
107+
5. Add framework to root `package.json` workspaces array if not already covered by glob
108+
109+
## Adding a New App
110+
111+
1. Add the app folder to `src/` in each framework you want to support
112+
2. The build system auto-discovers new app folders in each framework's `src/` directory
113+
3. Tests should be added to `tests/apps/[app-name]/` with framework-specific test files

0 commit comments

Comments
 (0)