@flight-framework/bundler-flightpack 0.1.4 → 0.1.6
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 +78 -135
- package/dist/index.d.ts +266 -409
- package/dist/index.js +215 -346
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,21 +4,19 @@ FlightPack native Rust bundler adapter for Flight Framework.
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This package provides the TypeScript adapter that integrates FlightPack with the Flight Framework bundler interface. It wraps the native NAPI bindings to provide a seamless developer experience
|
|
7
|
+
This package provides the TypeScript adapter that integrates FlightPack with the Flight Framework bundler interface. It wraps the native NAPI bindings to provide a seamless developer experience matching other Flight bundler adapters.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
- **Native Performance** - 1,874+ files/second processing speed
|
|
12
12
|
- **100% Rust Core** - No JavaScript runtime overhead in hot paths
|
|
13
13
|
- **Zero Configuration** - Works out of the box with TypeScript/TSX
|
|
14
|
-
- **Statement-Level Tree Shaking** - InnerGraph analysis for superior DCE
|
|
15
|
-
- **Persistent Build Cache** - TurboCache + ArtifactStore for incremental builds
|
|
16
|
-
- **Code Splitting** - ChunkSplitter with vendor/common chunk optimization
|
|
17
|
-
- **Platform-Aware Builds** - Automatic externals for browser/node/edge
|
|
18
|
-
- **React Server Components** - First-class RSC directive detection and manifests
|
|
19
|
-
- **CSS Processing** - Lightning CSS for modules, minification, autoprefixer
|
|
20
|
-
- **Module Federation** - Rspack-compatible micro-frontend support
|
|
21
14
|
- **HMR Support** - Native Axum WebSocket-based Hot Module Replacement
|
|
15
|
+
- **RSC Ready** - React Server Components with directive detection
|
|
16
|
+
- **CSS Processing** - Lightning CSS for modules, minification, autoprefixer
|
|
17
|
+
- **Universal Builds** - SSR, SSG, CSR, SPA, Edge deployment support
|
|
18
|
+
- **Tree Shaking** - Dead code elimination
|
|
19
|
+
- **Code Splitting** - Automatic chunk optimization
|
|
22
20
|
|
|
23
21
|
## Installation
|
|
24
22
|
|
|
@@ -40,189 +38,133 @@ export default defineConfig({
|
|
|
40
38
|
});
|
|
41
39
|
```
|
|
42
40
|
|
|
43
|
-
### With
|
|
41
|
+
### With Options
|
|
44
42
|
|
|
45
43
|
```typescript
|
|
46
44
|
import { flightpack } from '@flight-framework/bundler-flightpack';
|
|
47
45
|
|
|
48
46
|
export default defineConfig({
|
|
49
47
|
bundler: flightpack({
|
|
50
|
-
// Core Options
|
|
51
48
|
minify: true,
|
|
52
49
|
sourcemap: true,
|
|
53
50
|
target: 'es2022',
|
|
54
|
-
|
|
55
|
-
// Tree Shaking (InnerGraph - statement level)
|
|
51
|
+
rsc: true,
|
|
56
52
|
treeshake: true,
|
|
57
|
-
|
|
58
|
-
// Code Splitting (ChunkSplitter)
|
|
59
53
|
splitting: true,
|
|
60
|
-
chunkSizeLimit: 500,
|
|
61
|
-
|
|
62
|
-
// Persistent Caching
|
|
63
|
-
cache: true,
|
|
64
|
-
cacheDir: '.flightpack_cache',
|
|
65
|
-
|
|
66
|
-
// React Server Components
|
|
67
|
-
rsc: true,
|
|
68
|
-
|
|
69
|
-
// Platform & Externals
|
|
70
|
-
platform: 'browser', // 'browser' | 'node' | 'edge' | 'neutral'
|
|
71
|
-
external: [],
|
|
72
|
-
noExternal: [],
|
|
73
|
-
|
|
74
|
-
// Module Federation
|
|
75
|
-
federation: {
|
|
76
|
-
name: 'app',
|
|
77
|
-
filename: 'remoteEntry.js',
|
|
78
|
-
exposes: {
|
|
79
|
-
'./Button': './src/components/Button.tsx',
|
|
80
|
-
},
|
|
81
|
-
shared: {
|
|
82
|
-
react: { singleton: true },
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
// Development
|
|
87
|
-
hmr: true,
|
|
88
54
|
}),
|
|
89
55
|
});
|
|
90
56
|
```
|
|
91
57
|
|
|
92
|
-
##
|
|
93
|
-
|
|
94
|
-
The adapter implements a comprehensive 6-phase production build:
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
Phase 1/6: Client Build (Browser Platform)
|
|
98
|
-
Phase 2/6: Server Build (Node Platform, SSR)
|
|
99
|
-
Phase 3/6: Edge Build (Edge Platform, optional)
|
|
100
|
-
Phase 4/6: CSS Processing (Lightning CSS)
|
|
101
|
-
Phase 5/6: Static Assets (HTML injection, public files)
|
|
102
|
-
Phase 6/6: RSC Manifests (client/server references)
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Build Output Structure
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
dist/
|
|
109
|
-
client/
|
|
110
|
-
assets/
|
|
111
|
-
main.js - Client bundle
|
|
112
|
-
global.css - Processed CSS
|
|
113
|
-
index.html - HTML with injected scripts
|
|
114
|
-
react-client-manifest.json
|
|
115
|
-
server/
|
|
116
|
-
main.js - SSR bundle
|
|
117
|
-
react-server-manifest.json
|
|
118
|
-
edge/ - Optional edge bundle
|
|
119
|
-
.flightpack_cache/ - Persistent cache (content-addressed)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Configuration Reference
|
|
123
|
-
|
|
124
|
-
### Core Options
|
|
58
|
+
## Configuration Options
|
|
125
59
|
|
|
126
60
|
| Option | Type | Default | Description |
|
|
127
61
|
|--------|------|---------|-------------|
|
|
128
62
|
| `minify` | `boolean` | `true` | Enable minification in production |
|
|
129
|
-
| `sourcemap` | `boolean \| 'inline'
|
|
63
|
+
| `sourcemap` | `boolean \| 'inline'` | `true` | Generate source maps |
|
|
130
64
|
| `target` | `string` | `'es2022'` | JavaScript target environment |
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
|
135
|
-
|--------|------|---------|-------------|
|
|
136
|
-
| `treeshake` | `boolean \| TreeShakeConfig` | `true` | Enable InnerGraph tree shaking |
|
|
137
|
-
| `treeshake.innerGraph` | `boolean` | `true` | Statement-level dead code elimination |
|
|
138
|
-
| `treeshake.preserve` | `string[]` | `[]` | Modules to exclude from tree shaking |
|
|
139
|
-
|
|
140
|
-
### Code Splitting
|
|
141
|
-
|
|
142
|
-
| Option | Type | Default | Description |
|
|
143
|
-
|--------|------|---------|-------------|
|
|
144
|
-
| `splitting` | `boolean \| SplittingConfig` | `true` | Enable code splitting |
|
|
145
|
-
| `splitting.minSize` | `number` | - | Minimum shared chunk size in bytes |
|
|
146
|
-
| `splitting.maxSize` | `number` | - | Maximum chunk size before warning |
|
|
147
|
-
| `splitting.vendorChunk` | `boolean` | `true` | Extract vendor dependencies |
|
|
65
|
+
| `treeshake` | `boolean` | `true` | Enable tree shaking |
|
|
66
|
+
| `rsc` | `boolean` | `true` | Enable RSC directive detection |
|
|
67
|
+
| `hmr` | `boolean` | `true` | Enable HMR in development |
|
|
68
|
+
| `splitting` | `boolean` | `true` | Enable code splitting |
|
|
148
69
|
| `chunkSizeLimit` | `number` | `500` | Warn on chunks larger than (KB) |
|
|
149
70
|
|
|
150
|
-
|
|
71
|
+
## Bundler Interface
|
|
151
72
|
|
|
152
|
-
|
|
153
|
-
|--------|------|---------|-------------|
|
|
154
|
-
| `cache` | `boolean \| CacheConfig` | `true` | Enable incremental build cache |
|
|
155
|
-
| `cacheDir` | `string` | `.flightpack_cache` | Persistent cache directory |
|
|
156
|
-
| `cache.maxSize` | `number` | - | Maximum cache size in MB |
|
|
157
|
-
|
|
158
|
-
### Platform & Externals
|
|
159
|
-
|
|
160
|
-
| Option | Type | Default | Description |
|
|
161
|
-
|--------|------|---------|-------------|
|
|
162
|
-
| `platform` | `'browser' \| 'node' \| 'edge' \| 'neutral'` | `'browser'` | Target platform |
|
|
163
|
-
| `external` | `string[]` | `[]` | Packages to externalize |
|
|
164
|
-
| `noExternal` | `string[]` | `[]` | Force bundle (override auto-external) |
|
|
165
|
-
|
|
166
|
-
### React Server Components
|
|
73
|
+
The adapter implements the full `BundlerAdapter` interface:
|
|
167
74
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
interface BundlerAdapter {
|
|
77
|
+
name: string;
|
|
78
|
+
|
|
79
|
+
// Build operations
|
|
80
|
+
build(config: FlightConfig): Promise<BuildResult>;
|
|
81
|
+
transform(code: string, id: string, config: FlightConfig): Promise<TransformResult | null>;
|
|
82
|
+
|
|
83
|
+
// Development server
|
|
84
|
+
createDevServer(config: FlightConfig): Promise<DevServer>;
|
|
85
|
+
|
|
86
|
+
// Module resolution
|
|
87
|
+
resolve(id: string, importer: string | undefined, config: FlightConfig): Promise<string | null>;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
171
90
|
|
|
172
91
|
## Development Server
|
|
173
92
|
|
|
174
93
|
The dev server uses native Rust (Axum) for maximum performance:
|
|
175
94
|
|
|
176
95
|
```typescript
|
|
177
|
-
const adapter = flightpack();
|
|
96
|
+
const adapter = await flightpack();
|
|
178
97
|
const devServer = await adapter.createDevServer(config);
|
|
179
98
|
|
|
180
|
-
// Server with WebSocket HMR
|
|
181
|
-
|
|
99
|
+
// Server runs on native Axum with WebSocket HMR
|
|
100
|
+
await devServer.listen(3000);
|
|
101
|
+
|
|
102
|
+
// File watcher triggers HMR updates
|
|
103
|
+
devServer.on('update', (modules) => {
|
|
104
|
+
console.log('Updated:', modules);
|
|
105
|
+
});
|
|
182
106
|
|
|
183
107
|
// Graceful shutdown
|
|
184
108
|
await devServer.close();
|
|
185
109
|
```
|
|
186
110
|
|
|
187
|
-
## CSS
|
|
111
|
+
## CSS Handling
|
|
188
112
|
|
|
189
|
-
The adapter provides native
|
|
113
|
+
The adapter provides native CSS processing:
|
|
190
114
|
|
|
191
|
-
- CSS Minification
|
|
192
|
-
- CSS Modules
|
|
193
|
-
- Autoprefixer
|
|
194
|
-
- Source Maps
|
|
115
|
+
- **CSS Minification** - Lightning CSS for fast minification
|
|
116
|
+
- **CSS Modules** - Class name hashing with exports
|
|
117
|
+
- **Autoprefixer** - Automatic vendor prefixes
|
|
118
|
+
- **Source Maps** - Development debugging support
|
|
195
119
|
|
|
196
120
|
```typescript
|
|
197
|
-
//
|
|
121
|
+
// .css files are minified and injected
|
|
198
122
|
import './styles.css';
|
|
199
123
|
|
|
200
|
-
//
|
|
124
|
+
// .module.css files export class mappings
|
|
201
125
|
import styles from './component.module.css';
|
|
202
126
|
console.log(styles.button); // 'button_a1b2c3'
|
|
203
127
|
```
|
|
204
128
|
|
|
205
|
-
## Platform Support
|
|
129
|
+
## Universal Platform Support
|
|
130
|
+
|
|
131
|
+
The adapter includes utilities for multi-platform builds:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { flightpack } from '@flight-framework/bundler-flightpack';
|
|
206
135
|
|
|
207
|
-
|
|
136
|
+
// Access native externals detection
|
|
137
|
+
const native = await loadNativeBinding();
|
|
208
138
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
| Node | Node.js builtins | `node`, `import`, `module` |
|
|
213
|
-
| Edge | Edge-incompatible modules | `edge`, `worker`, `import`, `module` |
|
|
214
|
-
| Neutral | None | `import`, `module` |
|
|
139
|
+
// SSR - detect Node.js builtins to externalize
|
|
140
|
+
native.isNodeBuiltin('fs'); // true
|
|
141
|
+
native.isBareImport('express'); // true
|
|
215
142
|
|
|
216
|
-
|
|
143
|
+
// Edge - check runtime compatibility
|
|
144
|
+
native.isEdgeCompatible('crypto'); // true
|
|
145
|
+
native.isEdgeCompatible('fs'); // false
|
|
146
|
+
|
|
147
|
+
// Platform-specific resolve conditions
|
|
148
|
+
native.getPlatformConditions('browser'); // ['browser', 'import', 'module']
|
|
149
|
+
native.getPlatformConditions('node'); // ['node', 'import', 'module']
|
|
150
|
+
native.getPlatformConditions('edge'); // ['edge', 'worker', 'import', 'module']
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Performance
|
|
154
|
+
|
|
155
|
+
FlightPack benchmarks against Flight Framework monorepo:
|
|
217
156
|
|
|
218
157
|
```
|
|
219
158
|
Files Processed: 126
|
|
220
159
|
Total Lines: 36,231
|
|
221
|
-
|
|
160
|
+
|
|
161
|
+
Total Time: 67 ms
|
|
222
162
|
Files/second: 1,874
|
|
223
163
|
Lines/second: 538,908
|
|
224
164
|
```
|
|
225
165
|
|
|
166
|
+
### Comparison
|
|
167
|
+
|
|
226
168
|
| Bundler | Files/sec | Category |
|
|
227
169
|
|---------|-----------|----------|
|
|
228
170
|
| FlightPack | 1,874 | Elite |
|
|
@@ -233,7 +175,7 @@ Lines/second: 538,908
|
|
|
233
175
|
|
|
234
176
|
## Native Bindings
|
|
235
177
|
|
|
236
|
-
This adapter wraps `@flight-framework/flightpack` which provides 21 native
|
|
178
|
+
This adapter wraps the `@flight-framework/flightpack` NAPI package which provides 21 native functions:
|
|
237
179
|
|
|
238
180
|
| Category | Functions |
|
|
239
181
|
|----------|-----------|
|
|
@@ -241,7 +183,7 @@ This adapter wraps `@flight-framework/flightpack` which provides 21 native NAPI
|
|
|
241
183
|
| Dev Server | `startDevServer`, `stopDevServer`, `isDevServerRunning` |
|
|
242
184
|
| HMR | `sendHmrUpdate`, `sendHmrError`, `watchFiles`, `WatchHandle` |
|
|
243
185
|
| CSS | `transformCss`, `minifyCss`, `transformCssModule` |
|
|
244
|
-
|
|
|
186
|
+
| Universal | `isNodeBuiltin`, `getNodeBuiltins`, `isBareImport`, `isEdgeCompatible`, `getPlatformConditions` |
|
|
245
187
|
|
|
246
188
|
## Related Packages
|
|
247
189
|
|
|
@@ -250,6 +192,7 @@ This adapter wraps `@flight-framework/flightpack` which provides 21 native NAPI
|
|
|
250
192
|
| `@flight-framework/flightpack` | Native NAPI bindings |
|
|
251
193
|
| `@flight-framework/bundler` | Bundler interface definitions |
|
|
252
194
|
| `@flight-framework/bundler-vite` | Vite adapter alternative |
|
|
195
|
+
| `@flight-framework/bundler-esbuild` | esbuild adapter alternative |
|
|
253
196
|
|
|
254
197
|
## License
|
|
255
198
|
|