@zenithbuild/bundler 0.5.0-beta.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 +138 -0
- package/package.json +33 -0
- package/target/release/zenith-bundler +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Zenith Bundler
|
|
2
|
+
|
|
3
|
+
> **⚠️ Internal API:** This package is an internal implementation detail of the Zenith framework. It is not intended for public use and its API may break without warning. Please use `@zenithbuild/core` instead.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Zero-Cost Abstraction Bundler for the Zenith Framework.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The Zenith Bundler provides capability-based runtime chunking, CSS pruning, and deferred hydration for optimal production builds. Instead of shipping a monolithic runtime, it selectively includes only the capabilities used by each page.
|
|
11
|
+
|
|
12
|
+
## Architecture
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Compiler (ZenIR) → Manifest → Bundler → Optimized Output
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Runtime Slices
|
|
19
|
+
|
|
20
|
+
| Slice | Size | When Included |
|
|
21
|
+
|-------|------|---------------|
|
|
22
|
+
| **Core** | ~2KB | Always required |
|
|
23
|
+
| **Reactivity** | ~8KB | If `{value}` expressions or state used |
|
|
24
|
+
| **Hydration** | ~5KB | If page is interactive |
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Rust crate
|
|
30
|
+
cargo add zenith-bundler
|
|
31
|
+
|
|
32
|
+
# TypeScript package
|
|
33
|
+
bun add @zenithbuild/bundler
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Rust
|
|
39
|
+
|
|
40
|
+
```rust
|
|
41
|
+
use zenith_bundler::{bundle, analyze_manifest, ZenManifest};
|
|
42
|
+
|
|
43
|
+
let manifest = ZenManifest::new("src/pages/index.zen".to_string());
|
|
44
|
+
let analysis = analyze_manifest(&manifest);
|
|
45
|
+
|
|
46
|
+
println!("Required slices: {:?}", analysis.required_slices);
|
|
47
|
+
println!("Is static: {}", analysis.is_static);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### TypeScript
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { bundle, generateRuntime } from '@zenithbuild/bundler'
|
|
54
|
+
|
|
55
|
+
// Full production bundle
|
|
56
|
+
const result = bundle(manifest, {
|
|
57
|
+
minifyJs: true,
|
|
58
|
+
minifyCss: true,
|
|
59
|
+
basePath: '/assets/'
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// Dev server (HMR)
|
|
63
|
+
const { code, slices } = generateRuntime(manifest, true)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API
|
|
67
|
+
|
|
68
|
+
### `bundle(manifest, options?)`
|
|
69
|
+
|
|
70
|
+
Generates complete HTML/JS/CSS output.
|
|
71
|
+
|
|
72
|
+
**Options:**
|
|
73
|
+
- `minifyJs` - Minify JavaScript (default: true)
|
|
74
|
+
- `minifyCss` - Minify CSS (default: true)
|
|
75
|
+
- `inlineCriticalCss` - Inline critical CSS (default: true)
|
|
76
|
+
- `sourceMaps` - Generate source maps (default: false)
|
|
77
|
+
- `devMode` - Skip optimizations (default: false)
|
|
78
|
+
- `basePath` - Asset base path (default: "/")
|
|
79
|
+
- `lazyLoad` - Lazy load non-critical chunks (default: true)
|
|
80
|
+
- `maxChunkSize` - Max chunk size in bytes (default: 50000)
|
|
81
|
+
|
|
82
|
+
### `generateRuntime(manifest, devMode?)`
|
|
83
|
+
|
|
84
|
+
Generates only the runtime code (for HMR/dev server).
|
|
85
|
+
|
|
86
|
+
### `analyzeManifest(manifest)`
|
|
87
|
+
|
|
88
|
+
Analyzes a manifest and returns required slices.
|
|
89
|
+
|
|
90
|
+
## Bundle Size Budgets
|
|
91
|
+
|
|
92
|
+
| Page Type | Budget |
|
|
93
|
+
|-----------|--------|
|
|
94
|
+
| Static | < 5KB |
|
|
95
|
+
| Interactive | < 20KB |
|
|
96
|
+
| Complex | < 50KB |
|
|
97
|
+
|
|
98
|
+
Run size gate: `bun run js/scripts/size-gate.ts`
|
|
99
|
+
|
|
100
|
+
## Testing
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Rust tests
|
|
104
|
+
cargo test
|
|
105
|
+
|
|
106
|
+
# TypeScript tests
|
|
107
|
+
cd js && bun test
|
|
108
|
+
|
|
109
|
+
# Size gate
|
|
110
|
+
cd js && bun run scripts/size-gate.ts
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Project Structure
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
zenith-bundler/
|
|
117
|
+
├── src/
|
|
118
|
+
│ ├── lib.rs # Main exports
|
|
119
|
+
│ ├── analysis.rs # Manifest analysis
|
|
120
|
+
│ ├── chunking/ # Chunk computation
|
|
121
|
+
│ ├── codegen/ # Runtime generation
|
|
122
|
+
│ ├── css/ # CSS optimization
|
|
123
|
+
│ └── manifest/ # Types & capabilities
|
|
124
|
+
├── tests/
|
|
125
|
+
│ └── integration.rs # Integration tests
|
|
126
|
+
└── js/
|
|
127
|
+
├── src/
|
|
128
|
+
│ ├── index.ts # TypeScript API
|
|
129
|
+
│ ├── types.ts # TypeScript types
|
|
130
|
+
│ └── index.test.ts
|
|
131
|
+
└── scripts/
|
|
132
|
+
└── size-gate.ts # Bundle size CI gate
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT
|
|
138
|
+
# zenith-bundler
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenithbuild/bundler",
|
|
3
|
+
"version": "0.5.0-beta.2.3",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "cargo build --release",
|
|
6
|
+
"contract:deps": "node dependency_contract.spec.js",
|
|
7
|
+
"contract:scan": "node contract-scan.mjs",
|
|
8
|
+
"contract:imports": "node --test tests/template_import_boundary.test.js",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bun": "latest",
|
|
13
|
+
"typescript": "^5"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"target/release/zenith-bundler",
|
|
17
|
+
"package.json",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@zenithbuild/core": "0.5.0-beta.2.3",
|
|
23
|
+
"@zenithbuild/router": "0.5.0-beta.2.3",
|
|
24
|
+
"@zenithbuild/runtime": "0.5.0-beta.2.3",
|
|
25
|
+
"chokidar": "^5.0.0",
|
|
26
|
+
"esbuild": "^0.27.3",
|
|
27
|
+
"express": "^4.21.2",
|
|
28
|
+
"rolldown": "^1.0.0-rc.3",
|
|
29
|
+
"ws": "^8.19.0"
|
|
30
|
+
},
|
|
31
|
+
"type": "module",
|
|
32
|
+
"private": false
|
|
33
|
+
}
|
|
Binary file
|