@flight-framework/bundler-flightpack 0.1.7 → 0.1.8
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/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,11 +35,11 @@ function flightpack(options = {}) {
|
|
|
35
35
|
options,
|
|
36
36
|
async createDevServer(config) {
|
|
37
37
|
const native = await loadNativeBinding();
|
|
38
|
-
const
|
|
38
|
+
const internalPort = (config.dev.port ?? 5173) + 1e3;
|
|
39
39
|
const host = config.dev.host ?? "localhost";
|
|
40
40
|
const https = config.dev.https === true;
|
|
41
41
|
const result = await native.startDevServer({
|
|
42
|
-
port,
|
|
42
|
+
port: internalPort,
|
|
43
43
|
publicDir: resolvePath(config.root, "public"),
|
|
44
44
|
outDir: resolvePath(config.root, config.build.outDir),
|
|
45
45
|
hmr: options.hmr ?? true,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\r\n * @flight-framework/bundler-flightpack\r\n * \r\n * FlightPack native Rust bundler adapter for Flight Framework.\r\n * Wraps the native Rust bundler for maximum performance.\r\n * \r\n * @example\r\n * ```typescript\r\n * // In flight.config.ts\r\n * import { defineConfig } from '@flight-framework/core';\r\n * import { flightpack } from '@flight-framework/bundler-flightpack';\r\n * \r\n * export default defineConfig({\r\n * bundler: flightpack(),\r\n * });\r\n * ```\r\n * \r\n * @packageDocumentation\r\n */\r\n\r\nimport type {\r\n BundlerAdapter,\r\n DevServer,\r\n BuildResult,\r\n PreviewServer,\r\n OutputFile,\r\n TransformOptions,\r\n TransformResult as BundlerTransformResult,\r\n} from '@flight-framework/bundler';\r\nimport {\r\n registerAdapter,\r\n setDefaultAdapter,\r\n createTimer,\r\n createBuildError,\r\n logDevServerStarted,\r\n logBuildSuccess,\r\n logBuildError,\r\n resolvePath,\r\n cleanDirectory,\r\n} from '@flight-framework/bundler';\r\nimport type { FlightConfig } from '@flight-framework/core/config';\r\nimport type {\r\n FlightPackAdapterOptions,\r\n} from './types.js';\r\n\r\n// Re-export types\r\nexport * from './types.js';\r\n\r\n// ============================================================================\r\n// Constants\r\n// ============================================================================\r\n\r\nconst ADAPTER_NAME = 'flight-flightpack';\r\nconst BUNDLER_NAME = 'flightpack';\r\n\r\n// ============================================================================\r\n// Native Binding Loader\r\n// ============================================================================\r\n\r\n/**\r\n * Native binding interface matching the NAPI exports\r\n */\r\ninterface NativeBinding {\r\n FlightPack: new (options?: FlightPackNativeOptions | undefined | null) => {\r\n build(): Promise<NativeBuildResult>;\r\n };\r\n build: (options: FlightPackNativeOptions) => Promise<NativeBuildResult>;\r\n transform: (code: string, filename: string, options?: NativeTransformOptions | undefined | null) => Promise<NativeTransformResult>;\r\n version: () => string;\r\n // Dev Server\r\n startDevServer: (options?: NativeDevServerOptions | undefined | null) => Promise<NativeDevServerResult>;\r\n stopDevServer: () => Promise<boolean>;\r\n isDevServerRunning: () => boolean;\r\n // HMR\r\n sendHmrUpdate: (modules: NativeHMRModuleUpdate[]) => boolean;\r\n sendHmrError: (message: string) => boolean;\r\n // File Watcher\r\n watchFiles: (options: NativeWatcherOptions, callback: (event: NativeWatchEvent) => void) => NativeWatchHandle;\r\n // CSS Processing\r\n transformCss: (code: string, filename: string, options?: NativeCssTransformOptions | undefined | null) => NativeCssTransformResult;\r\n minifyCss: (code: string, filename: string) => string;\r\n transformCssModule: (code: string, filename: string) => NativeCssModuleResult;\r\n\r\n // ============================================================================\r\n // Extended NAPI Exports (2026 Parity)\r\n // ============================================================================\r\n\r\n // SSG/ISR\r\n generateSsg: (options: NativeSSGOptions) => Promise<NativeSSGResult>;\r\n\r\n // Multi-Environment Builds\r\n buildMultiEnvironment: (baseOptions: FlightPackNativeOptions, environments: NativeEnvironmentsConfig) => Promise<NativeMultiEnvironmentResult>;\r\n\r\n // Externals Detection\r\n isNodeBuiltin: (moduleId: string) => boolean;\r\n getNodeBuiltins: () => string[];\r\n getNodeBuiltinsPrefixed: () => string[];\r\n isBareImport: (moduleId: string) => boolean;\r\n isEdgeCompatible: (moduleId: string) => boolean;\r\n getEdgeIncompatibleModules: () => string[];\r\n getPlatformConditions: (platform: string) => string[];\r\n}\r\n\r\n/**\r\n * Native CSS transform options\r\n */\r\ninterface NativeCssTransformOptions {\r\n minify?: boolean;\r\n cssModules?: boolean;\r\n cssModulesPattern?: string;\r\n dashedIdents?: boolean;\r\n sourcemap?: boolean;\r\n browserTargets?: {\r\n chrome?: number;\r\n firefox?: number;\r\n safari?: number;\r\n edge?: number;\r\n };\r\n}\r\n\r\n/**\r\n * Native CSS transform result\r\n */\r\ninterface NativeCssTransformResult {\r\n code: string;\r\n map?: string | null;\r\n exports: Array<{\r\n original: string;\r\n hashed: string;\r\n isReferenced: boolean;\r\n composes: string[];\r\n }>;\r\n success: boolean;\r\n}\r\n\r\n/**\r\n * Native CSS module result\r\n */\r\ninterface NativeCssModuleResult {\r\n code: string;\r\n classMap: Array<{\r\n original: string;\r\n hashed: string;\r\n }>;\r\n}\r\n\r\n/**\r\n * Platform type\r\n */\r\ntype NativePlatform = 'browser' | 'node' | 'edge' | 'neutral';\r\n\r\n/**\r\n * Extended NativeBinding interface with universal support\r\n */\r\ninterface NativeBindingExtended extends NativeBinding {\r\n // Externals Detection\r\n isNodeBuiltin: (moduleId: string) => boolean;\r\n getNodeBuiltins: () => string[];\r\n getNodeBuiltinsPrefixed: () => string[];\r\n isBareImport: (moduleId: string) => boolean;\r\n isEdgeCompatible: (moduleId: string) => boolean;\r\n getEdgeIncompatibleModules: () => string[];\r\n getPlatformConditions: (platform: string) => string[];\r\n}\r\n\r\n\r\n/**\r\n * Native dev server options\r\n */\r\ninterface NativeDevServerOptions {\r\n port?: number;\r\n publicDir?: string;\r\n outDir?: string;\r\n hmr?: boolean;\r\n root?: string;\r\n}\r\n\r\n/**\r\n * Native dev server result\r\n */\r\ninterface NativeDevServerResult {\r\n url: string;\r\n port: number;\r\n hmr: boolean;\r\n}\r\n\r\n/**\r\n * Native HMR module update\r\n */\r\ninterface NativeHMRModuleUpdate {\r\n id: string;\r\n path: string;\r\n code: string;\r\n deps?: string[] | null;\r\n accept: boolean;\r\n}\r\n\r\n/**\r\n * Native watcher options\r\n */\r\ninterface NativeWatcherOptions {\r\n paths: string[];\r\n extensions?: string[] | null;\r\n debounceMs?: number | null;\r\n}\r\n\r\n/**\r\n * Native watch event\r\n */\r\ninterface NativeWatchEvent {\r\n paths: string[];\r\n eventType: string;\r\n}\r\n\r\n/**\r\n * Native watch handle\r\n */\r\ninterface NativeWatchHandle {\r\n stop(): boolean;\r\n}\r\n\r\n/**\r\n * Native options matching Rust struct\r\n */\r\ninterface FlightPackNativeOptions {\r\n entry: string[];\r\n outDir: string;\r\n root?: string;\r\n minify?: boolean;\r\n sourcemap?: boolean;\r\n rsc?: boolean;\r\n\r\n // Extended options (2026 Parity)\r\n splitting?: boolean;\r\n treeshake?: boolean;\r\n platform?: string;\r\n external?: string[];\r\n noExternal?: string[];\r\n format?: string;\r\n target?: string;\r\n serverActions?: boolean;\r\n define?: Record<string, string>;\r\n conditions?: string[];\r\n nodeTarget?: string;\r\n}\r\n\r\n/**\r\n * Native SSG options\r\n */\r\ninterface NativeSSGPageConfig {\r\n path: string;\r\n params?: Record<string, string>[];\r\n fallback?: string;\r\n revalidate?: number;\r\n}\r\n\r\ninterface NativeSSGOptions {\r\n pages: NativeSSGPageConfig[];\r\n outDir?: string;\r\n ssrBundle?: string;\r\n defaultRevalidate?: number;\r\n concurrency?: number;\r\n trailingSlash?: boolean;\r\n}\r\n\r\ninterface NativeSSGGeneratedPage {\r\n path: string;\r\n filePath: string;\r\n revalidate?: number;\r\n size: number;\r\n}\r\n\r\ninterface NativeSSGResult {\r\n pages: NativeSSGGeneratedPage[];\r\n durationMs: number;\r\n totalSize: number;\r\n isrPages: string[];\r\n errors: string[];\r\n}\r\n\r\n/**\r\n * Native Multi-Environment types\r\n */\r\ninterface NativeEnvironmentOptions {\r\n platform?: string;\r\n nodeTarget?: string;\r\n conditions?: string[];\r\n external?: string[];\r\n noExternal?: string[];\r\n outDir?: string;\r\n entry?: string[];\r\n minify?: boolean;\r\n sourcemap?: boolean;\r\n}\r\n\r\ninterface NativeEnvironmentsConfig {\r\n client: NativeEnvironmentOptions;\r\n ssr?: NativeEnvironmentOptions;\r\n edge?: NativeEnvironmentOptions;\r\n}\r\n\r\ninterface NativeMultiEnvironmentResult {\r\n client: NativeBuildResult;\r\n ssr?: NativeBuildResult;\r\n edge?: NativeBuildResult;\r\n totalDurationMs: number;\r\n}\r\n\r\n/**\r\n * Native build result matching Rust struct\r\n */\r\ninterface NativeBuildResult {\r\n outputDir: string;\r\n durationMs: number;\r\n totalSize: number;\r\n chunks: NativeChunkInfo[];\r\n}\r\n\r\n/**\r\n * Native chunk info matching Rust struct\r\n */\r\ninterface NativeChunkInfo {\r\n fileName: string;\r\n chunkType: string;\r\n size: number;\r\n}\r\n\r\n/**\r\n * Native transform options matching Rust struct\r\n */\r\ninterface NativeTransformOptions {\r\n sourcemap?: boolean;\r\n minify?: boolean;\r\n target?: string;\r\n jsxFactory?: string;\r\n jsxFragment?: string;\r\n}\r\n\r\n/**\r\n * Native transform result matching Rust struct\r\n */\r\ninterface NativeTransformResult {\r\n code: string;\r\n map?: string | null;\r\n success: boolean;\r\n}\r\n\r\n/**\r\n * Lazy-loaded native FlightPack binding\r\n * This defers loading until actually needed, improving startup time\r\n */\r\nlet nativeBinding: NativeBinding | null = null;\r\n\r\nasync function loadNativeBinding(): Promise<NativeBinding> {\r\n if (nativeBinding) return nativeBinding;\r\n\r\n try {\r\n // Use createRequire for ESM compatibility with native modules\r\n // Native .node files require \"require()\" which isn't available in ESM\r\n const { createRequire } = await import('node:module');\r\n const require = createRequire(import.meta.url);\r\n const native = require('@flight-framework/flightpack') as NativeBinding;\r\n nativeBinding = native;\r\n return native;\r\n } catch (error) {\r\n throw new Error(\r\n `Failed to load FlightPack native binding. ` +\r\n `Make sure @flight-framework/flightpack is installed.\\n` +\r\n `Original error: ${error}`\r\n );\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Adapter Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * Create a FlightPack bundler adapter\r\n * \r\n * FlightPack is a native Rust bundler that provides:\r\n * - 1,874+ files/second processing speed\r\n * - Zero-config TypeScript/TSX support via Oxc\r\n * - React Server Components (RSC) support\r\n * - Tree shaking and code splitting\r\n * - Hot Module Replacement (HMR)\r\n * \r\n * @param options - FlightPack adapter options\r\n * @returns A BundlerAdapter instance\r\n * \r\n * @example\r\n * ```typescript\r\n * import { flightpack } from '@flight-framework/bundler-flightpack';\r\n * \r\n * const adapter = flightpack({\r\n * minify: true,\r\n * sourcemap: true,\r\n * rsc: true,\r\n * });\r\n * ```\r\n */\r\nexport function flightpack(options: FlightPackAdapterOptions = {}): BundlerAdapter {\r\n const adapter: BundlerAdapter = {\r\n name: ADAPTER_NAME,\r\n bundler: BUNDLER_NAME,\r\n options,\r\n\r\n async createDevServer(config: FlightConfig): Promise<DevServer> {\r\n const native = await loadNativeBinding();\r\n\r\n const port = config.dev.port ?? 5173;\r\n const host = config.dev.host ?? 'localhost';\r\n const https = config.dev.https === true;\r\n\r\n // Use native Rust dev server with Axum and WebSocket HMR\r\n const result = await native.startDevServer({\r\n port,\r\n publicDir: resolvePath(config.root, 'public'),\r\n outDir: resolvePath(config.root, config.build.outDir),\r\n hmr: options.hmr ?? true,\r\n root: config.root,\r\n });\r\n\r\n logDevServerStarted(result.url, 'FlightPack');\r\n\r\n // Set up file watcher for HMR updates\r\n let watchHandle: NativeWatchHandle | undefined;\r\n if (result.hmr) {\r\n try {\r\n watchHandle = native.watchFiles(\r\n {\r\n paths: [resolvePath(config.root, 'src')],\r\n extensions: ['ts', 'tsx', 'js', 'jsx', 'css'],\r\n debounceMs: 100,\r\n },\r\n async (event: NativeWatchEvent) => {\r\n // Transform changed files and send HMR updates\r\n const updates: NativeHMRModuleUpdate[] = [];\r\n\r\n for (const filePath of event.paths) {\r\n try {\r\n const { readFile } = await import('node:fs/promises');\r\n const source = await readFile(filePath, 'utf-8');\r\n const transformed = await native.transform(source, filePath);\r\n\r\n if (transformed.success) {\r\n updates.push({\r\n id: filePath,\r\n path: filePath,\r\n code: transformed.code,\r\n accept: true,\r\n deps: [],\r\n });\r\n }\r\n } catch (error) {\r\n native.sendHmrError(`Failed to transform ${filePath}: ${error}`);\r\n }\r\n }\r\n\r\n if (updates.length > 0) {\r\n native.sendHmrUpdate(updates);\r\n }\r\n }\r\n );\r\n } catch (error) {\r\n console.warn('[FlightPack] File watcher failed to start:', error);\r\n }\r\n }\r\n\r\n return {\r\n url: result.url,\r\n port: result.port,\r\n host: host as string,\r\n https,\r\n async close() {\r\n // Stop file watcher\r\n if (watchHandle) {\r\n watchHandle.stop();\r\n }\r\n // Stop native dev server\r\n await native.stopDevServer();\r\n },\r\n restart: undefined,\r\n reload: undefined,\r\n hmrUpdate: undefined,\r\n printUrls() {\r\n console.log(` ⚡ FlightPack Dev Server`);\r\n console.log(` ➜ Local: ${result.url}`);\r\n if (result.hmr) {\r\n console.log(` ➜ HMR: enabled (WebSocket)`);\r\n }\r\n },\r\n };\r\n },\r\n\r\n async build(config: FlightConfig): Promise<BuildResult> {\r\n const native = await loadNativeBinding();\r\n const timer = createTimer();\r\n\r\n try {\r\n // Build FlightPack options from config\r\n const minifyOption = typeof options.minify === 'boolean'\r\n ? options.minify\r\n : typeof config.build.minify === 'boolean'\r\n ? config.build.minify\r\n : true;\r\n\r\n // Determine platform\r\n const platform = options.platform ?? 'browser';\r\n\r\n // Auto-externalize Node.js builtins for Node platform\r\n let external = options.external || [];\r\n if (platform === 'node') {\r\n const builtins = native.getNodeBuiltins();\r\n external = [...new Set([...external, ...builtins])];\r\n }\r\n\r\n const flightpackOptions: FlightPackNativeOptions = {\r\n entry: await getEntryPoints(config),\r\n outDir: resolvePath(config.root, config.build.outDir),\r\n root: config.root,\r\n minify: minifyOption,\r\n sourcemap: typeof options.sourcemap === 'boolean'\r\n ? options.sourcemap\r\n : typeof config.build.sourcemap === 'boolean'\r\n ? config.build.sourcemap\r\n : true,\r\n rsc: options.rsc ?? true,\r\n // Extended options (2026 Parity)\r\n splitting: options.splitting ?? true,\r\n treeshake: options.treeshake ?? true,\r\n platform,\r\n external,\r\n noExternal: options.noExternal,\r\n format: options.format ?? 'esm',\r\n target: options.target ?? 'es2024',\r\n serverActions: options.serverActions ?? true,\r\n define: options.define,\r\n conditions: options.conditions,\r\n nodeTarget: options.nodeTarget,\r\n };\r\n\r\n // Run the native build\r\n const result = await native.build(flightpackOptions);\r\n\r\n // Convert to BundlerAdapter result format\r\n const files: OutputFile[] = result.chunks.map((chunk: NativeChunkInfo) => ({\r\n path: chunk.fileName,\r\n size: chunk.size,\r\n type: chunk.chunkType as 'entry' | 'chunk' | 'asset',\r\n isDynamicEntry: false,\r\n }));\r\n\r\n const buildResult: BuildResult = {\r\n outDir: result.outputDir,\r\n duration: timer.stop(),\r\n files,\r\n totalSize: result.totalSize,\r\n errors: [],\r\n warnings: [],\r\n success: true,\r\n };\r\n\r\n logBuildSuccess(buildResult);\r\n return buildResult;\r\n\r\n } catch (error) {\r\n const buildResult: BuildResult = {\r\n outDir: resolvePath(config.root, config.build.outDir),\r\n duration: timer.stop(),\r\n files: [],\r\n totalSize: 0,\r\n errors: [createBuildError(error)],\r\n warnings: [],\r\n success: false,\r\n };\r\n\r\n logBuildError(buildResult);\r\n return buildResult;\r\n }\r\n },\r\n\r\n async preview(config: FlightConfig): Promise<PreviewServer> {\r\n const { createServer } = await import('node:http');\r\n const { readFile, stat } = await import('node:fs/promises');\r\n const { join, extname } = await import('node:path');\r\n\r\n const outDir = resolvePath(config.root, config.build.outDir);\r\n const port = 4173;\r\n const host = 'localhost';\r\n const url = `http://${host}:${port}`;\r\n\r\n const mimeTypes: Record<string, string> = {\r\n '.html': 'text/html',\r\n '.js': 'text/javascript',\r\n '.css': 'text/css',\r\n '.json': 'application/json',\r\n };\r\n\r\n const server = createServer(async (req, res) => {\r\n let urlPath = req.url === '/' ? '/index.html' : req.url!;\r\n const filePath = join(outDir, urlPath);\r\n\r\n try {\r\n const content = await readFile(filePath);\r\n const ext = extname(filePath);\r\n res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');\r\n res.writeHead(200);\r\n res.end(content);\r\n } catch {\r\n // Try with .html extension\r\n try {\r\n const htmlPath = filePath.endsWith('.html') ? filePath : `${filePath}.html`;\r\n const content = await readFile(htmlPath);\r\n res.setHeader('Content-Type', 'text/html');\r\n res.writeHead(200);\r\n res.end(content);\r\n } catch {\r\n res.writeHead(404);\r\n res.end('Not Found');\r\n }\r\n }\r\n });\r\n\r\n server.listen(port, host);\r\n\r\n return {\r\n url,\r\n port,\r\n async close() {\r\n return new Promise((resolve) => {\r\n server.close(() => resolve());\r\n });\r\n },\r\n printUrls() {\r\n console.log(` ➜ Preview: ${url}`);\r\n },\r\n };\r\n },\r\n\r\n async clean(config: FlightConfig): Promise<void> {\r\n const outDir = resolvePath(config.root, config.build.outDir);\r\n await cleanDirectory(outDir);\r\n },\r\n\r\n async version(): Promise<string> {\r\n const native = await loadNativeBinding();\r\n return native.version();\r\n },\r\n\r\n async transform(\r\n code: string,\r\n id: string,\r\n transformOptions?: TransformOptions\r\n ): Promise<BundlerTransformResult> {\r\n const native = await loadNativeBinding();\r\n\r\n // Handle CSS files with native CSS processor\r\n if (id.endsWith('.css')) {\r\n const isCssModule = id.includes('.module.');\r\n\r\n if (isCssModule) {\r\n // CSS Modules: transform and generate class mappings\r\n const result = native.transformCssModule(code, id);\r\n\r\n // Generate JS export for CSS modules\r\n const classMapObject = Object.fromEntries(\r\n result.classMap.map(c => [c.original, c.hashed])\r\n );\r\n\r\n const jsCode = [\r\n `// CSS Module: ${id}`,\r\n `const styles = ${JSON.stringify(classMapObject)};`,\r\n `export default styles;`,\r\n ``,\r\n `// Inject CSS`,\r\n `if (typeof document !== 'undefined') {`,\r\n ` const style = document.createElement('style');`,\r\n ` style.textContent = ${JSON.stringify(result.code)};`,\r\n ` document.head.appendChild(style);`,\r\n `}`,\r\n ].join('\\n');\r\n\r\n return {\r\n code: jsCode,\r\n map: null,\r\n };\r\n } else {\r\n // Regular CSS: just minify and inject\r\n const minified = native.minifyCss(code, id);\r\n\r\n const jsCode = [\r\n `// CSS: ${id}`,\r\n `if (typeof document !== 'undefined') {`,\r\n ` const style = document.createElement('style');`,\r\n ` style.textContent = ${JSON.stringify(minified)};`,\r\n ` document.head.appendChild(style);`,\r\n `}`,\r\n ].join('\\n');\r\n\r\n return {\r\n code: jsCode,\r\n map: null,\r\n };\r\n }\r\n }\r\n\r\n // Handle TypeScript/JavaScript files\r\n const sourcemapOption = typeof transformOptions?.sourcemap === 'boolean'\r\n ? transformOptions.sourcemap\r\n : true;\r\n\r\n const result = await native.transform(code, id, {\r\n sourcemap: sourcemapOption,\r\n target: transformOptions?.target ?? 'es2022',\r\n });\r\n\r\n return {\r\n code: result.code,\r\n map: result.map,\r\n };\r\n },\r\n };\r\n\r\n // Auto-register as default if specified\r\n if (options.autoRegister !== false) {\r\n registerAdapter(adapter);\r\n\r\n // Set as default bundler\r\n setDefaultAdapter(ADAPTER_NAME);\r\n }\r\n\r\n return adapter;\r\n}\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Get entry points from Flight configuration\r\n */\r\nasync function getEntryPoints(config: FlightConfig): Promise<string[]> {\r\n const entries: string[] = [];\r\n const { existsSync } = await import('node:fs');\r\n const { join } = await import('node:path');\r\n\r\n // Look for common entry patterns in priority order\r\n const possibleEntries = [\r\n // Standard Flight entries\r\n 'src/entry-client.tsx',\r\n 'src/entry-client.ts',\r\n // Vite-style entries\r\n 'src/main.tsx',\r\n 'src/main.ts',\r\n // App-style entries\r\n 'src/App.tsx',\r\n 'src/App.ts',\r\n 'src/app.tsx',\r\n 'src/app.ts',\r\n // Index-style entries\r\n 'src/index.tsx',\r\n 'src/index.ts',\r\n ];\r\n\r\n // Find existing entries\r\n for (const entry of possibleEntries) {\r\n const fullPath = join(config.root, entry);\r\n if (existsSync(fullPath)) {\r\n entries.push(entry);\r\n break; // Only need one primary entry\r\n }\r\n }\r\n\r\n // Fallback if nothing found\r\n if (entries.length === 0) {\r\n entries.push('src/index.tsx');\r\n }\r\n\r\n return entries;\r\n}\r\n\r\n// ============================================================================\r\n// Exports\r\n// ============================================================================\r\n\r\nexport default flightpack;\r\nexport { flightpack as createFlightPackAdapter };\r\n\r\n/**\r\n * Package version\r\n */\r\nexport const VERSION = '0.0.1';\r\n\r\n// ============================================================================\r\n// Public Utilities (100% Parity)\r\n// ============================================================================\r\n\r\n/**\r\n * FlightPack utility functions for advanced usage\r\n * \r\n * @example\r\n * ```typescript\r\n * import { utils } from '@flight-framework/bundler-flightpack';\r\n * \r\n * utils.isNodeBuiltin('fs'); // true\r\n * utils.isEdgeCompatible('fs'); // false\r\n * utils.isBareImport('react'); // true\r\n * ```\r\n */\r\nexport const utils = {\r\n /**\r\n * Check if a module is a Node.js builtin\r\n * Handles both 'fs' and 'node:fs' formats\r\n */\r\n async isNodeBuiltin(moduleId: string): Promise<boolean> {\r\n const native = await loadNativeBinding();\r\n return native.isNodeBuiltin(moduleId);\r\n },\r\n\r\n /**\r\n * Get list of all Node.js builtin modules\r\n */\r\n async getNodeBuiltins(): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getNodeBuiltins();\r\n },\r\n\r\n /**\r\n * Get list of all Node.js builtins with node: prefix\r\n */\r\n async getNodeBuiltinsPrefixed(): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getNodeBuiltinsPrefixed();\r\n },\r\n\r\n /**\r\n * Check if a module is a bare import (from node_modules)\r\n * Returns false for relative/absolute paths\r\n */\r\n async isBareImport(moduleId: string): Promise<boolean> {\r\n const native = await loadNativeBinding();\r\n return native.isBareImport(moduleId);\r\n },\r\n\r\n /**\r\n * Check if a module is compatible with Edge runtimes\r\n * Returns false for modules like 'fs', 'child_process', etc.\r\n */\r\n async isEdgeCompatible(moduleId: string): Promise<boolean> {\r\n const native = await loadNativeBinding();\r\n return native.isEdgeCompatible(moduleId);\r\n },\r\n\r\n /**\r\n * Get list of Edge-incompatible modules\r\n */\r\n async getEdgeIncompatibleModules(): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getEdgeIncompatibleModules();\r\n },\r\n\r\n /**\r\n * Get default resolve conditions for a platform\r\n */\r\n async getPlatformConditions(platform: 'browser' | 'node' | 'edge' | 'neutral'): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getPlatformConditions(platform);\r\n },\r\n};\r\n\r\n// ============================================================================\r\n// SSG/ISR Public API\r\n// ============================================================================\r\n\r\nimport type { SSGOptions, SSGResult } from './types.js';\r\n\r\n/**\r\n * Generate static pages (SSG/ISR)\r\n * \r\n * Pre-renders pages at build time with optional Incremental Static Regeneration.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { generateSSG } from '@flight-framework/bundler-flightpack';\r\n * \r\n * const result = await generateSSG({\r\n * pages: [\r\n * { path: '/' },\r\n * { path: '/about' },\r\n * { path: '/blog/[slug]', params: [{ slug: 'hello' }, { slug: 'world' }] },\r\n * ],\r\n * outDir: './dist',\r\n * ssrBundle: './dist/server/entry-server.js',\r\n * });\r\n * ```\r\n */\r\nexport async function generateSSG(options: SSGOptions): Promise<SSGResult> {\r\n const native = await loadNativeBinding();\r\n\r\n const nativeOptions: NativeSSGOptions = {\r\n pages: options.pages.map(p => ({\r\n path: p.path,\r\n params: p.params,\r\n fallback: p.fallback,\r\n revalidate: p.revalidate,\r\n })),\r\n outDir: options.outDir,\r\n ssrBundle: options.ssrBundle,\r\n defaultRevalidate: options.defaultRevalidate,\r\n concurrency: options.concurrency,\r\n trailingSlash: options.trailingSlash,\r\n };\r\n\r\n const result = await native.generateSsg(nativeOptions);\r\n\r\n return {\r\n pages: result.pages.map(p => ({\r\n path: p.path,\r\n filePath: p.filePath,\r\n revalidate: p.revalidate,\r\n size: p.size,\r\n })),\r\n durationMs: result.durationMs,\r\n totalSize: result.totalSize,\r\n isrPages: result.isrPages,\r\n errors: result.errors,\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// Multi-Environment Build Public API\r\n// ============================================================================\r\n\r\nimport type { EnvironmentsConfig, MultiEnvironmentBuildResult } from './types.js';\r\n\r\n/**\r\n * Internal build result type (avoids conflict with types.ts)\r\n */\r\ninterface InternalBuildResult {\r\n outputDir: string;\r\n durationMs: number;\r\n totalSize: number;\r\n chunks: Array<{\r\n fileName: string;\r\n chunkType: 'entry' | 'chunk' | 'asset';\r\n size: number;\r\n }>;\r\n}\r\n\r\n/**\r\n * Build for multiple environments simultaneously\r\n * \r\n * Builds client, SSR, and edge bundles in parallel for maximum performance.\r\n * Follows Vite 7+ Environment API patterns.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { buildMultiEnvironment } from '@flight-framework/bundler-flightpack';\r\n * \r\n * const result = await buildMultiEnvironment({\r\n * entry: ['src/index.tsx'],\r\n * outDir: './dist',\r\n * }, {\r\n * client: { platform: 'browser', outDir: './dist/client' },\r\n * ssr: { platform: 'node', outDir: './dist/server', external: ['express'] },\r\n * edge: { platform: 'edge', outDir: './dist/edge' },\r\n * });\r\n * ```\r\n */\r\nexport async function buildMultiEnvironment(\r\n baseOptions: {\r\n entry: string[];\r\n outDir: string;\r\n root?: string;\r\n minify?: boolean;\r\n sourcemap?: boolean;\r\n rsc?: boolean;\r\n treeshake?: boolean;\r\n target?: string;\r\n define?: Record<string, string>;\r\n },\r\n environments: EnvironmentsConfig,\r\n): Promise<MultiEnvironmentBuildResult> {\r\n const native = await loadNativeBinding();\r\n\r\n const nativeBaseOptions: FlightPackNativeOptions = {\r\n entry: baseOptions.entry,\r\n outDir: baseOptions.outDir,\r\n root: baseOptions.root,\r\n minify: baseOptions.minify,\r\n sourcemap: baseOptions.sourcemap,\r\n rsc: baseOptions.rsc,\r\n treeshake: baseOptions.treeshake,\r\n target: baseOptions.target,\r\n define: baseOptions.define,\r\n };\r\n\r\n const nativeEnvironments: NativeEnvironmentsConfig = {\r\n client: {\r\n platform: environments.client.platform,\r\n nodeTarget: environments.client.nodeTarget,\r\n conditions: environments.client.conditions,\r\n external: environments.client.external,\r\n noExternal: environments.client.noExternal,\r\n outDir: environments.client.outDir,\r\n entry: environments.client.entry,\r\n minify: environments.client.minify,\r\n sourcemap: environments.client.sourcemap,\r\n },\r\n ssr: environments.ssr ? {\r\n platform: environments.ssr.platform,\r\n nodeTarget: environments.ssr.nodeTarget,\r\n conditions: environments.ssr.conditions,\r\n external: environments.ssr.external,\r\n noExternal: environments.ssr.noExternal,\r\n outDir: environments.ssr.outDir,\r\n entry: environments.ssr.entry,\r\n minify: environments.ssr.minify,\r\n sourcemap: environments.ssr.sourcemap,\r\n } : undefined,\r\n edge: environments.edge ? {\r\n platform: environments.edge.platform,\r\n nodeTarget: environments.edge.nodeTarget,\r\n conditions: environments.edge.conditions,\r\n external: environments.edge.external,\r\n noExternal: environments.edge.noExternal,\r\n outDir: environments.edge.outDir,\r\n entry: environments.edge.entry,\r\n minify: environments.edge.minify,\r\n sourcemap: environments.edge.sourcemap,\r\n } : undefined,\r\n };\r\n\r\n const result = await native.buildMultiEnvironment(nativeBaseOptions, nativeEnvironments);\r\n\r\n const mapBuildResult = (r: NativeBuildResult): InternalBuildResult => ({\r\n outputDir: r.outputDir,\r\n durationMs: r.durationMs,\r\n totalSize: r.totalSize,\r\n chunks: r.chunks.map(c => ({\r\n fileName: c.fileName,\r\n chunkType: c.chunkType as 'entry' | 'chunk' | 'asset',\r\n size: c.size,\r\n })),\r\n });\r\n\r\n return {\r\n client: mapBuildResult(result.client),\r\n ssr: result.ssr ? mapBuildResult(result.ssr) : undefined,\r\n edge: result.edge ? mapBuildResult(result.edge) : undefined,\r\n totalDurationMs: result.totalDurationMs,\r\n };\r\n}\r\n"],"mappings":";AA6BA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA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],"sourcesContent":["/**\r\n * @flight-framework/bundler-flightpack\r\n * \r\n * FlightPack native Rust bundler adapter for Flight Framework.\r\n * Wraps the native Rust bundler for maximum performance.\r\n * \r\n * @example\r\n * ```typescript\r\n * // In flight.config.ts\r\n * import { defineConfig } from '@flight-framework/core';\r\n * import { flightpack } from '@flight-framework/bundler-flightpack';\r\n * \r\n * export default defineConfig({\r\n * bundler: flightpack(),\r\n * });\r\n * ```\r\n * \r\n * @packageDocumentation\r\n */\r\n\r\nimport type {\r\n BundlerAdapter,\r\n DevServer,\r\n BuildResult,\r\n PreviewServer,\r\n OutputFile,\r\n TransformOptions,\r\n TransformResult as BundlerTransformResult,\r\n} from '@flight-framework/bundler';\r\nimport {\r\n registerAdapter,\r\n setDefaultAdapter,\r\n createTimer,\r\n createBuildError,\r\n logDevServerStarted,\r\n logBuildSuccess,\r\n logBuildError,\r\n resolvePath,\r\n cleanDirectory,\r\n} from '@flight-framework/bundler';\r\nimport type { FlightConfig } from '@flight-framework/core/config';\r\nimport type {\r\n FlightPackAdapterOptions,\r\n} from './types.js';\r\n\r\n// Re-export types\r\nexport * from './types.js';\r\n\r\n// ============================================================================\r\n// Constants\r\n// ============================================================================\r\n\r\nconst ADAPTER_NAME = 'flight-flightpack';\r\nconst BUNDLER_NAME = 'flightpack';\r\n\r\n// ============================================================================\r\n// Native Binding Loader\r\n// ============================================================================\r\n\r\n/**\r\n * Native binding interface matching the NAPI exports\r\n */\r\ninterface NativeBinding {\r\n FlightPack: new (options?: FlightPackNativeOptions | undefined | null) => {\r\n build(): Promise<NativeBuildResult>;\r\n };\r\n build: (options: FlightPackNativeOptions) => Promise<NativeBuildResult>;\r\n transform: (code: string, filename: string, options?: NativeTransformOptions | undefined | null) => Promise<NativeTransformResult>;\r\n version: () => string;\r\n // Dev Server\r\n startDevServer: (options?: NativeDevServerOptions | undefined | null) => Promise<NativeDevServerResult>;\r\n stopDevServer: () => Promise<boolean>;\r\n isDevServerRunning: () => boolean;\r\n // HMR\r\n sendHmrUpdate: (modules: NativeHMRModuleUpdate[]) => boolean;\r\n sendHmrError: (message: string) => boolean;\r\n // File Watcher\r\n watchFiles: (options: NativeWatcherOptions, callback: (event: NativeWatchEvent) => void) => NativeWatchHandle;\r\n // CSS Processing\r\n transformCss: (code: string, filename: string, options?: NativeCssTransformOptions | undefined | null) => NativeCssTransformResult;\r\n minifyCss: (code: string, filename: string) => string;\r\n transformCssModule: (code: string, filename: string) => NativeCssModuleResult;\r\n\r\n // ============================================================================\r\n // Extended NAPI Exports (2026 Parity)\r\n // ============================================================================\r\n\r\n // SSG/ISR\r\n generateSsg: (options: NativeSSGOptions) => Promise<NativeSSGResult>;\r\n\r\n // Multi-Environment Builds\r\n buildMultiEnvironment: (baseOptions: FlightPackNativeOptions, environments: NativeEnvironmentsConfig) => Promise<NativeMultiEnvironmentResult>;\r\n\r\n // Externals Detection\r\n isNodeBuiltin: (moduleId: string) => boolean;\r\n getNodeBuiltins: () => string[];\r\n getNodeBuiltinsPrefixed: () => string[];\r\n isBareImport: (moduleId: string) => boolean;\r\n isEdgeCompatible: (moduleId: string) => boolean;\r\n getEdgeIncompatibleModules: () => string[];\r\n getPlatformConditions: (platform: string) => string[];\r\n}\r\n\r\n/**\r\n * Native CSS transform options\r\n */\r\ninterface NativeCssTransformOptions {\r\n minify?: boolean;\r\n cssModules?: boolean;\r\n cssModulesPattern?: string;\r\n dashedIdents?: boolean;\r\n sourcemap?: boolean;\r\n browserTargets?: {\r\n chrome?: number;\r\n firefox?: number;\r\n safari?: number;\r\n edge?: number;\r\n };\r\n}\r\n\r\n/**\r\n * Native CSS transform result\r\n */\r\ninterface NativeCssTransformResult {\r\n code: string;\r\n map?: string | null;\r\n exports: Array<{\r\n original: string;\r\n hashed: string;\r\n isReferenced: boolean;\r\n composes: string[];\r\n }>;\r\n success: boolean;\r\n}\r\n\r\n/**\r\n * Native CSS module result\r\n */\r\ninterface NativeCssModuleResult {\r\n code: string;\r\n classMap: Array<{\r\n original: string;\r\n hashed: string;\r\n }>;\r\n}\r\n\r\n/**\r\n * Platform type\r\n */\r\ntype NativePlatform = 'browser' | 'node' | 'edge' | 'neutral';\r\n\r\n/**\r\n * Extended NativeBinding interface with universal support\r\n */\r\ninterface NativeBindingExtended extends NativeBinding {\r\n // Externals Detection\r\n isNodeBuiltin: (moduleId: string) => boolean;\r\n getNodeBuiltins: () => string[];\r\n getNodeBuiltinsPrefixed: () => string[];\r\n isBareImport: (moduleId: string) => boolean;\r\n isEdgeCompatible: (moduleId: string) => boolean;\r\n getEdgeIncompatibleModules: () => string[];\r\n getPlatformConditions: (platform: string) => string[];\r\n}\r\n\r\n\r\n/**\r\n * Native dev server options\r\n */\r\ninterface NativeDevServerOptions {\r\n port?: number;\r\n publicDir?: string;\r\n outDir?: string;\r\n hmr?: boolean;\r\n root?: string;\r\n}\r\n\r\n/**\r\n * Native dev server result\r\n */\r\ninterface NativeDevServerResult {\r\n url: string;\r\n port: number;\r\n hmr: boolean;\r\n}\r\n\r\n/**\r\n * Native HMR module update\r\n */\r\ninterface NativeHMRModuleUpdate {\r\n id: string;\r\n path: string;\r\n code: string;\r\n deps?: string[] | null;\r\n accept: boolean;\r\n}\r\n\r\n/**\r\n * Native watcher options\r\n */\r\ninterface NativeWatcherOptions {\r\n paths: string[];\r\n extensions?: string[] | null;\r\n debounceMs?: number | null;\r\n}\r\n\r\n/**\r\n * Native watch event\r\n */\r\ninterface NativeWatchEvent {\r\n paths: string[];\r\n eventType: string;\r\n}\r\n\r\n/**\r\n * Native watch handle\r\n */\r\ninterface NativeWatchHandle {\r\n stop(): boolean;\r\n}\r\n\r\n/**\r\n * Native options matching Rust struct\r\n */\r\ninterface FlightPackNativeOptions {\r\n entry: string[];\r\n outDir: string;\r\n root?: string;\r\n minify?: boolean;\r\n sourcemap?: boolean;\r\n rsc?: boolean;\r\n\r\n // Extended options (2026 Parity)\r\n splitting?: boolean;\r\n treeshake?: boolean;\r\n platform?: string;\r\n external?: string[];\r\n noExternal?: string[];\r\n format?: string;\r\n target?: string;\r\n serverActions?: boolean;\r\n define?: Record<string, string>;\r\n conditions?: string[];\r\n nodeTarget?: string;\r\n}\r\n\r\n/**\r\n * Native SSG options\r\n */\r\ninterface NativeSSGPageConfig {\r\n path: string;\r\n params?: Record<string, string>[];\r\n fallback?: string;\r\n revalidate?: number;\r\n}\r\n\r\ninterface NativeSSGOptions {\r\n pages: NativeSSGPageConfig[];\r\n outDir?: string;\r\n ssrBundle?: string;\r\n defaultRevalidate?: number;\r\n concurrency?: number;\r\n trailingSlash?: boolean;\r\n}\r\n\r\ninterface NativeSSGGeneratedPage {\r\n path: string;\r\n filePath: string;\r\n revalidate?: number;\r\n size: number;\r\n}\r\n\r\ninterface NativeSSGResult {\r\n pages: NativeSSGGeneratedPage[];\r\n durationMs: number;\r\n totalSize: number;\r\n isrPages: string[];\r\n errors: string[];\r\n}\r\n\r\n/**\r\n * Native Multi-Environment types\r\n */\r\ninterface NativeEnvironmentOptions {\r\n platform?: string;\r\n nodeTarget?: string;\r\n conditions?: string[];\r\n external?: string[];\r\n noExternal?: string[];\r\n outDir?: string;\r\n entry?: string[];\r\n minify?: boolean;\r\n sourcemap?: boolean;\r\n}\r\n\r\ninterface NativeEnvironmentsConfig {\r\n client: NativeEnvironmentOptions;\r\n ssr?: NativeEnvironmentOptions;\r\n edge?: NativeEnvironmentOptions;\r\n}\r\n\r\ninterface NativeMultiEnvironmentResult {\r\n client: NativeBuildResult;\r\n ssr?: NativeBuildResult;\r\n edge?: NativeBuildResult;\r\n totalDurationMs: number;\r\n}\r\n\r\n/**\r\n * Native build result matching Rust struct\r\n */\r\ninterface NativeBuildResult {\r\n outputDir: string;\r\n durationMs: number;\r\n totalSize: number;\r\n chunks: NativeChunkInfo[];\r\n}\r\n\r\n/**\r\n * Native chunk info matching Rust struct\r\n */\r\ninterface NativeChunkInfo {\r\n fileName: string;\r\n chunkType: string;\r\n size: number;\r\n}\r\n\r\n/**\r\n * Native transform options matching Rust struct\r\n */\r\ninterface NativeTransformOptions {\r\n sourcemap?: boolean;\r\n minify?: boolean;\r\n target?: string;\r\n jsxFactory?: string;\r\n jsxFragment?: string;\r\n}\r\n\r\n/**\r\n * Native transform result matching Rust struct\r\n */\r\ninterface NativeTransformResult {\r\n code: string;\r\n map?: string | null;\r\n success: boolean;\r\n}\r\n\r\n/**\r\n * Lazy-loaded native FlightPack binding\r\n * This defers loading until actually needed, improving startup time\r\n */\r\nlet nativeBinding: NativeBinding | null = null;\r\n\r\nasync function loadNativeBinding(): Promise<NativeBinding> {\r\n if (nativeBinding) return nativeBinding;\r\n\r\n try {\r\n // Use createRequire for ESM compatibility with native modules\r\n // Native .node files require \"require()\" which isn't available in ESM\r\n const { createRequire } = await import('node:module');\r\n const require = createRequire(import.meta.url);\r\n const native = require('@flight-framework/flightpack') as NativeBinding;\r\n nativeBinding = native;\r\n return native;\r\n } catch (error) {\r\n throw new Error(\r\n `Failed to load FlightPack native binding. ` +\r\n `Make sure @flight-framework/flightpack is installed.\\n` +\r\n `Original error: ${error}`\r\n );\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Adapter Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * Create a FlightPack bundler adapter\r\n * \r\n * FlightPack is a native Rust bundler that provides:\r\n * - 1,874+ files/second processing speed\r\n * - Zero-config TypeScript/TSX support via Oxc\r\n * - React Server Components (RSC) support\r\n * - Tree shaking and code splitting\r\n * - Hot Module Replacement (HMR)\r\n * \r\n * @param options - FlightPack adapter options\r\n * @returns A BundlerAdapter instance\r\n * \r\n * @example\r\n * ```typescript\r\n * import { flightpack } from '@flight-framework/bundler-flightpack';\r\n * \r\n * const adapter = flightpack({\r\n * minify: true,\r\n * sourcemap: true,\r\n * rsc: true,\r\n * });\r\n * ```\r\n */\r\nexport function flightpack(options: FlightPackAdapterOptions = {}): BundlerAdapter {\r\n const adapter: BundlerAdapter = {\r\n name: ADAPTER_NAME,\r\n bundler: BUNDLER_NAME,\r\n options,\r\n\r\n async createDevServer(config: FlightConfig): Promise<DevServer> {\r\n const native = await loadNativeBinding();\r\n\r\n // Internal port for transform API (CLI will proxy to this)\r\n const internalPort = (config.dev.port ?? 5173) + 1000;\r\n const host = config.dev.host ?? 'localhost';\r\n const https = config.dev.https === true;\r\n\r\n // Use native Rust dev server with Axum and WebSocket HMR\r\n const result = await native.startDevServer({\r\n port: internalPort,\r\n publicDir: resolvePath(config.root, 'public'),\r\n outDir: resolvePath(config.root, config.build.outDir),\r\n hmr: options.hmr ?? true,\r\n root: config.root,\r\n });\r\n\r\n logDevServerStarted(result.url, 'FlightPack');\r\n\r\n // Set up file watcher for HMR updates\r\n let watchHandle: NativeWatchHandle | undefined;\r\n if (result.hmr) {\r\n try {\r\n watchHandle = native.watchFiles(\r\n {\r\n paths: [resolvePath(config.root, 'src')],\r\n extensions: ['ts', 'tsx', 'js', 'jsx', 'css'],\r\n debounceMs: 100,\r\n },\r\n async (event: NativeWatchEvent) => {\r\n // Transform changed files and send HMR updates\r\n const updates: NativeHMRModuleUpdate[] = [];\r\n\r\n for (const filePath of event.paths) {\r\n try {\r\n const { readFile } = await import('node:fs/promises');\r\n const source = await readFile(filePath, 'utf-8');\r\n const transformed = await native.transform(source, filePath);\r\n\r\n if (transformed.success) {\r\n updates.push({\r\n id: filePath,\r\n path: filePath,\r\n code: transformed.code,\r\n accept: true,\r\n deps: [],\r\n });\r\n }\r\n } catch (error) {\r\n native.sendHmrError(`Failed to transform ${filePath}: ${error}`);\r\n }\r\n }\r\n\r\n if (updates.length > 0) {\r\n native.sendHmrUpdate(updates);\r\n }\r\n }\r\n );\r\n } catch (error) {\r\n console.warn('[FlightPack] File watcher failed to start:', error);\r\n }\r\n }\r\n\r\n return {\r\n url: result.url,\r\n port: result.port,\r\n host: host as string,\r\n https,\r\n async close() {\r\n // Stop file watcher\r\n if (watchHandle) {\r\n watchHandle.stop();\r\n }\r\n // Stop native dev server\r\n await native.stopDevServer();\r\n },\r\n restart: undefined,\r\n reload: undefined,\r\n hmrUpdate: undefined,\r\n printUrls() {\r\n console.log(` ⚡ FlightPack Dev Server`);\r\n console.log(` ➜ Local: ${result.url}`);\r\n if (result.hmr) {\r\n console.log(` ➜ HMR: enabled (WebSocket)`);\r\n }\r\n },\r\n };\r\n },\r\n\r\n async build(config: FlightConfig): Promise<BuildResult> {\r\n const native = await loadNativeBinding();\r\n const timer = createTimer();\r\n\r\n try {\r\n // Build FlightPack options from config\r\n const minifyOption = typeof options.minify === 'boolean'\r\n ? options.minify\r\n : typeof config.build.minify === 'boolean'\r\n ? config.build.minify\r\n : true;\r\n\r\n // Determine platform\r\n const platform = options.platform ?? 'browser';\r\n\r\n // Auto-externalize Node.js builtins for Node platform\r\n let external = options.external || [];\r\n if (platform === 'node') {\r\n const builtins = native.getNodeBuiltins();\r\n external = [...new Set([...external, ...builtins])];\r\n }\r\n\r\n const flightpackOptions: FlightPackNativeOptions = {\r\n entry: await getEntryPoints(config),\r\n outDir: resolvePath(config.root, config.build.outDir),\r\n root: config.root,\r\n minify: minifyOption,\r\n sourcemap: typeof options.sourcemap === 'boolean'\r\n ? options.sourcemap\r\n : typeof config.build.sourcemap === 'boolean'\r\n ? config.build.sourcemap\r\n : true,\r\n rsc: options.rsc ?? true,\r\n // Extended options (2026 Parity)\r\n splitting: options.splitting ?? true,\r\n treeshake: options.treeshake ?? true,\r\n platform,\r\n external,\r\n noExternal: options.noExternal,\r\n format: options.format ?? 'esm',\r\n target: options.target ?? 'es2024',\r\n serverActions: options.serverActions ?? true,\r\n define: options.define,\r\n conditions: options.conditions,\r\n nodeTarget: options.nodeTarget,\r\n };\r\n\r\n // Run the native build\r\n const result = await native.build(flightpackOptions);\r\n\r\n // Convert to BundlerAdapter result format\r\n const files: OutputFile[] = result.chunks.map((chunk: NativeChunkInfo) => ({\r\n path: chunk.fileName,\r\n size: chunk.size,\r\n type: chunk.chunkType as 'entry' | 'chunk' | 'asset',\r\n isDynamicEntry: false,\r\n }));\r\n\r\n const buildResult: BuildResult = {\r\n outDir: result.outputDir,\r\n duration: timer.stop(),\r\n files,\r\n totalSize: result.totalSize,\r\n errors: [],\r\n warnings: [],\r\n success: true,\r\n };\r\n\r\n logBuildSuccess(buildResult);\r\n return buildResult;\r\n\r\n } catch (error) {\r\n const buildResult: BuildResult = {\r\n outDir: resolvePath(config.root, config.build.outDir),\r\n duration: timer.stop(),\r\n files: [],\r\n totalSize: 0,\r\n errors: [createBuildError(error)],\r\n warnings: [],\r\n success: false,\r\n };\r\n\r\n logBuildError(buildResult);\r\n return buildResult;\r\n }\r\n },\r\n\r\n async preview(config: FlightConfig): Promise<PreviewServer> {\r\n const { createServer } = await import('node:http');\r\n const { readFile, stat } = await import('node:fs/promises');\r\n const { join, extname } = await import('node:path');\r\n\r\n const outDir = resolvePath(config.root, config.build.outDir);\r\n const port = 4173;\r\n const host = 'localhost';\r\n const url = `http://${host}:${port}`;\r\n\r\n const mimeTypes: Record<string, string> = {\r\n '.html': 'text/html',\r\n '.js': 'text/javascript',\r\n '.css': 'text/css',\r\n '.json': 'application/json',\r\n };\r\n\r\n const server = createServer(async (req, res) => {\r\n let urlPath = req.url === '/' ? '/index.html' : req.url!;\r\n const filePath = join(outDir, urlPath);\r\n\r\n try {\r\n const content = await readFile(filePath);\r\n const ext = extname(filePath);\r\n res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');\r\n res.writeHead(200);\r\n res.end(content);\r\n } catch {\r\n // Try with .html extension\r\n try {\r\n const htmlPath = filePath.endsWith('.html') ? filePath : `${filePath}.html`;\r\n const content = await readFile(htmlPath);\r\n res.setHeader('Content-Type', 'text/html');\r\n res.writeHead(200);\r\n res.end(content);\r\n } catch {\r\n res.writeHead(404);\r\n res.end('Not Found');\r\n }\r\n }\r\n });\r\n\r\n server.listen(port, host);\r\n\r\n return {\r\n url,\r\n port,\r\n async close() {\r\n return new Promise((resolve) => {\r\n server.close(() => resolve());\r\n });\r\n },\r\n printUrls() {\r\n console.log(` ➜ Preview: ${url}`);\r\n },\r\n };\r\n },\r\n\r\n async clean(config: FlightConfig): Promise<void> {\r\n const outDir = resolvePath(config.root, config.build.outDir);\r\n await cleanDirectory(outDir);\r\n },\r\n\r\n async version(): Promise<string> {\r\n const native = await loadNativeBinding();\r\n return native.version();\r\n },\r\n\r\n async transform(\r\n code: string,\r\n id: string,\r\n transformOptions?: TransformOptions\r\n ): Promise<BundlerTransformResult> {\r\n const native = await loadNativeBinding();\r\n\r\n // Handle CSS files with native CSS processor\r\n if (id.endsWith('.css')) {\r\n const isCssModule = id.includes('.module.');\r\n\r\n if (isCssModule) {\r\n // CSS Modules: transform and generate class mappings\r\n const result = native.transformCssModule(code, id);\r\n\r\n // Generate JS export for CSS modules\r\n const classMapObject = Object.fromEntries(\r\n result.classMap.map(c => [c.original, c.hashed])\r\n );\r\n\r\n const jsCode = [\r\n `// CSS Module: ${id}`,\r\n `const styles = ${JSON.stringify(classMapObject)};`,\r\n `export default styles;`,\r\n ``,\r\n `// Inject CSS`,\r\n `if (typeof document !== 'undefined') {`,\r\n ` const style = document.createElement('style');`,\r\n ` style.textContent = ${JSON.stringify(result.code)};`,\r\n ` document.head.appendChild(style);`,\r\n `}`,\r\n ].join('\\n');\r\n\r\n return {\r\n code: jsCode,\r\n map: null,\r\n };\r\n } else {\r\n // Regular CSS: just minify and inject\r\n const minified = native.minifyCss(code, id);\r\n\r\n const jsCode = [\r\n `// CSS: ${id}`,\r\n `if (typeof document !== 'undefined') {`,\r\n ` const style = document.createElement('style');`,\r\n ` style.textContent = ${JSON.stringify(minified)};`,\r\n ` document.head.appendChild(style);`,\r\n `}`,\r\n ].join('\\n');\r\n\r\n return {\r\n code: jsCode,\r\n map: null,\r\n };\r\n }\r\n }\r\n\r\n // Handle TypeScript/JavaScript files\r\n const sourcemapOption = typeof transformOptions?.sourcemap === 'boolean'\r\n ? transformOptions.sourcemap\r\n : true;\r\n\r\n const result = await native.transform(code, id, {\r\n sourcemap: sourcemapOption,\r\n target: transformOptions?.target ?? 'es2022',\r\n });\r\n\r\n return {\r\n code: result.code,\r\n map: result.map,\r\n };\r\n },\r\n };\r\n\r\n // Auto-register as default if specified\r\n if (options.autoRegister !== false) {\r\n registerAdapter(adapter);\r\n\r\n // Set as default bundler\r\n setDefaultAdapter(ADAPTER_NAME);\r\n }\r\n\r\n return adapter;\r\n}\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Get entry points from Flight configuration\r\n */\r\nasync function getEntryPoints(config: FlightConfig): Promise<string[]> {\r\n const entries: string[] = [];\r\n const { existsSync } = await import('node:fs');\r\n const { join } = await import('node:path');\r\n\r\n // Look for common entry patterns in priority order\r\n const possibleEntries = [\r\n // Standard Flight entries\r\n 'src/entry-client.tsx',\r\n 'src/entry-client.ts',\r\n // Vite-style entries\r\n 'src/main.tsx',\r\n 'src/main.ts',\r\n // App-style entries\r\n 'src/App.tsx',\r\n 'src/App.ts',\r\n 'src/app.tsx',\r\n 'src/app.ts',\r\n // Index-style entries\r\n 'src/index.tsx',\r\n 'src/index.ts',\r\n ];\r\n\r\n // Find existing entries\r\n for (const entry of possibleEntries) {\r\n const fullPath = join(config.root, entry);\r\n if (existsSync(fullPath)) {\r\n entries.push(entry);\r\n break; // Only need one primary entry\r\n }\r\n }\r\n\r\n // Fallback if nothing found\r\n if (entries.length === 0) {\r\n entries.push('src/index.tsx');\r\n }\r\n\r\n return entries;\r\n}\r\n\r\n// ============================================================================\r\n// Exports\r\n// ============================================================================\r\n\r\nexport default flightpack;\r\nexport { flightpack as createFlightPackAdapter };\r\n\r\n/**\r\n * Package version\r\n */\r\nexport const VERSION = '0.0.1';\r\n\r\n// ============================================================================\r\n// Public Utilities (100% Parity)\r\n// ============================================================================\r\n\r\n/**\r\n * FlightPack utility functions for advanced usage\r\n * \r\n * @example\r\n * ```typescript\r\n * import { utils } from '@flight-framework/bundler-flightpack';\r\n * \r\n * utils.isNodeBuiltin('fs'); // true\r\n * utils.isEdgeCompatible('fs'); // false\r\n * utils.isBareImport('react'); // true\r\n * ```\r\n */\r\nexport const utils = {\r\n /**\r\n * Check if a module is a Node.js builtin\r\n * Handles both 'fs' and 'node:fs' formats\r\n */\r\n async isNodeBuiltin(moduleId: string): Promise<boolean> {\r\n const native = await loadNativeBinding();\r\n return native.isNodeBuiltin(moduleId);\r\n },\r\n\r\n /**\r\n * Get list of all Node.js builtin modules\r\n */\r\n async getNodeBuiltins(): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getNodeBuiltins();\r\n },\r\n\r\n /**\r\n * Get list of all Node.js builtins with node: prefix\r\n */\r\n async getNodeBuiltinsPrefixed(): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getNodeBuiltinsPrefixed();\r\n },\r\n\r\n /**\r\n * Check if a module is a bare import (from node_modules)\r\n * Returns false for relative/absolute paths\r\n */\r\n async isBareImport(moduleId: string): Promise<boolean> {\r\n const native = await loadNativeBinding();\r\n return native.isBareImport(moduleId);\r\n },\r\n\r\n /**\r\n * Check if a module is compatible with Edge runtimes\r\n * Returns false for modules like 'fs', 'child_process', etc.\r\n */\r\n async isEdgeCompatible(moduleId: string): Promise<boolean> {\r\n const native = await loadNativeBinding();\r\n return native.isEdgeCompatible(moduleId);\r\n },\r\n\r\n /**\r\n * Get list of Edge-incompatible modules\r\n */\r\n async getEdgeIncompatibleModules(): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getEdgeIncompatibleModules();\r\n },\r\n\r\n /**\r\n * Get default resolve conditions for a platform\r\n */\r\n async getPlatformConditions(platform: 'browser' | 'node' | 'edge' | 'neutral'): Promise<string[]> {\r\n const native = await loadNativeBinding();\r\n return native.getPlatformConditions(platform);\r\n },\r\n};\r\n\r\n// ============================================================================\r\n// SSG/ISR Public API\r\n// ============================================================================\r\n\r\nimport type { SSGOptions, SSGResult } from './types.js';\r\n\r\n/**\r\n * Generate static pages (SSG/ISR)\r\n * \r\n * Pre-renders pages at build time with optional Incremental Static Regeneration.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { generateSSG } from '@flight-framework/bundler-flightpack';\r\n * \r\n * const result = await generateSSG({\r\n * pages: [\r\n * { path: '/' },\r\n * { path: '/about' },\r\n * { path: '/blog/[slug]', params: [{ slug: 'hello' }, { slug: 'world' }] },\r\n * ],\r\n * outDir: './dist',\r\n * ssrBundle: './dist/server/entry-server.js',\r\n * });\r\n * ```\r\n */\r\nexport async function generateSSG(options: SSGOptions): Promise<SSGResult> {\r\n const native = await loadNativeBinding();\r\n\r\n const nativeOptions: NativeSSGOptions = {\r\n pages: options.pages.map(p => ({\r\n path: p.path,\r\n params: p.params,\r\n fallback: p.fallback,\r\n revalidate: p.revalidate,\r\n })),\r\n outDir: options.outDir,\r\n ssrBundle: options.ssrBundle,\r\n defaultRevalidate: options.defaultRevalidate,\r\n concurrency: options.concurrency,\r\n trailingSlash: options.trailingSlash,\r\n };\r\n\r\n const result = await native.generateSsg(nativeOptions);\r\n\r\n return {\r\n pages: result.pages.map(p => ({\r\n path: p.path,\r\n filePath: p.filePath,\r\n revalidate: p.revalidate,\r\n size: p.size,\r\n })),\r\n durationMs: result.durationMs,\r\n totalSize: result.totalSize,\r\n isrPages: result.isrPages,\r\n errors: result.errors,\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// Multi-Environment Build Public API\r\n// ============================================================================\r\n\r\nimport type { EnvironmentsConfig, MultiEnvironmentBuildResult } from './types.js';\r\n\r\n/**\r\n * Internal build result type (avoids conflict with types.ts)\r\n */\r\ninterface InternalBuildResult {\r\n outputDir: string;\r\n durationMs: number;\r\n totalSize: number;\r\n chunks: Array<{\r\n fileName: string;\r\n chunkType: 'entry' | 'chunk' | 'asset';\r\n size: number;\r\n }>;\r\n}\r\n\r\n/**\r\n * Build for multiple environments simultaneously\r\n * \r\n * Builds client, SSR, and edge bundles in parallel for maximum performance.\r\n * Follows Vite 7+ Environment API patterns.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { buildMultiEnvironment } from '@flight-framework/bundler-flightpack';\r\n * \r\n * const result = await buildMultiEnvironment({\r\n * entry: ['src/index.tsx'],\r\n * outDir: './dist',\r\n * }, {\r\n * client: { platform: 'browser', outDir: './dist/client' },\r\n * ssr: { platform: 'node', outDir: './dist/server', external: ['express'] },\r\n * edge: { platform: 'edge', outDir: './dist/edge' },\r\n * });\r\n * ```\r\n */\r\nexport async function buildMultiEnvironment(\r\n baseOptions: {\r\n entry: string[];\r\n outDir: string;\r\n root?: string;\r\n minify?: boolean;\r\n sourcemap?: boolean;\r\n rsc?: boolean;\r\n treeshake?: boolean;\r\n target?: string;\r\n define?: Record<string, string>;\r\n },\r\n environments: EnvironmentsConfig,\r\n): Promise<MultiEnvironmentBuildResult> {\r\n const native = await loadNativeBinding();\r\n\r\n const nativeBaseOptions: FlightPackNativeOptions = {\r\n entry: baseOptions.entry,\r\n outDir: baseOptions.outDir,\r\n root: baseOptions.root,\r\n minify: baseOptions.minify,\r\n sourcemap: baseOptions.sourcemap,\r\n rsc: baseOptions.rsc,\r\n treeshake: baseOptions.treeshake,\r\n target: baseOptions.target,\r\n define: baseOptions.define,\r\n };\r\n\r\n const nativeEnvironments: NativeEnvironmentsConfig = {\r\n client: {\r\n platform: environments.client.platform,\r\n nodeTarget: environments.client.nodeTarget,\r\n conditions: environments.client.conditions,\r\n external: environments.client.external,\r\n noExternal: environments.client.noExternal,\r\n outDir: environments.client.outDir,\r\n entry: environments.client.entry,\r\n minify: environments.client.minify,\r\n sourcemap: environments.client.sourcemap,\r\n },\r\n ssr: environments.ssr ? {\r\n platform: environments.ssr.platform,\r\n nodeTarget: environments.ssr.nodeTarget,\r\n conditions: environments.ssr.conditions,\r\n external: environments.ssr.external,\r\n noExternal: environments.ssr.noExternal,\r\n outDir: environments.ssr.outDir,\r\n entry: environments.ssr.entry,\r\n minify: environments.ssr.minify,\r\n sourcemap: environments.ssr.sourcemap,\r\n } : undefined,\r\n edge: environments.edge ? {\r\n platform: environments.edge.platform,\r\n nodeTarget: environments.edge.nodeTarget,\r\n conditions: environments.edge.conditions,\r\n external: environments.edge.external,\r\n noExternal: environments.edge.noExternal,\r\n outDir: environments.edge.outDir,\r\n entry: environments.edge.entry,\r\n minify: environments.edge.minify,\r\n sourcemap: environments.edge.sourcemap,\r\n } : undefined,\r\n };\r\n\r\n const result = await native.buildMultiEnvironment(nativeBaseOptions, nativeEnvironments);\r\n\r\n const mapBuildResult = (r: NativeBuildResult): InternalBuildResult => ({\r\n outputDir: r.outputDir,\r\n durationMs: r.durationMs,\r\n totalSize: r.totalSize,\r\n chunks: r.chunks.map(c => ({\r\n fileName: c.fileName,\r\n chunkType: c.chunkType as 'entry' | 'chunk' | 'asset',\r\n size: c.size,\r\n })),\r\n });\r\n\r\n return {\r\n client: mapBuildResult(result.client),\r\n ssr: result.ssr ? mapBuildResult(result.ssr) : undefined,\r\n edge: result.edge ? mapBuildResult(result.edge) : undefined,\r\n totalDurationMs: result.totalDurationMs,\r\n };\r\n}\r\n"],"mappings":";AA6BA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAaP,IAAM,eAAe;AACrB,IAAM,eAAe;AA0SrB,IAAI,gBAAsC;AAE1C,eAAe,oBAA4C;AACvD,MAAI,cAAe,QAAO;AAE1B,MAAI;AAGA,UAAM,EAAE,cAAc,IAAI,MAAM,OAAO,QAAa;AACpD,UAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,UAAM,SAASA,SAAQ,8BAA8B;AACrD,oBAAgB;AAChB,WAAO;AAAA,EACX,SAAS,OAAO;AACZ,UAAM,IAAI;AAAA,MACN;AAAA,kBAEmB,KAAK;AAAA,IAC5B;AAAA,EACJ;AACJ;AA8BO,SAAS,WAAW,UAAoC,CAAC,GAAmB;AAC/E,QAAM,UAA0B;AAAA,IAC5B,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IAEA,MAAM,gBAAgB,QAA0C;AAC5D,YAAM,SAAS,MAAM,kBAAkB;AAGvC,YAAM,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