bertui 1.2.1 → 1.2.3
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/README.md +152 -197
- package/index.js +16 -8
- package/package.json +1 -1
- package/src/build/compiler/file-transpiler.js +92 -141
- package/src/build/compiler/index.js +23 -15
- package/src/build.js +149 -93
- package/src/client/compiler.js +169 -157
- package/src/config/defaultConfig.js +13 -4
- package/src/config/loadConfig.js +47 -32
- package/src/dev.js +34 -30
- package/src/logger/logger.js +294 -16
- package/src/server/dev-handler.js +11 -0
- package/src/server/dev-server-utils.js +262 -160
- package/src/utils/importhow.js +52 -0
package/README.md
CHANGED
|
@@ -1,267 +1,222 @@
|
|
|
1
|
-
|
|
1
|
+
# BertUI ⚡
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Zero-config React framework powered by Bun. File-based routing, Server Islands, and a build system that gets out of your way.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Zero configuration. 494ms dev server. 265ms builds. Perfect SEO with Server Islands.
|
|
8
|
-
**78% smaller images. 20x faster than Sharp. Zero Rust required.**
|
|
9
|
-
|
|
10
|
-
[](https://github.com/BunElysiaReact/BERTUI)
|
|
11
|
-
[](https://www.npmjs.com/package/bertui)
|
|
12
|
-
[](https://bun.sh)
|
|
13
|
-
[](https://www.rust-lang.org)
|
|
5
|
+
[](https://www.npmjs.com/package/bertui)
|
|
6
|
+
[](https://bun.sh)
|
|
14
7
|
[](LICENSE)
|
|
15
8
|
|
|
9
|
+
---
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
bunx create-bertui my-app && cd my-app && bun run dev
|
|
19
|
-
|
|
20
|
-
🦀 New in v1.1.7: Rust Image Optimization
|
|
21
|
-
|
|
22
|
-
BertUI now ships with a pre-compiled WASM image optimizer written in Rust.
|
|
23
|
-
Before (v1.1.6) After (v1.1.7) Gain
|
|
24
|
-
❌ No optimization ✅ PNG: 78% smaller 3.6x smaller
|
|
25
|
-
❌ Just copy ✅ JPEG: 75% smaller 4x smaller
|
|
26
|
-
❌ Large images ✅ WebP: 70% smaller 3.3x smaller
|
|
27
|
-
❌ Slow builds ✅ 20x faster than Sharp 2,000% faster
|
|
11
|
+
## Quick Start
|
|
28
12
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
```bash
|
|
14
|
+
bunx create-bertui my-app
|
|
15
|
+
cd my-app
|
|
16
|
+
bun run dev
|
|
17
|
+
```
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
const result = await optimizeImage(buffer, { format: 'png', quality: 80 });
|
|
37
|
-
// ✅ 78% smaller image in result.data
|
|
19
|
+
---
|
|
38
20
|
|
|
39
|
-
|
|
40
|
-
🎯 What BertUI Is
|
|
21
|
+
## What's New in v1.2.2
|
|
41
22
|
|
|
42
|
-
|
|
23
|
+
### Import Aliases (`importhow`)
|
|
24
|
+
No more `../../../` chains. Define aliases in your config and import cleanly from anywhere.
|
|
43
25
|
|
|
44
|
-
|
|
26
|
+
```javascript
|
|
27
|
+
// bertui.config.js
|
|
28
|
+
export default {
|
|
29
|
+
importhow: {
|
|
30
|
+
amani: '../components',
|
|
31
|
+
ui: '../components/ui',
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
45
35
|
|
|
46
|
-
|
|
36
|
+
```javascript
|
|
37
|
+
// anywhere in your project
|
|
38
|
+
import Button from 'amani/button';
|
|
39
|
+
import Card from 'ui/card';
|
|
40
|
+
```
|
|
47
41
|
|
|
48
|
-
|
|
42
|
+
Aliases are resolved at compile time — zero runtime overhead.
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
### Node Modules — Just Work
|
|
45
|
+
Install a package, import it. That's it.
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
```javascript
|
|
48
|
+
import { format } from 'date-fns';
|
|
49
|
+
import confetti from 'canvas-confetti';
|
|
50
|
+
```
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
In dev, packages are served from your local filesystem. In production, only the packages you actually import are bundled and tree-shaken into the output.
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
### CLI — New Look
|
|
55
|
+
The build and dev output is now compact and step-based instead of verbose line-by-line logs.
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
```
|
|
58
|
+
██████╗ ███████╗██████╗ ████████╗██╗ ██╗██╗
|
|
59
|
+
██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██║ ██║██║
|
|
60
|
+
██████╔╝█████╗ ██████╔╝ ██║ ██║ ██║██║
|
|
61
|
+
██╔══██╗██╔══╝ ██╔══██╗ ██║ ██║ ██║██║
|
|
62
|
+
██████╔╝███████╗██║ ██║ ██║ ╚██████╔╝██║
|
|
63
|
+
╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
|
64
|
+
by Pease Ernest · BUILD
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
[ 1/10] ✓ Loading env
|
|
67
|
+
[ 2/10] ✓ Compiling 5 routes · 1 islands
|
|
68
|
+
[ 3/10] ⠸ Layouts ...
|
|
69
|
+
...
|
|
70
|
+
✓ Done 0.54s
|
|
71
|
+
JS bundle 32.6 KB
|
|
72
|
+
Output dist/
|
|
73
|
+
```
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
⚡ Performance That Matters
|
|
75
|
+
Debug logs are written silently to `.bertui/dev.log`.
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Dev Server 494ms 713ms 2,100ms 1.4-4.3x faster ⚡
|
|
68
|
-
Prod Build 265ms 4,700ms 8,400ms 18-32x faster ⚡
|
|
69
|
-
Bundle Size 100KB 220KB 280KB 2.2-2.8x smaller ⚡
|
|
70
|
-
HMR Speed 30ms 85ms 120ms 2.8-4x faster ⚡
|
|
71
|
-
PNG Optimization 78% smaller 0% 0% 78% smaller 🦀
|
|
72
|
-
JPEG Optimization 75% smaller 0% 0% 75% smaller 🦀
|
|
77
|
+
### Dev Server — No More Restarts
|
|
78
|
+
Run `bun add some-package` and the dev server picks it up automatically. The import map rebuilds and the browser reloads — no restart needed.
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
🏝️ Server Islands: Perfect SEO, Zero Complexity
|
|
80
|
+
---
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
## Features
|
|
78
83
|
|
|
79
|
-
|
|
84
|
+
### File-Based Routing
|
|
80
85
|
|
|
81
|
-
|
|
86
|
+
```
|
|
87
|
+
src/pages/index.jsx → /
|
|
88
|
+
src/pages/about.jsx → /about
|
|
89
|
+
src/pages/blog/index.jsx → /blog
|
|
90
|
+
src/pages/blog/[slug].jsx → /blog/:slug
|
|
91
|
+
```
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
### Server Islands
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
jsx
|
|
95
|
+
Add one line to opt a page into static generation at build time.
|
|
87
96
|
|
|
97
|
+
```jsx
|
|
88
98
|
// src/pages/about.jsx
|
|
89
|
-
|
|
90
|
-
// 🏝️ Add ONE line to enable static generation
|
|
91
99
|
export const render = "server";
|
|
92
|
-
|
|
93
|
-
// 🎯 Optional: Add SEO metadata
|
|
94
100
|
export const title = "About Us";
|
|
95
|
-
export const description = "Learn about our team";
|
|
96
101
|
|
|
97
|
-
// ⚛️ Write normal React (no hooks, no event handlers)
|
|
98
102
|
export default function About() {
|
|
99
103
|
return (
|
|
100
104
|
<div>
|
|
101
105
|
<h1>About Us</h1>
|
|
102
|
-
<p>
|
|
106
|
+
<p>Pre-rendered as static HTML at build time.</p>
|
|
103
107
|
</div>
|
|
104
108
|
);
|
|
105
109
|
}
|
|
110
|
+
```
|
|
106
111
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
✅ Auto-adds to sitemap.xml
|
|
112
|
-
|
|
113
|
-
✅ Perfect SEO without SSR complexity
|
|
114
|
-
|
|
115
|
-
✅ Still builds in 265ms
|
|
116
|
-
|
|
117
|
-
🦀 Image Optimization (Just Works)
|
|
118
|
-
|
|
119
|
-
No configuration. No Rust installation. Just smaller images.
|
|
120
|
-
bash
|
|
112
|
+
- Static HTML embedded in the output for instant load and perfect SEO
|
|
113
|
+
- Pages with hooks or event handlers are rejected at build time with a clear error
|
|
114
|
+
- All other pages are client-only by default
|
|
121
115
|
|
|
122
|
-
|
|
123
|
-
bun run build
|
|
116
|
+
### TypeScript
|
|
124
117
|
|
|
125
|
-
|
|
118
|
+
`.tsx` and `.ts` files work with no setup. Mix them freely with `.jsx`.
|
|
126
119
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
✓ icon.webp: 89KB → 26KB (70% saved)
|
|
131
|
-
✅ Optimized 12 images, saved 3.4MB
|
|
132
|
-
|
|
133
|
-
Or use the API directly:
|
|
134
|
-
js
|
|
120
|
+
```typescript
|
|
121
|
+
// src/pages/blog/[slug].tsx
|
|
122
|
+
import { useRouter } from 'bertui/router';
|
|
135
123
|
|
|
136
|
-
|
|
124
|
+
export default function BlogPost() {
|
|
125
|
+
const { params } = useRouter();
|
|
126
|
+
return <h1>Post: {params.slug}</h1>;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
137
129
|
|
|
138
|
-
|
|
139
|
-
const result = await optimizeImage(buffer, {
|
|
140
|
-
format: 'png',
|
|
141
|
-
quality: 80 // 0-100, default 80
|
|
142
|
-
});
|
|
130
|
+
### SEO
|
|
143
131
|
|
|
144
|
-
|
|
145
|
-
const results = await optimizeImagesBatch(images, 'webp');
|
|
132
|
+
`sitemap.xml` and `robots.txt` are generated automatically from your routes. Requires `baseUrl` in config.
|
|
146
133
|
|
|
147
|
-
|
|
148
|
-
|
|
134
|
+
```javascript
|
|
135
|
+
export default {
|
|
136
|
+
baseUrl: 'https://example.com',
|
|
137
|
+
robots: {
|
|
138
|
+
disallow: ['/admin'],
|
|
139
|
+
crawlDelay: 1,
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
149
143
|
|
|
150
|
-
|
|
151
|
-
bunx create-bertui my-app
|
|
144
|
+
### CSS
|
|
152
145
|
|
|
153
|
-
|
|
154
|
-
cd my-app
|
|
155
|
-
bun run dev
|
|
146
|
+
Put your styles in `src/styles/`. They are combined and minified with LightningCSS into a single `bertui.min.css`.
|
|
156
147
|
|
|
157
|
-
|
|
158
|
-
bun run build
|
|
148
|
+
---
|
|
159
149
|
|
|
160
|
-
|
|
161
|
-
📁 Project Structure
|
|
162
|
-
text
|
|
150
|
+
## Project Structure
|
|
163
151
|
|
|
152
|
+
```
|
|
164
153
|
my-app/
|
|
165
154
|
├── src/
|
|
166
|
-
│ ├── pages/
|
|
167
|
-
│
|
|
168
|
-
│
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
│ ├──
|
|
172
|
-
│
|
|
173
|
-
│
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
└── package.json
|
|
183
|
-
|
|
184
|
-
🛣️ File-Based Routing
|
|
185
|
-
|
|
186
|
-
Just create files. BertUI handles the rest.
|
|
187
|
-
text
|
|
188
|
-
|
|
189
|
-
src/pages/index.jsx → /
|
|
190
|
-
src/pages/about.jsx → /about
|
|
191
|
-
src/pages/blog/index.jsx → /blog
|
|
192
|
-
src/pages/blog/[slug].jsx → /blog/:slug
|
|
193
|
-
|
|
194
|
-
Dynamic routes with TypeScript:
|
|
195
|
-
typescript
|
|
196
|
-
|
|
197
|
-
// src/pages/blog/[slug].tsx
|
|
198
|
-
import { useRouter } from 'bertui/router';
|
|
199
|
-
|
|
200
|
-
interface Params {
|
|
201
|
-
slug: string;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export default function BlogPost() {
|
|
205
|
-
const { params } = useRouter<Params>();
|
|
206
|
-
return <h1>Post: {params.slug}</h1>;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
⚙️ Configuration (Optional)
|
|
210
|
-
javascript
|
|
211
|
-
|
|
155
|
+
│ ├── pages/ # File-based routing
|
|
156
|
+
│ ├── components/ # Your components
|
|
157
|
+
│ └── styles/ # Global CSS
|
|
158
|
+
├── public/ # Static assets
|
|
159
|
+
├── dist/ # Production output
|
|
160
|
+
│ ├── sitemap.xml
|
|
161
|
+
│ ├── robots.txt
|
|
162
|
+
│ └── assets/
|
|
163
|
+
└── bertui.config.js
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
212
171
|
// bertui.config.js
|
|
213
172
|
export default {
|
|
214
|
-
siteName:
|
|
215
|
-
baseUrl:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
quality: 80, // JPEG/PNG quality (0-100)
|
|
220
|
-
webpQuality: 75, // WebP quality (0-100)
|
|
221
|
-
stripMetadata: true // Remove EXIF data
|
|
173
|
+
siteName: 'My Site',
|
|
174
|
+
baseUrl: 'https://example.com',
|
|
175
|
+
|
|
176
|
+
importhow: {
|
|
177
|
+
ui: '../components/ui',
|
|
222
178
|
},
|
|
223
|
-
|
|
224
|
-
robots: {
|
|
225
|
-
disallow: ["/admin", "/api"],
|
|
226
|
-
crawlDelay: 1
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
179
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Bundle Size 100KB 280KB 220KB 250KB
|
|
235
|
-
Image Optimization ✅ 78% smaller ❌ No ❌ No ❌ No
|
|
236
|
-
Server Islands ✅ Built-in ❌ No ❌ No ❌ No
|
|
237
|
-
Auto SEO ✅ Yes ⚠️ Manual ❌ No ⚠️ Manual
|
|
238
|
-
TypeScript ✅ No setup ✅ Config needed ✅ Config needed ✅ Config needed
|
|
239
|
-
Rust Required ❌ NO N/A N/A N/A
|
|
240
|
-
🚀 Coming Soon
|
|
180
|
+
robots: {
|
|
181
|
+
disallow: ['/admin'],
|
|
182
|
+
crawlDelay: 1,
|
|
183
|
+
},
|
|
241
184
|
|
|
242
|
-
|
|
185
|
+
meta: {
|
|
186
|
+
title: 'My Site',
|
|
187
|
+
description: 'Built with BertUI',
|
|
188
|
+
themeColor: '#000000',
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
```
|
|
243
192
|
|
|
244
|
-
|
|
193
|
+
---
|
|
245
194
|
|
|
246
|
-
|
|
195
|
+
## Performance
|
|
247
196
|
|
|
248
|
-
|
|
197
|
+
Benchmarks on an Intel i3-2348M, 7.6GB RAM.
|
|
249
198
|
|
|
250
|
-
|
|
199
|
+
| Metric | BertUI | Vite | Next.js |
|
|
200
|
+
|--------------|---------|---------|---------|
|
|
201
|
+
| Dev start | 494ms | 713ms | 2,100ms |
|
|
202
|
+
| Prod build | 265ms | 4,700ms | 8,400ms |
|
|
203
|
+
| Bundle size | ~32KB | 220KB | 280KB |
|
|
204
|
+
| HMR | 30ms | 85ms | 120ms |
|
|
251
205
|
|
|
252
|
-
|
|
206
|
+
---
|
|
253
207
|
|
|
254
|
-
|
|
208
|
+
## Coming Soon
|
|
255
209
|
|
|
256
|
-
|
|
210
|
+
- `bertui-elysia` — API routes, auth, database
|
|
211
|
+
- `bertui-animate` — GPU-accelerated animations
|
|
257
212
|
|
|
258
|
-
|
|
213
|
+
---
|
|
259
214
|
|
|
260
|
-
|
|
215
|
+
## Credits
|
|
261
216
|
|
|
262
|
-
|
|
217
|
+
- Runtime: [Bun](https://bun.sh)
|
|
218
|
+
- CSS: [LightningCSS](https://lightningcss.dev)
|
|
263
219
|
|
|
264
|
-
|
|
220
|
+
---
|
|
265
221
|
|
|
266
|
-
|
|
267
|
-
</div> ```
|
|
222
|
+
Made by Pease Ernest
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// bertui/index.js - v1.
|
|
1
|
+
// bertui/index.js - v1.3.0
|
|
2
2
|
|
|
3
3
|
// Compiler
|
|
4
4
|
export { compileProject, compileFile } from './src/client/compiler.js';
|
|
@@ -33,7 +33,7 @@ export { default as logger } from './src/logger/logger.js';
|
|
|
33
33
|
// CLI
|
|
34
34
|
export { program } from './src/cli.js';
|
|
35
35
|
|
|
36
|
-
// ✅
|
|
36
|
+
// ✅ Middleware system
|
|
37
37
|
export {
|
|
38
38
|
MiddlewareManager,
|
|
39
39
|
loadMiddleware,
|
|
@@ -41,7 +41,7 @@ export {
|
|
|
41
41
|
MiddlewareContext,
|
|
42
42
|
} from './src/middleware/index.js';
|
|
43
43
|
|
|
44
|
-
// ✅
|
|
44
|
+
// ✅ Layout system
|
|
45
45
|
export {
|
|
46
46
|
discoverLayouts,
|
|
47
47
|
compileLayouts,
|
|
@@ -50,7 +50,7 @@ export {
|
|
|
50
50
|
injectLayoutsIntoRouter,
|
|
51
51
|
} from './src/layouts/index.js';
|
|
52
52
|
|
|
53
|
-
// ✅
|
|
53
|
+
// ✅ Loading states
|
|
54
54
|
export {
|
|
55
55
|
discoverLoadingComponents,
|
|
56
56
|
compileLoadingComponents,
|
|
@@ -59,7 +59,7 @@ export {
|
|
|
59
59
|
DEFAULT_LOADING_HTML,
|
|
60
60
|
} from './src/loading/index.js';
|
|
61
61
|
|
|
62
|
-
// ✅
|
|
62
|
+
// ✅ Partial hydration
|
|
63
63
|
export {
|
|
64
64
|
needsHydration,
|
|
65
65
|
getInteractiveFeatures,
|
|
@@ -68,10 +68,10 @@ export {
|
|
|
68
68
|
logHydrationReport,
|
|
69
69
|
} from './src/hydration/index.js';
|
|
70
70
|
|
|
71
|
-
// ✅
|
|
71
|
+
// ✅ Bundle analyzer
|
|
72
72
|
export { analyzeBuild } from './src/analyzer/index.js';
|
|
73
73
|
|
|
74
|
-
// ✅
|
|
74
|
+
// ✅ CLI scaffolder
|
|
75
75
|
export { scaffold, parseCreateArgs } from './src/scaffolder/index.js';
|
|
76
76
|
|
|
77
77
|
// Server
|
|
@@ -91,5 +91,13 @@ export {
|
|
|
91
91
|
validateServerIsland,
|
|
92
92
|
} from './src/server-islands/index.js';
|
|
93
93
|
|
|
94
|
+
// ✅ NEW: importhow — alias/import resolution system
|
|
95
|
+
// Bunny and external tools can use these to apply the same alias logic
|
|
96
|
+
export {
|
|
97
|
+
buildAliasMap,
|
|
98
|
+
rewriteAliasImports,
|
|
99
|
+
getAliasDirs,
|
|
100
|
+
} from './src/utils/importhow.js';
|
|
101
|
+
|
|
94
102
|
// Version
|
|
95
|
-
export const version = '1.2.
|
|
103
|
+
export const version = '1.2.2';
|
package/package.json
CHANGED