reroute-js 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/package.json +8 -6
- package/packages/cli/README.md +264 -0
- package/{cli/bin.d.ts → packages/cli/bin.ts} +1 -1
- package/packages/core/README.md +90 -0
- package/packages/elysia/README.md +250 -0
- package/packages/react/README.md +3 -0
- package/_/README.md +0 -59
- package/_/basic/package.json +0 -23
- package/_/basic/src/client/App.tsx +0 -10
- package/_/basic/src/client/components/Counter.tsx +0 -15
- package/_/basic/src/client/index.html +0 -12
- package/_/basic/src/client/index.tsx +0 -5
- package/_/basic/src/client/routes/[404].tsx +0 -18
- package/_/basic/src/client/routes/about.tsx +0 -25
- package/_/basic/src/client/routes/index.tsx +0 -57
- package/_/basic/src/index.ts +0 -20
- package/_/basic/tsconfig.json +0 -26
- package/_/blog/package.json +0 -23
- package/_/blog/src/client/App.tsx +0 -10
- package/_/blog/src/client/components/Counter.tsx +0 -14
- package/_/blog/src/client/components/RecentPosts.tsx +0 -90
- package/_/blog/src/client/index.html +0 -13
- package/_/blog/src/client/index.tsx +0 -5
- package/_/blog/src/client/routes/[404].tsx +0 -21
- package/_/blog/src/client/routes/about.tsx +0 -31
- package/_/blog/src/client/routes/blog/[404].tsx +0 -21
- package/_/blog/src/client/routes/blog/[layout].tsx +0 -84
- package/_/blog/src/client/routes/blog/[slug].tsx +0 -11
- package/_/blog/src/client/routes/blog/content/1-hello-world.tsx +0 -27
- package/_/blog/src/client/routes/blog/content/2-what-is-reroute.tsx +0 -31
- package/_/blog/src/client/routes/blog/index.tsx +0 -70
- package/_/blog/src/client/routes/index.tsx +0 -63
- package/_/blog/src/index.ts +0 -20
- package/_/blog/tsconfig.json +0 -26
- package/_/store/package.json +0 -25
- package/_/store/src/client/App.tsx +0 -17
- package/_/store/src/client/components/Header.tsx +0 -40
- package/_/store/src/client/components/ProductCard.tsx +0 -51
- package/_/store/src/client/index.html +0 -17
- package/_/store/src/client/index.tsx +0 -7
- package/_/store/src/client/lib/api.ts +0 -153
- package/_/store/src/client/routes/[404].tsx +0 -63
- package/_/store/src/client/routes/categories/[category].tsx +0 -223
- package/_/store/src/client/routes/categories/index.tsx +0 -187
- package/_/store/src/client/routes/index.tsx +0 -126
- package/_/store/src/client/routes/products/[id].tsx +0 -233
- package/_/store/src/client/routes/products/index.tsx +0 -261
- package/_/store/src/client/theme.css +0 -306
- package/_/store/src/index.ts +0 -19
- package/_/store/tsconfig.json +0 -26
- package/cli/bin.d.ts.map +0 -1
- package/cli/bin.js +0 -878
- package/cli/bin.js.map +0 -15
- package/cli/index.d.ts +0 -2
- package/cli/index.d.ts.map +0 -1
- package/cli/index.js +0 -147
- package/cli/index.js.map +0 -10
- package/cli/src/cli.d.ts +0 -8
- package/cli/src/cli.d.ts.map +0 -1
- package/cli/src/commands/build.d.ts +0 -8
- package/cli/src/commands/build.d.ts.map +0 -1
- package/cli/src/commands/dev.d.ts +0 -8
- package/cli/src/commands/dev.d.ts.map +0 -1
- package/cli/src/commands/gen.d.ts +0 -3
- package/cli/src/commands/gen.d.ts.map +0 -1
- package/cli/src/commands/init.d.ts +0 -8
- package/cli/src/commands/init.d.ts.map +0 -1
- package/cli/src/libs/index.d.ts +0 -2
- package/cli/src/libs/index.d.ts.map +0 -1
- package/cli/src/libs/tailwind.d.ts +0 -45
- package/cli/src/libs/tailwind.d.ts.map +0 -1
- package/core/index.d.ts +0 -2
- package/core/index.d.ts.map +0 -1
- package/core/index.js +0 -1117
- package/core/index.js.map +0 -25
- package/core/src/bundler/hash.d.ts +0 -2
- package/core/src/bundler/hash.d.ts.map +0 -1
- package/core/src/bundler/index.d.ts +0 -3
- package/core/src/bundler/index.d.ts.map +0 -1
- package/core/src/bundler/transpile.d.ts +0 -4
- package/core/src/bundler/transpile.d.ts.map +0 -1
- package/core/src/content/discovery.d.ts +0 -5
- package/core/src/content/discovery.d.ts.map +0 -1
- package/core/src/content/index.d.ts +0 -4
- package/core/src/content/index.d.ts.map +0 -1
- package/core/src/content/metadata.d.ts +0 -9
- package/core/src/content/metadata.d.ts.map +0 -1
- package/core/src/content/registry.d.ts +0 -2
- package/core/src/content/registry.d.ts.map +0 -1
- package/core/src/index.d.ts +0 -7
- package/core/src/index.d.ts.map +0 -1
- package/core/src/ssr/data.d.ts +0 -9
- package/core/src/ssr/data.d.ts.map +0 -1
- package/core/src/ssr/index.d.ts +0 -4
- package/core/src/ssr/index.d.ts.map +0 -1
- package/core/src/ssr/modules.d.ts +0 -8
- package/core/src/ssr/modules.d.ts.map +0 -1
- package/core/src/ssr/render.d.ts +0 -20
- package/core/src/ssr/render.d.ts.map +0 -1
- package/core/src/ssr/seed.d.ts +0 -2
- package/core/src/ssr/seed.d.ts.map +0 -1
- package/core/src/template/html.d.ts +0 -4
- package/core/src/template/html.d.ts.map +0 -1
- package/core/src/template/index.d.ts +0 -2
- package/core/src/template/index.d.ts.map +0 -1
- package/core/src/types.d.ts +0 -50
- package/core/src/types.d.ts.map +0 -1
- package/core/src/utils/cache.d.ts +0 -12
- package/core/src/utils/cache.d.ts.map +0 -1
- package/core/src/utils/compression.d.ts +0 -5
- package/core/src/utils/compression.d.ts.map +0 -1
- package/core/src/utils/index.d.ts +0 -5
- package/core/src/utils/index.d.ts.map +0 -1
- package/core/src/utils/mime.d.ts +0 -3
- package/core/src/utils/mime.d.ts.map +0 -1
- package/core/src/utils/path.d.ts +0 -6
- package/core/src/utils/path.d.ts.map +0 -1
- package/elysia/index.d.ts +0 -2
- package/elysia/index.d.ts.map +0 -1
- package/elysia/index.js +0 -1762
- package/elysia/index.js.map +0 -32
- package/elysia/src/index.d.ts +0 -3
- package/elysia/src/index.d.ts.map +0 -1
- package/elysia/src/plugin.d.ts +0 -32
- package/elysia/src/plugin.d.ts.map +0 -1
- package/elysia/src/routes/artifacts.d.ts +0 -3
- package/elysia/src/routes/artifacts.d.ts.map +0 -1
- package/elysia/src/routes/content.d.ts +0 -3
- package/elysia/src/routes/content.d.ts.map +0 -1
- package/elysia/src/routes/dev.d.ts +0 -7
- package/elysia/src/routes/dev.d.ts.map +0 -1
- package/elysia/src/routes/ssr.d.ts +0 -19
- package/elysia/src/routes/ssr.d.ts.map +0 -1
- package/elysia/src/routes/static.d.ts +0 -19
- package/elysia/src/routes/static.d.ts.map +0 -1
- package/elysia/src/types.d.ts +0 -31
- package/elysia/src/types.d.ts.map +0 -1
- package/elysia/src/utils/http.d.ts +0 -5
- package/elysia/src/utils/http.d.ts.map +0 -1
- package/react/index.d.ts +0 -2
- package/react/index.d.ts.map +0 -1
- package/react/index.js +0 -1152
- package/react/index.js.map +0 -23
- package/react/src/components/ContentRoute.d.ts +0 -13
- package/react/src/components/ContentRoute.d.ts.map +0 -1
- package/react/src/components/Link.d.ts +0 -8
- package/react/src/components/Link.d.ts.map +0 -1
- package/react/src/components/Outlet.d.ts +0 -7
- package/react/src/components/Outlet.d.ts.map +0 -1
- package/react/src/components/index.d.ts +0 -4
- package/react/src/components/index.d.ts.map +0 -1
- package/react/src/hooks/index.d.ts +0 -7
- package/react/src/hooks/index.d.ts.map +0 -1
- package/react/src/hooks/useContent.d.ts +0 -26
- package/react/src/hooks/useContent.d.ts.map +0 -1
- package/react/src/hooks/useData.d.ts +0 -10
- package/react/src/hooks/useData.d.ts.map +0 -1
- package/react/src/hooks/useNavigate.d.ts +0 -6
- package/react/src/hooks/useNavigate.d.ts.map +0 -1
- package/react/src/hooks/useParams.d.ts +0 -6
- package/react/src/hooks/useParams.d.ts.map +0 -1
- package/react/src/hooks/useRouter.d.ts +0 -7
- package/react/src/hooks/useRouter.d.ts.map +0 -1
- package/react/src/hooks/useSearchParams.d.ts +0 -6
- package/react/src/hooks/useSearchParams.d.ts.map +0 -1
- package/react/src/index.d.ts +0 -6
- package/react/src/index.d.ts.map +0 -1
- package/react/src/providers/ContentProvider.d.ts +0 -35
- package/react/src/providers/ContentProvider.d.ts.map +0 -1
- package/react/src/providers/RerouteProvider.d.ts +0 -25
- package/react/src/providers/RerouteProvider.d.ts.map +0 -1
- package/react/src/providers/RouterProvider.d.ts +0 -23
- package/react/src/providers/RouterProvider.d.ts.map +0 -1
- package/react/src/providers/index.d.ts +0 -4
- package/react/src/providers/index.d.ts.map +0 -1
- package/react/src/types/any.d.ts +0 -3
- package/react/src/types/any.d.ts.map +0 -1
- package/react/src/types/index.d.ts +0 -3
- package/react/src/types/index.d.ts.map +0 -1
- package/react/src/types/router.d.ts +0 -32
- package/react/src/types/router.d.ts.map +0 -1
- package/react/src/utils/content.d.ts +0 -8
- package/react/src/utils/content.d.ts.map +0 -1
- package/react/src/utils/head.d.ts +0 -6
- package/react/src/utils/head.d.ts.map +0 -1
- package/react/src/utils/index.d.ts +0 -3
- package/react/src/utils/index.d.ts.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## [0.2.1](https://github.com/stewones/reroute/compare/v0.2.0...v0.2.1) (2025-11-04)
|
|
2
|
+
|
|
3
|
+
### 📚 Documentation
|
|
4
|
+
|
|
5
|
+
* fix typo ([080ee94](https://github.com/stewones/reroute/commit/080ee9423786e35256faf2094a957f1c3e515735))
|
|
6
|
+
|
|
7
|
+
### 👷 Continuous Integration
|
|
8
|
+
|
|
9
|
+
* add github releases [skip ci] ([de44be7](https://github.com/stewones/reroute/commit/de44be7a7edc28522730a2981f9873d5f6e4d74c))
|
|
10
|
+
* fix bunx ([f9beb55](https://github.com/stewones/reroute/commit/f9beb5588d0b3cb035df02f1af44879dfbf0d693))
|
|
11
|
+
|
|
12
|
+
## [0.2.0](https://github.com/stewones/reroute/compare/v0.1.0...v0.2.0) (2025-11-04)
|
|
13
|
+
|
|
14
|
+
### ⚡ Performance Improvements
|
|
15
|
+
|
|
16
|
+
* improve static cache ([ca13189](https://github.com/stewones/reroute/commit/ca13189025213d95e125ced4198e34956cac08d8))
|
|
17
|
+
|
|
18
|
+
### 👷 Continuous Integration
|
|
19
|
+
|
|
20
|
+
* add ci prefix as trigger ([5d9567a](https://github.com/stewones/reroute/commit/5d9567aede7ab17c3e3da244b2d0e8963ece0dc4))
|
|
21
|
+
* disable tests for now ([45c0855](https://github.com/stewones/reroute/commit/45c08557cd9a436103e9ef0dd12fa239154dd2a5))
|
|
22
|
+
* fix changelog ([00be21e](https://github.com/stewones/reroute/commit/00be21ed183061255e40c6fed51d8f885526573f))
|
|
23
|
+
* fix code quality check ([fa09adb](https://github.com/stewones/reroute/commit/fa09adb5c88bc118839d322698974c7249e9a894))
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Reroute
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reroute is a dead-simple file-based routing framework for building full-stack React apps on top of Bun and Elysia.
|
|
4
4
|
|
|
5
5
|
## ✨ Features
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reroute-js",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"types": "tsc --noEmit",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"bin": {
|
|
45
|
-
"reroute": "./cli/bin.
|
|
45
|
+
"reroute": "./packages/cli/bin.ts"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"_",
|
|
@@ -57,17 +57,19 @@
|
|
|
57
57
|
"@biomejs/biome": "^2.3.3",
|
|
58
58
|
"@semantic-release/changelog": "^6.0.3",
|
|
59
59
|
"@semantic-release/git": "^10.0.1",
|
|
60
|
+
"@semantic-release/github": "^12.0.1",
|
|
61
|
+
"@tailwindcss/cli": "^4.1.16",
|
|
60
62
|
"@types/bun": "latest",
|
|
61
63
|
"@types/react-dom": "^19.2.2",
|
|
62
64
|
"@vitest/coverage-v8": "^3.2.4",
|
|
65
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
63
66
|
"dedent": "^1.7.0",
|
|
64
67
|
"knip": "^5.66.3",
|
|
68
|
+
"react": "^19.2.0",
|
|
69
|
+
"react-dom": "^19.2.0",
|
|
65
70
|
"semantic-release": "^24.2.8",
|
|
66
71
|
"vite-tsconfig-paths": "^5.1.4",
|
|
67
|
-
"vitest": "^3.2.4"
|
|
68
|
-
"@tailwindcss/cli": "^4.1.16",
|
|
69
|
-
"react": "^19.2.0",
|
|
70
|
-
"react-dom": "^19.2.0"
|
|
72
|
+
"vitest": "^3.2.4"
|
|
71
73
|
},
|
|
72
74
|
"peerDependencies": {
|
|
73
75
|
"typescript": "^5",
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Reroute CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for the Reroute framework.
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
7
|
+
✅ **Available** - The `gen` and `init` commands are ready to use!
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### Local Usage (Recommended)
|
|
12
|
+
|
|
13
|
+
Use with `bunx` without installation:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bunx reroute-js init my-app
|
|
17
|
+
bunx reroute-js gen
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Global Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun install -g reroute-js
|
|
24
|
+
reroute gen
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Available Commands
|
|
28
|
+
|
|
29
|
+
### `reroute init`
|
|
30
|
+
|
|
31
|
+
Scaffold a new Reroute project with templates.
|
|
32
|
+
|
|
33
|
+
**What it does:**
|
|
34
|
+
|
|
35
|
+
1. Creates a new project directory with the specified name
|
|
36
|
+
2. Scaffolds a complete Reroute application structure
|
|
37
|
+
3. Sets up routing, server, and client entry points
|
|
38
|
+
4. Installs all required dependencies
|
|
39
|
+
5. Provides optional templates (basic, blog)
|
|
40
|
+
|
|
41
|
+
**Usage:**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
reroute init <project-name>
|
|
45
|
+
reroute init <project-name> --template <template>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Available Templates:**
|
|
49
|
+
|
|
50
|
+
- `basic` (default) - Minimal Reroute application with basic routing
|
|
51
|
+
- `blog` - Full-featured blog with content collections and layouts
|
|
52
|
+
|
|
53
|
+
**Options:**
|
|
54
|
+
|
|
55
|
+
- `--template <name>` - Template to use (basic, blog)
|
|
56
|
+
- `-h, --help` - Show help
|
|
57
|
+
|
|
58
|
+
**Examples:**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Create basic project
|
|
62
|
+
bunx reroute-js init my-app
|
|
63
|
+
|
|
64
|
+
# Create blog project
|
|
65
|
+
bunx reroute-js init my-blog --template blog
|
|
66
|
+
|
|
67
|
+
# Or with global installation
|
|
68
|
+
reroute init my-app
|
|
69
|
+
reroute init my-blog --template blog
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**What gets created:**
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
your-app/
|
|
76
|
+
├── package.json
|
|
77
|
+
├── .gitignore
|
|
78
|
+
└── src/
|
|
79
|
+
├── index.ts # Server entry point with Elysia
|
|
80
|
+
└── client/
|
|
81
|
+
├── App.tsx # Root React component
|
|
82
|
+
├── index.tsx # Client entry point (hydration)
|
|
83
|
+
├── index.html # HTML template
|
|
84
|
+
├── routes/ # File-based routes
|
|
85
|
+
│ ├── index.tsx # Home page
|
|
86
|
+
│ ├── about.tsx # About page
|
|
87
|
+
│ └── [404].tsx # Not found page
|
|
88
|
+
└── components/ # React components
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For the blog template, additional files are created:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
└── client/
|
|
95
|
+
├── routes/
|
|
96
|
+
│ └── blog/
|
|
97
|
+
│ ├── index.tsx # Blog listing
|
|
98
|
+
│ ├── [slug].tsx # Dynamic blog post
|
|
99
|
+
│ ├── [layout].tsx # Blog layout
|
|
100
|
+
│ ├── [404].tsx # Blog not found
|
|
101
|
+
│ └── content/ # Blog posts
|
|
102
|
+
│ ├── hello-world.tsx
|
|
103
|
+
│ └── getting-started.tsx
|
|
104
|
+
└── components/
|
|
105
|
+
└── Counter.tsx
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `reroute gen`
|
|
109
|
+
|
|
110
|
+
Generate content registry and static assets from your routes.
|
|
111
|
+
|
|
112
|
+
**What it does:**
|
|
113
|
+
|
|
114
|
+
1. Scans your routes directory for `.tsx` and `.ts` files
|
|
115
|
+
2. Generates type-safe route patterns with dynamic parameters
|
|
116
|
+
3. Builds content chunks with cache-busted filenames
|
|
117
|
+
4. Creates collection-based content registries
|
|
118
|
+
5. Exports layouts and route matching utilities
|
|
119
|
+
|
|
120
|
+
**Usage:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
reroute gen
|
|
124
|
+
reroute gen --watch
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This command scans your `src/client/routes` directory and generates:
|
|
128
|
+
|
|
129
|
+
- `.reroute/routes.ts` - Type-safe route definitions with pattern matching
|
|
130
|
+
- `.reroute/content.ts` - Content registry with metadata and collections
|
|
131
|
+
- `.reroute/collections/*.js` - Per-collection runtime ESM modules
|
|
132
|
+
- `.reroute/chunks/**/*.js` - Bundled content components
|
|
133
|
+
- `.reroute/index.ts` - Aggregated exports for framework integration
|
|
134
|
+
|
|
135
|
+
**Options:**
|
|
136
|
+
|
|
137
|
+
- `--watch`, `-w` - Watch for changes and regenerate automatically
|
|
138
|
+
|
|
139
|
+
**Examples:**
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Generate once
|
|
143
|
+
bunx reroute-js gen
|
|
144
|
+
|
|
145
|
+
# Watch mode for development
|
|
146
|
+
bunx reroute-js gen --watch
|
|
147
|
+
|
|
148
|
+
# Or with global installation
|
|
149
|
+
reroute gen
|
|
150
|
+
reroute gen --watch
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Tailwind CSS v4 Integration
|
|
154
|
+
|
|
155
|
+
The CLI automatically detects and integrates with Tailwind CSS v4 when:
|
|
156
|
+
|
|
157
|
+
1. Both `tailwindcss` and `@tailwindcss/cli` are installed in your project dependencies
|
|
158
|
+
2. An input CSS file exists at `src/client/theme.css` with `@import "tailwindcss"`
|
|
159
|
+
|
|
160
|
+
When these conditions are met, the CLI will automatically:
|
|
161
|
+
|
|
162
|
+
- Build Tailwind CSS when running `reroute gen`
|
|
163
|
+
- Watch and rebuild Tailwind CSS in `reroute gen --watch` mode
|
|
164
|
+
- Output compiled CSS to `.reroute/theme.css`
|
|
165
|
+
|
|
166
|
+
### Setup
|
|
167
|
+
|
|
168
|
+
1. Install Tailwind CSS v4:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
bun add -d tailwindcss@next @tailwindcss/cli@next
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. Create your input CSS file at `src/client/theme.css`:
|
|
175
|
+
|
|
176
|
+
```css
|
|
177
|
+
@import "tailwindcss";
|
|
178
|
+
|
|
179
|
+
@theme {
|
|
180
|
+
/* Custom colors */
|
|
181
|
+
--color-primary-500: #3b82f6;
|
|
182
|
+
--color-primary-600: #2563eb;
|
|
183
|
+
|
|
184
|
+
/* Custom shadows */
|
|
185
|
+
--shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@utility btn {
|
|
189
|
+
padding: 0.75rem 1.5rem;
|
|
190
|
+
border-radius: 0.5rem;
|
|
191
|
+
font-weight: 600;
|
|
192
|
+
|
|
193
|
+
&:hover {
|
|
194
|
+
opacity: 0.9;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
3. Run the generator in watch mode:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
reroute gen --watch
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The CLI will automatically detect Tailwind v4 and compile your styles alongside the route generation!
|
|
206
|
+
|
|
207
|
+
### Why v4?
|
|
208
|
+
|
|
209
|
+
Tailwind CSS v4 is a complete rewrite with:
|
|
210
|
+
- **CSS-first configuration** using `@theme` directive (no JS config needed)
|
|
211
|
+
- **5x faster** full builds with the new Oxide engine
|
|
212
|
+
- **100x faster** incremental builds
|
|
213
|
+
- **Native** `@utility` directive for custom utilities
|
|
214
|
+
- Built-in support for modern CSS features
|
|
215
|
+
|
|
216
|
+
## Integration
|
|
217
|
+
|
|
218
|
+
The generated files are consumed by the Reroute framework in your project:
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
import { RerouteProvider } from 'reroute-js/react';
|
|
222
|
+
import { artifacts } from '../../.reroute';
|
|
223
|
+
|
|
224
|
+
interface AppProps {
|
|
225
|
+
pathname?: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export default function App({ pathname }: AppProps = {}) {
|
|
229
|
+
return <RerouteProvider from={{ pathname, ...artifacts }} />;
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Project Structure
|
|
234
|
+
|
|
235
|
+
For the CLI to work correctly, your project should follow this structure:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
your-app/
|
|
239
|
+
├── src/
|
|
240
|
+
│ └── client/
|
|
241
|
+
│ └── routes/
|
|
242
|
+
│ ├── index.tsx # / route
|
|
243
|
+
│ ├── about.tsx # /about route
|
|
244
|
+
│ ├── blog/
|
|
245
|
+
│ │ ├── [slug].tsx # /blog/:slug route
|
|
246
|
+
│ │ └── content/
|
|
247
|
+
│ │ ├── post-1.tsx # Content files
|
|
248
|
+
│ │ └── post-2.tsx
|
|
249
|
+
│ └── [layout].tsx # Layout wrapper
|
|
250
|
+
└── .reroute/ # Generated (gitignore this)
|
|
251
|
+
├── routes.ts
|
|
252
|
+
├── content.ts
|
|
253
|
+
├── index.ts
|
|
254
|
+
├── collections/
|
|
255
|
+
│ └── blog.js
|
|
256
|
+
└── chunks/
|
|
257
|
+
└── blog/
|
|
258
|
+
├── post-1.abc123.js
|
|
259
|
+
└── post-2.def456.js
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Reroute Core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic core utilities for the Reroute framework.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package contains the core, framework-independent logic for Reroute, including:
|
|
8
|
+
|
|
9
|
+
- **Bundler**: TypeScript/JSX transpilation and bundling utilities
|
|
10
|
+
- **Content**: Content discovery, metadata extraction, and registry management
|
|
11
|
+
- **SSR**: Server-side rendering utilities for React components
|
|
12
|
+
- **Template**: HTML template processing and manipulation
|
|
13
|
+
- **Utils**: Common utilities (compression, MIME types, path handling, caching)
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
This package is typically not used directly by end users. Instead, it's consumed by framework-specific adapters like `@reroute/elysia`.
|
|
18
|
+
|
|
19
|
+
However, if you're building a custom integration, you can import utilities directly:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import {
|
|
23
|
+
transpileFile,
|
|
24
|
+
getBundleUrlsFor,
|
|
25
|
+
renderSSRDocument,
|
|
26
|
+
discoverCollections,
|
|
27
|
+
applyIndexTemplate,
|
|
28
|
+
gzipIfAccepted
|
|
29
|
+
} from 'reroute-js/core';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
### Bundler
|
|
35
|
+
|
|
36
|
+
- `transpileFile(filePath, originalPath, options, bundleCache)` - Transpile and bundle a TypeScript/JSX file
|
|
37
|
+
- `getBundleUrlsFor(modules, clientDir, prefix, options, bundleCache)` - Get hashed bundle URLs for modules
|
|
38
|
+
- `generateContentHash(content)` - Generate SHA-256 hash for content versioning
|
|
39
|
+
|
|
40
|
+
### Content
|
|
41
|
+
|
|
42
|
+
- `discoverCollections(clientDir)` - Discover content collections in the routes directory
|
|
43
|
+
- `buildContentDTOs(collectionPath, clientDir, prefix, isWatchMode)` - Build content item DTOs for a collection
|
|
44
|
+
- `listContentFiles(dir, baseRel)` - Recursively list content files in a directory
|
|
45
|
+
- `getContentMeta(absPath, isWatchMode)` - Extract metadata from a content file
|
|
46
|
+
- `generateContentRegistry(cwd)` - Validate content registry existence
|
|
47
|
+
|
|
48
|
+
### SSR
|
|
49
|
+
|
|
50
|
+
- `renderSSRDocument(options)` - Render a React component to HTML with SSR
|
|
51
|
+
- `seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode)` - Seed SSR module cache for a content path
|
|
52
|
+
|
|
53
|
+
Per-page metadata: when a content module exports `meta` (or `frontmatter`) and/or `ssr`, SSR will automatically inject page `<head>` tags. Supported by default:
|
|
54
|
+
|
|
55
|
+
- `meta.title` -> `<title>`
|
|
56
|
+
- `meta.description` or `meta.excerpt` -> `<meta name="description">`
|
|
57
|
+
- `ssr.head` (string or string[]) is appended verbatim.
|
|
58
|
+
- `ssr.lang` overrides the `<html lang>` attribute for the response.
|
|
59
|
+
|
|
60
|
+
### Template
|
|
61
|
+
|
|
62
|
+
- `loadIndexHtml(clientDir)` - Load the index.html template
|
|
63
|
+
- `applyIndexTemplate(templateHtml, appHtml, context)` - Apply SSR content to HTML template
|
|
64
|
+
|
|
65
|
+
### Utils
|
|
66
|
+
|
|
67
|
+
- `gzipIfAccepted(body, contentType, acceptEncoding)` - Compress response if client accepts gzip
|
|
68
|
+
- `getMimeType(filePath)` - Get MIME type for a file
|
|
69
|
+
- `isCompressible(contentType)` - Check if content type is compressible
|
|
70
|
+
- `LRUCache<K, V>` - LRU cache implementation
|
|
71
|
+
- Path utilities: `join`, `basename`, `extname`, `stripStart`, `stripEnd`
|
|
72
|
+
|
|
73
|
+
## Types
|
|
74
|
+
|
|
75
|
+
All TypeScript types are exported, including:
|
|
76
|
+
|
|
77
|
+
- `Doc` - Generic document type
|
|
78
|
+
- `TemplateContext` - HTML template context
|
|
79
|
+
- `BundleInfo` - Bundle information with hash and code
|
|
80
|
+
- `ContentMeta` - Content metadata
|
|
81
|
+
- `ContentItemDTO` - Content item data transfer object
|
|
82
|
+
- `CoreConfig` - Core configuration options
|
|
83
|
+
- `BundleOptions` - Bundler options
|
|
84
|
+
- `CompressionResult` - Compression result with headers
|
|
85
|
+
- `SSRRenderOptions` - SSR rendering options
|
|
86
|
+
- `SSRRenderResult` - SSR rendering result
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Reroute Elysia
|
|
2
|
+
|
|
3
|
+
Elysia adapter for the Reroute framework. This package provides an Elysia plugin that enables server-side rendering, static file serving, content management, and live reload for React applications.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package is a thin adapter layer that integrates Reroute's core functionality with the Elysia web framework. It handles:
|
|
8
|
+
|
|
9
|
+
- **Server-Side Rendering (SSR)**: Automatic SSR for React components
|
|
10
|
+
- **Static File Serving**: Optimized static asset delivery with compression
|
|
11
|
+
- **Content Management**: File-based content collections with automatic discovery
|
|
12
|
+
- **Live Reload**: Development mode with hot reload via SSE
|
|
13
|
+
- **TypeScript/JSX Transpilation**: On-the-fly bundling with Bun
|
|
14
|
+
- **Asset Optimization**: Content hashing, compression, and caching
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bun add reroute-js elysia react react-dom
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Basic Setup
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { Elysia } from 'elysia';
|
|
28
|
+
import { reroute } from 'reroute-js/elysia';
|
|
29
|
+
import { createElement } from 'react';
|
|
30
|
+
import App from './App';
|
|
31
|
+
|
|
32
|
+
const app = new Elysia()
|
|
33
|
+
.use(
|
|
34
|
+
reroute({
|
|
35
|
+
app: createElement(App),
|
|
36
|
+
assets: 'src/client',
|
|
37
|
+
prefix: '/',
|
|
38
|
+
})
|
|
39
|
+
)
|
|
40
|
+
.listen(3000);
|
|
41
|
+
|
|
42
|
+
console.log(`Server running at http://localhost:3000`);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### With Collections
|
|
46
|
+
|
|
47
|
+
Content collections are automatically discovered from your `routes` directory:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
src/client/
|
|
51
|
+
├── routes/
|
|
52
|
+
│ ├── blog/
|
|
53
|
+
│ │ └── content/
|
|
54
|
+
│ │ ├── post-1.tsx
|
|
55
|
+
│ │ └── post-2.tsx
|
|
56
|
+
│ └── docs/
|
|
57
|
+
│ └── content/
|
|
58
|
+
│ └── guide.tsx
|
|
59
|
+
├── index.html
|
|
60
|
+
└── index.tsx
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Collections are accessible at:
|
|
64
|
+
- `/blog/post-1` - SSR rendered
|
|
65
|
+
- `/blog/post-2` - SSR rendered
|
|
66
|
+
- `/__content/blog` - JSON manifest with all blog posts
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
### `reroute(options: RerouteOptions)`
|
|
71
|
+
|
|
72
|
+
Creates an Elysia plugin with the provided configuration.
|
|
73
|
+
|
|
74
|
+
#### Options
|
|
75
|
+
|
|
76
|
+
##### SSR Options
|
|
77
|
+
|
|
78
|
+
- **`app?: ReactElement`** - Root React component for SSR. When provided, enables automatic SSR for all routes.
|
|
79
|
+
- **`head?: string`** - Additional HTML to inject into `<head>` (default: `''`)
|
|
80
|
+
- **`lang?: string`** - HTML document language (default: `'en'`)
|
|
81
|
+
- **`appId?: string`** - ID of the root element (default: `'root'`)
|
|
82
|
+
- **`entrypoint?: string`** - Client-side entry file (default: `'index.tsx'`)
|
|
83
|
+
|
|
84
|
+
##### Static Serving Options
|
|
85
|
+
|
|
86
|
+
- **`assets?: string`** - Assets directory path (default: `'src/client'`)
|
|
87
|
+
- **`prefix?: string`** - URL prefix for static files (default: `'/'`)
|
|
88
|
+
- **`ignorePatterns?: (string | RegExp)[]`** - Files to ignore (default: `['.DS_Store', '.git', '.env', 'index.html', /favicon\.ico/, /\.well-known/]`)
|
|
89
|
+
- **`staticHeaders?: Record<string, string>`** - Additional headers for static files
|
|
90
|
+
- **`maxAge?: number`** - Cache max-age in seconds (default: `3600`)
|
|
91
|
+
- **`directive?: string`** - Cache-Control directive (default: `'public'`)
|
|
92
|
+
- **`indexHTML?: boolean`** - Serve index.html for directories (default: `true`)
|
|
93
|
+
|
|
94
|
+
##### Build Options
|
|
95
|
+
|
|
96
|
+
- **`minify?: boolean`** - Minify JavaScript bundles (default: `process.env.NODE_ENV === 'production'`)
|
|
97
|
+
- **`sourcemap?: boolean`** - Generate sourcemaps (default: `true`)
|
|
98
|
+
|
|
99
|
+
## Features
|
|
100
|
+
|
|
101
|
+
### Automatic SSR
|
|
102
|
+
|
|
103
|
+
When you provide a root component via the `app` option, Reroute automatically:
|
|
104
|
+
|
|
105
|
+
1. Discovers content collections in your routes directory
|
|
106
|
+
2. Registers SSR routes for each collection (e.g., `/blog/*`, `/docs/*`)
|
|
107
|
+
3. Renders components on the server with React
|
|
108
|
+
4. Sends fully hydrated HTML to the client
|
|
109
|
+
5. Hydrates the client-side React app seamlessly
|
|
110
|
+
|
|
111
|
+
### Content Collections
|
|
112
|
+
|
|
113
|
+
Content files are TypeScript/TSX modules that export a React component and optional metadata:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
// src/client/routes/blog/content/my-post.tsx
|
|
117
|
+
export const meta = {
|
|
118
|
+
title: 'My Blog Post',
|
|
119
|
+
excerpt: 'This is a great post',
|
|
120
|
+
date: '2024-01-15',
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Optional SSR extras per page
|
|
124
|
+
export const ssr = {
|
|
125
|
+
// Extra tags appended verbatim into <head>
|
|
126
|
+
head: [
|
|
127
|
+
'<meta property="og:type" content="article" />',
|
|
128
|
+
],
|
|
129
|
+
// Override document language for this page
|
|
130
|
+
lang: 'en',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default function MyPost() {
|
|
134
|
+
return (
|
|
135
|
+
<article>
|
|
136
|
+
<h1>My Blog Post</h1>
|
|
137
|
+
<p>Content goes here...</p>
|
|
138
|
+
</article>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Access via:
|
|
144
|
+
- **Route**: `/blog/my-post` (SSR rendered)
|
|
145
|
+
- **API**: `/__content/blog` (JSON manifest)
|
|
146
|
+
|
|
147
|
+
During SSR, `meta.title` and `meta.description` (or `meta.excerpt`) are converted into `<title>` and `<meta name="description">`. Any `ssr.head` content is appended to `<head>`, and `ssr.lang` overrides the HTML `lang` attribute for that response.
|
|
148
|
+
|
|
149
|
+
### Development Mode
|
|
150
|
+
|
|
151
|
+
Run with `--watch` flag to enable live reload:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
bun --watch src/server.ts
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Features:
|
|
158
|
+
- File watching with automatic rebuild
|
|
159
|
+
- SSE-based live reload (no browser extension needed)
|
|
160
|
+
- Fast hot module replacement
|
|
161
|
+
- Source map support
|
|
162
|
+
|
|
163
|
+
### Production Optimization
|
|
164
|
+
|
|
165
|
+
In production:
|
|
166
|
+
- JavaScript bundles are minified
|
|
167
|
+
- Content is hashed for cache busting (e.g., `index.abc12345.js`)
|
|
168
|
+
- Responses are gzip compressed
|
|
169
|
+
- Aggressive caching headers for hashed assets
|
|
170
|
+
- Preloading hints for content chunks
|
|
171
|
+
|
|
172
|
+
## Routes
|
|
173
|
+
|
|
174
|
+
The Elysia plugin registers these routes automatically:
|
|
175
|
+
|
|
176
|
+
### Content Routes
|
|
177
|
+
- `/__content/:collection` - JSON manifest of collection items
|
|
178
|
+
|
|
179
|
+
### Development Routes (watch mode only)
|
|
180
|
+
- `/__reroute_watch` - SSE endpoint for live reload
|
|
181
|
+
- `/__reroute_watch.js` - Live reload client script
|
|
182
|
+
- `/__reroute_preload` - Content chunk preloader
|
|
183
|
+
|
|
184
|
+
### Artifact Routes
|
|
185
|
+
- `/.reroute/*` - Generated content chunks and bundles
|
|
186
|
+
|
|
187
|
+
### SSR Routes
|
|
188
|
+
- `/:collection/:slug` - Server-rendered collection items
|
|
189
|
+
- `/*` (fallback) - Catch-all SSR for unmatched routes
|
|
190
|
+
|
|
191
|
+
### Static Routes
|
|
192
|
+
- `${prefix}/*` - Static file serving with transpilation
|
|
193
|
+
|
|
194
|
+
## Architecture
|
|
195
|
+
|
|
196
|
+
This package is built on top of `reroute-js/core`, which provides framework-agnostic utilities. The Elysia adapter:
|
|
197
|
+
|
|
198
|
+
1. Translates Elysia request/response objects
|
|
199
|
+
2. Registers appropriate route handlers
|
|
200
|
+
3. Handles errors with Elysia's `NotFoundError`
|
|
201
|
+
4. Manages caches and live reload state
|
|
202
|
+
|
|
203
|
+
This separation allows Reroute to support multiple frameworks (Hono, Fastify, etc.) by creating similar adapter packages.
|
|
204
|
+
|
|
205
|
+
## Examples
|
|
206
|
+
|
|
207
|
+
### Custom Ignore Patterns
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
reroute({
|
|
211
|
+
ignorePatterns: [
|
|
212
|
+
'.DS_Store',
|
|
213
|
+
/\.test\.(ts|tsx|js|jsx)$/,
|
|
214
|
+
/^_/, // Ignore files starting with underscore
|
|
215
|
+
],
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Custom Headers
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
reroute({
|
|
223
|
+
staticHeaders: {
|
|
224
|
+
'X-Custom-Header': 'value',
|
|
225
|
+
'Access-Control-Allow-Origin': '*',
|
|
226
|
+
},
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Multiple Asset Directories
|
|
231
|
+
|
|
232
|
+
You can mount multiple reroute instances with different prefixes:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
new Elysia()
|
|
236
|
+
.use(reroute({ assets: 'src/client', prefix: '/app' }))
|
|
237
|
+
.use(reroute({ assets: 'src/admin', prefix: '/admin' }))
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## TypeScript
|
|
241
|
+
|
|
242
|
+
All types are exported from the package:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import type { RerouteOptions } from 'reroute-js/elysia';
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
MIT
|