@flight-framework/bundler-flightpack 0.1.3 → 0.1.4

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 CHANGED
@@ -4,19 +4,21 @@ 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 matching other Flight bundler adapters.
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 with maximum performance.
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
- - **HMR Support** - Native Axum WebSocket-based Hot Module Replacement
15
- - **RSC Ready** - React Server Components with directive detection
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
16
19
  - **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
20
+ - **Module Federation** - Rspack-compatible micro-frontend support
21
+ - **HMR Support** - Native Axum WebSocket-based Hot Module Replacement
20
22
 
21
23
  ## Installation
22
24
 
@@ -38,133 +40,189 @@ export default defineConfig({
38
40
  });
39
41
  ```
40
42
 
41
- ### With Options
43
+ ### With Full Options
42
44
 
43
45
  ```typescript
44
46
  import { flightpack } from '@flight-framework/bundler-flightpack';
45
47
 
46
48
  export default defineConfig({
47
49
  bundler: flightpack({
50
+ // Core Options
48
51
  minify: true,
49
52
  sourcemap: true,
50
53
  target: 'es2022',
51
- rsc: true,
54
+
55
+ // Tree Shaking (InnerGraph - statement level)
52
56
  treeshake: true,
57
+
58
+ // Code Splitting (ChunkSplitter)
53
59
  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,
54
88
  }),
55
89
  });
56
90
  ```
57
91
 
58
- ## Configuration Options
92
+ ## Build Process
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
59
125
 
60
126
  | Option | Type | Default | Description |
61
127
  |--------|------|---------|-------------|
62
128
  | `minify` | `boolean` | `true` | Enable minification in production |
63
- | `sourcemap` | `boolean \| 'inline'` | `true` | Generate source maps |
129
+ | `sourcemap` | `boolean \| 'inline' \| 'hidden'` | `true` | Generate source maps |
64
130
  | `target` | `string` | `'es2022'` | JavaScript target environment |
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 |
131
+
132
+ ### Tree Shaking
133
+
134
+ | Option | Type | Default | Description |
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 |
69
148
  | `chunkSizeLimit` | `number` | `500` | Warn on chunks larger than (KB) |
70
149
 
71
- ## Bundler Interface
150
+ ### Caching
72
151
 
73
- The adapter implements the full `BundlerAdapter` interface:
152
+ | Option | Type | Default | Description |
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 |
74
157
 
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
- ```
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
167
+
168
+ | Option | Type | Default | Description |
169
+ |--------|------|---------|-------------|
170
+ | `rsc` | `boolean` | `true` | Enable RSC directive detection |
90
171
 
91
172
  ## Development Server
92
173
 
93
174
  The dev server uses native Rust (Axum) for maximum performance:
94
175
 
95
176
  ```typescript
96
- const adapter = await flightpack();
177
+ const adapter = flightpack();
97
178
  const devServer = await adapter.createDevServer(config);
98
179
 
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
- });
180
+ // Server with WebSocket HMR
181
+ console.log(devServer.url); // http://localhost:5173
106
182
 
107
183
  // Graceful shutdown
108
184
  await devServer.close();
109
185
  ```
110
186
 
111
- ## CSS Handling
187
+ ## CSS Processing
112
188
 
113
- The adapter provides native CSS processing:
189
+ The adapter provides native Lightning CSS processing:
114
190
 
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
191
+ - CSS Minification with optimal compression
192
+ - CSS Modules with class name hashing
193
+ - Autoprefixer with configurable browser targets
194
+ - Source Maps for development debugging
119
195
 
120
196
  ```typescript
121
- // .css files are minified and injected
197
+ // Standard CSS - minified and bundled
122
198
  import './styles.css';
123
199
 
124
- // .module.css files export class mappings
200
+ // CSS Modules - exports class mappings
125
201
  import styles from './component.module.css';
126
202
  console.log(styles.button); // 'button_a1b2c3'
127
203
  ```
128
204
 
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';
205
+ ## Platform Support
135
206
 
136
- // Access native externals detection
137
- const native = await loadNativeBinding();
207
+ The adapter automatically handles platform-specific externals:
138
208
 
139
- // SSR - detect Node.js builtins to externalize
140
- native.isNodeBuiltin('fs'); // true
141
- native.isBareImport('express'); // true
209
+ | Platform | Auto-External | Resolve Conditions |
210
+ |----------|---------------|-------------------|
211
+ | Browser | None | `browser`, `import`, `module` |
212
+ | Node | Node.js builtins | `node`, `import`, `module` |
213
+ | Edge | Edge-incompatible modules | `edge`, `worker`, `import`, `module` |
214
+ | Neutral | None | `import`, `module` |
142
215
 
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:
216
+ ## Performance Benchmarks
156
217
 
157
218
  ```
158
219
  Files Processed: 126
159
220
  Total Lines: 36,231
160
-
161
- Total Time: 67 ms
221
+ Total Time: 66 ms
162
222
  Files/second: 1,874
163
223
  Lines/second: 538,908
164
224
  ```
165
225
 
166
- ### Comparison
167
-
168
226
  | Bundler | Files/sec | Category |
169
227
  |---------|-----------|----------|
170
228
  | FlightPack | 1,874 | Elite |
@@ -175,7 +233,7 @@ Lines/second: 538,908
175
233
 
176
234
  ## Native Bindings
177
235
 
178
- This adapter wraps the `@flight-framework/flightpack` NAPI package which provides 21 native functions:
236
+ This adapter wraps `@flight-framework/flightpack` which provides 21 native NAPI functions:
179
237
 
180
238
  | Category | Functions |
181
239
  |----------|-----------|
@@ -183,7 +241,7 @@ This adapter wraps the `@flight-framework/flightpack` NAPI package which provide
183
241
  | Dev Server | `startDevServer`, `stopDevServer`, `isDevServerRunning` |
184
242
  | HMR | `sendHmrUpdate`, `sendHmrError`, `watchFiles`, `WatchHandle` |
185
243
  | CSS | `transformCss`, `minifyCss`, `transformCssModule` |
186
- | Universal | `isNodeBuiltin`, `getNodeBuiltins`, `isBareImport`, `isEdgeCompatible`, `getPlatformConditions` |
244
+ | Platform | `isNodeBuiltin`, `getNodeBuiltins`, `isBareImport`, `isEdgeCompatible`, `getPlatformConditions` |
187
245
 
188
246
  ## Related Packages
189
247
 
@@ -192,7 +250,6 @@ This adapter wraps the `@flight-framework/flightpack` NAPI package which provide
192
250
  | `@flight-framework/flightpack` | Native NAPI bindings |
193
251
  | `@flight-framework/bundler` | Bundler interface definitions |
194
252
  | `@flight-framework/bundler-vite` | Vite adapter alternative |
195
- | `@flight-framework/bundler-esbuild` | esbuild adapter alternative |
196
253
 
197
254
  ## License
198
255