@flight-framework/bundler-flightpack 0.1.7 → 0.1.9
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 +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.ts +0 -479
package/dist/index.js
CHANGED
|
@@ -35,11 +35,13 @@ 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
|
+
console.log("[Bundler] JS Root:", config.root);
|
|
41
|
+
console.log("[Bundler] Resolved Public Dir:", resolvePath(config.root, "public"));
|
|
42
|
+
console.log("[Bundler] Internal Port:", internalPort);
|
|
41
43
|
const result = await native.startDevServer({
|
|
42
|
-
port,
|
|
44
|
+
port: internalPort,
|
|
43
45
|
publicDir: resolvePath(config.root, "public"),
|
|
44
46
|
outDir: resolvePath(config.root, config.build.outDir),
|
|
45
47
|
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,\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C,MAAM,OAAO,OAAO,eAAe,OAAO,IAAI,IAAI;AAAA,IAClD,iBAAiB,OAAO;AAAA,EAC5B;AACJ;","names":["require","result"]}
|
|
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 // 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\r\n console.log('[Bundler] JS Root:', config.root);\r\n console.log('[Bundler] Resolved Public Dir:', resolvePath(config.root, 'public'));\r\n console.log('[Bundler] Internal Port:', internalPort);\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,k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,aAAa,IAAI;AAAA,MACzB,WAAW,aAAa,IAAI;AAAA,IAChC,IAAI;AAAA,IACJ,MAAM,aAAa,OAAO;AAAA,MACtB,UAAU,aAAa,KAAK;AAAA,MAC5B,YAAY,aAAa,KAAK;AAAA,MAC9B,YAAY,aAAa,KAAK;AAAA,MAC9B,UAAU,aAAa,KAAK;AAAA,MAC5B,YAAY,aAAa,KAAK;AAAA,MAC9B,QAAQ,aAAa,KAAK;AAAA,MAC1B,OAAO,aAAa,KAAK;AAAA,MACzB,QAAQ,aAAa,KAAK;AAAA,MAC1B,WAAW,aAAa,KAAK;AAAA,IACjC,IAAI;AAAA,EACR;AAEA,QAAM,SAAS,MAAM,OAAO,sBAAsB,mBAAmB,kBAAkB;AAEvF,QAAM,iBAAiB,CAAC,OAA+C;AAAA,IACnE,WAAW,EAAE;AAAA,IACb,YAAY,EAAE;AAAA,IACd,WAAW,EAAE;AAAA,IACb,QAAQ,EAAE,OAAO,IAAI,QAAM;AAAA,MACvB,UAAU,EAAE;AAAA,MACZ,WAAW,EAAE;AAAA,MACb,MAAM,EAAE;AAAA,IACZ,EAAE;AAAA,EACN;AAEA,SAAO;AAAA,IACH,QAAQ,eAAe,OAAO,MAAM;AAAA,IACpC,KAAK,OAAO,MAAM,eAAe,OAAO,GAAG,IAAI;AAAA,IAC/C,MAAM,OAAO,OAAO,eAAe,OAAO,IAAI,IAAI;AAAA,IAClD,iBAAiB,OAAO;AAAA,EAC5B;AACJ;","names":["require","result"]}
|
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
import { CSSOptions, BundlerAdapter } from '@flight-framework/bundler';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @flight-framework/bundler-flightpack - Types
|
|
5
|
-
*
|
|
6
|
-
* Type definitions for the FlightPack bundler adapter.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Platform target for builds
|
|
11
|
-
*/
|
|
12
|
-
type Platform = 'browser' | 'node' | 'edge' | 'neutral';
|
|
13
|
-
/**
|
|
14
|
-
* Output format for bundles
|
|
15
|
-
*/
|
|
16
|
-
type OutputFormat = 'esm' | 'cjs' | 'iife';
|
|
17
|
-
/**
|
|
18
|
-
* Target environment for transpilation
|
|
19
|
-
*/
|
|
20
|
-
type TargetEnvironment = 'es2020' | 'es2021' | 'es2022' | 'es2023' | 'es2024' | 'esnext';
|
|
21
|
-
/**
|
|
22
|
-
* Options for the FlightPack bundler adapter
|
|
23
|
-
*/
|
|
24
|
-
interface FlightPackAdapterOptions {
|
|
25
|
-
/**
|
|
26
|
-
* Enable minification in production builds
|
|
27
|
-
* @default true in production, false in development
|
|
28
|
-
*/
|
|
29
|
-
minify?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Generate source maps
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
34
|
-
sourcemap?: boolean | 'inline' | 'hidden';
|
|
35
|
-
/**
|
|
36
|
-
* Target environment
|
|
37
|
-
* @default 'es2024'
|
|
38
|
-
*/
|
|
39
|
-
target?: TargetEnvironment;
|
|
40
|
-
/**
|
|
41
|
-
* Enable tree shaking
|
|
42
|
-
* @default true
|
|
43
|
-
*/
|
|
44
|
-
treeshake?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Maximum chunk size in KB before warning
|
|
47
|
-
* @default 500
|
|
48
|
-
*/
|
|
49
|
-
chunkSizeLimit?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Enable React Server Components support
|
|
52
|
-
* @default true
|
|
53
|
-
*/
|
|
54
|
-
rsc?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Enable Hot Module Replacement in dev mode
|
|
57
|
-
* @default true
|
|
58
|
-
*/
|
|
59
|
-
hmr?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* CSS configuration
|
|
62
|
-
*/
|
|
63
|
-
css?: CSSOptions;
|
|
64
|
-
/**
|
|
65
|
-
* Resolve aliases (similar to webpack resolve.alias)
|
|
66
|
-
*/
|
|
67
|
-
resolveAlias?: Record<string, string>;
|
|
68
|
-
/**
|
|
69
|
-
* File extensions to resolve
|
|
70
|
-
* @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
|
|
71
|
-
*/
|
|
72
|
-
resolveExtensions?: string[];
|
|
73
|
-
/**
|
|
74
|
-
* External packages (not bundled)
|
|
75
|
-
*/
|
|
76
|
-
external?: string[];
|
|
77
|
-
/**
|
|
78
|
-
* Define global constants (replaced at compile time)
|
|
79
|
-
*/
|
|
80
|
-
define?: Record<string, string>;
|
|
81
|
-
/**
|
|
82
|
-
* Auto-register adapter on import
|
|
83
|
-
* @default true
|
|
84
|
-
*/
|
|
85
|
-
autoRegister?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Enable code splitting for dynamic imports
|
|
88
|
-
* @default true
|
|
89
|
-
*/
|
|
90
|
-
splitting?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Platform target for the build
|
|
93
|
-
* Determines module resolution, externals behavior, and runtime features
|
|
94
|
-
* @default 'browser'
|
|
95
|
-
*/
|
|
96
|
-
platform?: Platform;
|
|
97
|
-
/**
|
|
98
|
-
* Output format
|
|
99
|
-
* @default 'esm'
|
|
100
|
-
*/
|
|
101
|
-
format?: OutputFormat;
|
|
102
|
-
/**
|
|
103
|
-
* Force bundle packages (override external/auto-external)
|
|
104
|
-
* Takes precedence over external
|
|
105
|
-
*/
|
|
106
|
-
noExternal?: string[];
|
|
107
|
-
/**
|
|
108
|
-
* Enable Server Actions support
|
|
109
|
-
* @default true
|
|
110
|
-
*/
|
|
111
|
-
serverActions?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Resolve conditions for package.json exports
|
|
114
|
-
* Auto-set based on platform if not specified
|
|
115
|
-
*/
|
|
116
|
-
conditions?: string[];
|
|
117
|
-
/**
|
|
118
|
-
* Node.js target version (for Node platform)
|
|
119
|
-
* e.g., "node20", "node22"
|
|
120
|
-
*/
|
|
121
|
-
nodeTarget?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Multi-environment build configuration
|
|
124
|
-
* When set, builds for multiple platforms simultaneously
|
|
125
|
-
*/
|
|
126
|
-
environments?: EnvironmentsConfig;
|
|
127
|
-
/**
|
|
128
|
-
* Additional options passed directly to FlightPack
|
|
129
|
-
*/
|
|
130
|
-
[key: string]: unknown;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Environment-specific build options
|
|
134
|
-
*/
|
|
135
|
-
interface EnvironmentOptions {
|
|
136
|
-
/** Platform target */
|
|
137
|
-
platform?: Platform;
|
|
138
|
-
/** Node.js target version (e.g., "node22") */
|
|
139
|
-
nodeTarget?: string;
|
|
140
|
-
/** Resolve conditions */
|
|
141
|
-
conditions?: string[];
|
|
142
|
-
/** External packages */
|
|
143
|
-
external?: string[];
|
|
144
|
-
/** Force bundle packages */
|
|
145
|
-
noExternal?: string[];
|
|
146
|
-
/** Output directory for this environment */
|
|
147
|
-
outDir?: string;
|
|
148
|
-
/** Entry points for this environment */
|
|
149
|
-
entry?: string[];
|
|
150
|
-
/** Enable minification */
|
|
151
|
-
minify?: boolean;
|
|
152
|
-
/** Generate source maps */
|
|
153
|
-
sourcemap?: boolean;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Multi-environment configuration
|
|
157
|
-
* Based on Vite 7+ Environment API
|
|
158
|
-
*/
|
|
159
|
-
interface EnvironmentsConfig {
|
|
160
|
-
/** Client (browser) environment - always present */
|
|
161
|
-
client: EnvironmentOptions;
|
|
162
|
-
/** SSR (Node.js server) environment - optional */
|
|
163
|
-
ssr?: EnvironmentOptions;
|
|
164
|
-
/** Edge environment (Cloudflare Workers, etc.) - optional */
|
|
165
|
-
edge?: EnvironmentOptions;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Multi-environment build result
|
|
169
|
-
*/
|
|
170
|
-
interface MultiEnvironmentBuildResult {
|
|
171
|
-
/** Client build result */
|
|
172
|
-
client: FlightPackBuildResult;
|
|
173
|
-
/** SSR build result (if configured) */
|
|
174
|
-
ssr?: FlightPackBuildResult;
|
|
175
|
-
/** Edge build result (if configured) */
|
|
176
|
-
edge?: FlightPackBuildResult;
|
|
177
|
-
/** Total duration in milliseconds */
|
|
178
|
-
totalDurationMs: number;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Fallback behavior for dynamic routes
|
|
182
|
-
*/
|
|
183
|
-
type SSGFallback = 'false' | 'true' | 'blocking';
|
|
184
|
-
/**
|
|
185
|
-
* SSG page configuration
|
|
186
|
-
*/
|
|
187
|
-
interface SSGPageConfig {
|
|
188
|
-
/** Route path pattern (e.g., "/blog/[slug]") */
|
|
189
|
-
path: string;
|
|
190
|
-
/** Static params for dynamic routes */
|
|
191
|
-
params?: Record<string, string>[];
|
|
192
|
-
/** Fallback behavior for paths not generated at build time */
|
|
193
|
-
fallback?: SSGFallback;
|
|
194
|
-
/** Revalidation time in seconds (ISR) */
|
|
195
|
-
revalidate?: number;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* SSG generation options
|
|
199
|
-
*/
|
|
200
|
-
interface SSGOptions {
|
|
201
|
-
/** Pages to pre-render */
|
|
202
|
-
pages: SSGPageConfig[];
|
|
203
|
-
/** Output directory */
|
|
204
|
-
outDir?: string;
|
|
205
|
-
/** SSR bundle path (for rendering) */
|
|
206
|
-
ssrBundle?: string;
|
|
207
|
-
/** Default revalidation time in seconds */
|
|
208
|
-
defaultRevalidate?: number;
|
|
209
|
-
/** Maximum concurrent page generations */
|
|
210
|
-
concurrency?: number;
|
|
211
|
-
/** Generate trailing slashes in URLs */
|
|
212
|
-
trailingSlash?: boolean;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Generated page information
|
|
216
|
-
*/
|
|
217
|
-
interface SSGGeneratedPage {
|
|
218
|
-
/** Route path */
|
|
219
|
-
path: string;
|
|
220
|
-
/** Output file path */
|
|
221
|
-
filePath: string;
|
|
222
|
-
/** Revalidation time (for ISR) */
|
|
223
|
-
revalidate?: number;
|
|
224
|
-
/** Page size in bytes */
|
|
225
|
-
size: number;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* SSG generation result
|
|
229
|
-
*/
|
|
230
|
-
interface SSGResult {
|
|
231
|
-
/** All generated pages */
|
|
232
|
-
pages: SSGGeneratedPage[];
|
|
233
|
-
/** Total duration in milliseconds */
|
|
234
|
-
durationMs: number;
|
|
235
|
-
/** Total size of all pages */
|
|
236
|
-
totalSize: number;
|
|
237
|
-
/** Pages that require ISR */
|
|
238
|
-
isrPages: string[];
|
|
239
|
-
/** Errors encountered */
|
|
240
|
-
errors: string[];
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Options for the FlightPack dev server
|
|
244
|
-
*/
|
|
245
|
-
interface FlightPackDevServerOptions {
|
|
246
|
-
/**
|
|
247
|
-
* Port to run dev server on
|
|
248
|
-
* @default 5173
|
|
249
|
-
*/
|
|
250
|
-
port?: number;
|
|
251
|
-
/**
|
|
252
|
-
* Host to bind to
|
|
253
|
-
* @default 'localhost'
|
|
254
|
-
*/
|
|
255
|
-
host?: string;
|
|
256
|
-
/**
|
|
257
|
-
* Enable HTTPS
|
|
258
|
-
* @default false
|
|
259
|
-
*/
|
|
260
|
-
https?: boolean | {
|
|
261
|
-
key?: string;
|
|
262
|
-
cert?: string;
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* Open browser on start
|
|
266
|
-
* @default false
|
|
267
|
-
*/
|
|
268
|
-
open?: boolean;
|
|
269
|
-
/**
|
|
270
|
-
* Proxy configuration for API requests
|
|
271
|
-
*/
|
|
272
|
-
proxy?: Record<string, string | {
|
|
273
|
-
target: string;
|
|
274
|
-
changeOrigin?: boolean;
|
|
275
|
-
rewrite?: (path: string) => string;
|
|
276
|
-
}>;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Result from FlightPack native build
|
|
280
|
-
*/
|
|
281
|
-
interface FlightPackBuildResult {
|
|
282
|
-
/** Output directory path */
|
|
283
|
-
outputDir: string;
|
|
284
|
-
/** Build duration in milliseconds */
|
|
285
|
-
durationMs: number;
|
|
286
|
-
/** Total size of all output files in bytes */
|
|
287
|
-
totalSize: number;
|
|
288
|
-
/** Information about each generated chunk */
|
|
289
|
-
chunks: FlightPackChunkInfo[];
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Information about a generated chunk
|
|
293
|
-
*/
|
|
294
|
-
interface FlightPackChunkInfo {
|
|
295
|
-
/** File name of the chunk */
|
|
296
|
-
fileName: string;
|
|
297
|
-
/** Type of chunk: 'entry', 'chunk', or 'asset' */
|
|
298
|
-
chunkType: 'entry' | 'chunk' | 'asset';
|
|
299
|
-
/** Size in bytes */
|
|
300
|
-
size: number;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Result from single file transformation
|
|
304
|
-
*/
|
|
305
|
-
interface FlightPackTransformResult {
|
|
306
|
-
/** Transformed code */
|
|
307
|
-
code: string;
|
|
308
|
-
/** Source map (if generated) */
|
|
309
|
-
map: string | null;
|
|
310
|
-
/** Whether transformation succeeded */
|
|
311
|
-
success: boolean;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Options for single file transformation
|
|
315
|
-
*/
|
|
316
|
-
interface FlightPackTransformOptions {
|
|
317
|
-
/** Generate source maps */
|
|
318
|
-
sourcemap?: boolean;
|
|
319
|
-
/** Enable minification */
|
|
320
|
-
minify?: boolean;
|
|
321
|
-
/** Target environment */
|
|
322
|
-
target?: string;
|
|
323
|
-
/** JSX factory function */
|
|
324
|
-
jsxFactory?: string;
|
|
325
|
-
/** JSX fragment function */
|
|
326
|
-
jsxFragment?: string;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* @flight-framework/bundler-flightpack
|
|
331
|
-
*
|
|
332
|
-
* FlightPack native Rust bundler adapter for Flight Framework.
|
|
333
|
-
* Wraps the native Rust bundler for maximum performance.
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* ```typescript
|
|
337
|
-
* // In flight.config.ts
|
|
338
|
-
* import { defineConfig } from '@flight-framework/core';
|
|
339
|
-
* import { flightpack } from '@flight-framework/bundler-flightpack';
|
|
340
|
-
*
|
|
341
|
-
* export default defineConfig({
|
|
342
|
-
* bundler: flightpack(),
|
|
343
|
-
* });
|
|
344
|
-
* ```
|
|
345
|
-
*
|
|
346
|
-
* @packageDocumentation
|
|
347
|
-
*/
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Create a FlightPack bundler adapter
|
|
351
|
-
*
|
|
352
|
-
* FlightPack is a native Rust bundler that provides:
|
|
353
|
-
* - 1,874+ files/second processing speed
|
|
354
|
-
* - Zero-config TypeScript/TSX support via Oxc
|
|
355
|
-
* - React Server Components (RSC) support
|
|
356
|
-
* - Tree shaking and code splitting
|
|
357
|
-
* - Hot Module Replacement (HMR)
|
|
358
|
-
*
|
|
359
|
-
* @param options - FlightPack adapter options
|
|
360
|
-
* @returns A BundlerAdapter instance
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```typescript
|
|
364
|
-
* import { flightpack } from '@flight-framework/bundler-flightpack';
|
|
365
|
-
*
|
|
366
|
-
* const adapter = flightpack({
|
|
367
|
-
* minify: true,
|
|
368
|
-
* sourcemap: true,
|
|
369
|
-
* rsc: true,
|
|
370
|
-
* });
|
|
371
|
-
* ```
|
|
372
|
-
*/
|
|
373
|
-
declare function flightpack(options?: FlightPackAdapterOptions): BundlerAdapter;
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Package version
|
|
377
|
-
*/
|
|
378
|
-
declare const VERSION = "0.0.1";
|
|
379
|
-
/**
|
|
380
|
-
* FlightPack utility functions for advanced usage
|
|
381
|
-
*
|
|
382
|
-
* @example
|
|
383
|
-
* ```typescript
|
|
384
|
-
* import { utils } from '@flight-framework/bundler-flightpack';
|
|
385
|
-
*
|
|
386
|
-
* utils.isNodeBuiltin('fs'); // true
|
|
387
|
-
* utils.isEdgeCompatible('fs'); // false
|
|
388
|
-
* utils.isBareImport('react'); // true
|
|
389
|
-
* ```
|
|
390
|
-
*/
|
|
391
|
-
declare const utils: {
|
|
392
|
-
/**
|
|
393
|
-
* Check if a module is a Node.js builtin
|
|
394
|
-
* Handles both 'fs' and 'node:fs' formats
|
|
395
|
-
*/
|
|
396
|
-
isNodeBuiltin(moduleId: string): Promise<boolean>;
|
|
397
|
-
/**
|
|
398
|
-
* Get list of all Node.js builtin modules
|
|
399
|
-
*/
|
|
400
|
-
getNodeBuiltins(): Promise<string[]>;
|
|
401
|
-
/**
|
|
402
|
-
* Get list of all Node.js builtins with node: prefix
|
|
403
|
-
*/
|
|
404
|
-
getNodeBuiltinsPrefixed(): Promise<string[]>;
|
|
405
|
-
/**
|
|
406
|
-
* Check if a module is a bare import (from node_modules)
|
|
407
|
-
* Returns false for relative/absolute paths
|
|
408
|
-
*/
|
|
409
|
-
isBareImport(moduleId: string): Promise<boolean>;
|
|
410
|
-
/**
|
|
411
|
-
* Check if a module is compatible with Edge runtimes
|
|
412
|
-
* Returns false for modules like 'fs', 'child_process', etc.
|
|
413
|
-
*/
|
|
414
|
-
isEdgeCompatible(moduleId: string): Promise<boolean>;
|
|
415
|
-
/**
|
|
416
|
-
* Get list of Edge-incompatible modules
|
|
417
|
-
*/
|
|
418
|
-
getEdgeIncompatibleModules(): Promise<string[]>;
|
|
419
|
-
/**
|
|
420
|
-
* Get default resolve conditions for a platform
|
|
421
|
-
*/
|
|
422
|
-
getPlatformConditions(platform: "browser" | "node" | "edge" | "neutral"): Promise<string[]>;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Generate static pages (SSG/ISR)
|
|
427
|
-
*
|
|
428
|
-
* Pre-renders pages at build time with optional Incremental Static Regeneration.
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* ```typescript
|
|
432
|
-
* import { generateSSG } from '@flight-framework/bundler-flightpack';
|
|
433
|
-
*
|
|
434
|
-
* const result = await generateSSG({
|
|
435
|
-
* pages: [
|
|
436
|
-
* { path: '/' },
|
|
437
|
-
* { path: '/about' },
|
|
438
|
-
* { path: '/blog/[slug]', params: [{ slug: 'hello' }, { slug: 'world' }] },
|
|
439
|
-
* ],
|
|
440
|
-
* outDir: './dist',
|
|
441
|
-
* ssrBundle: './dist/server/entry-server.js',
|
|
442
|
-
* });
|
|
443
|
-
* ```
|
|
444
|
-
*/
|
|
445
|
-
declare function generateSSG(options: SSGOptions): Promise<SSGResult>;
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Build for multiple environments simultaneously
|
|
449
|
-
*
|
|
450
|
-
* Builds client, SSR, and edge bundles in parallel for maximum performance.
|
|
451
|
-
* Follows Vite 7+ Environment API patterns.
|
|
452
|
-
*
|
|
453
|
-
* @example
|
|
454
|
-
* ```typescript
|
|
455
|
-
* import { buildMultiEnvironment } from '@flight-framework/bundler-flightpack';
|
|
456
|
-
*
|
|
457
|
-
* const result = await buildMultiEnvironment({
|
|
458
|
-
* entry: ['src/index.tsx'],
|
|
459
|
-
* outDir: './dist',
|
|
460
|
-
* }, {
|
|
461
|
-
* client: { platform: 'browser', outDir: './dist/client' },
|
|
462
|
-
* ssr: { platform: 'node', outDir: './dist/server', external: ['express'] },
|
|
463
|
-
* edge: { platform: 'edge', outDir: './dist/edge' },
|
|
464
|
-
* });
|
|
465
|
-
* ```
|
|
466
|
-
*/
|
|
467
|
-
declare function buildMultiEnvironment(baseOptions: {
|
|
468
|
-
entry: string[];
|
|
469
|
-
outDir: string;
|
|
470
|
-
root?: string;
|
|
471
|
-
minify?: boolean;
|
|
472
|
-
sourcemap?: boolean;
|
|
473
|
-
rsc?: boolean;
|
|
474
|
-
treeshake?: boolean;
|
|
475
|
-
target?: string;
|
|
476
|
-
define?: Record<string, string>;
|
|
477
|
-
}, environments: EnvironmentsConfig): Promise<MultiEnvironmentBuildResult>;
|
|
478
|
-
|
|
479
|
-
export { type EnvironmentOptions, type EnvironmentsConfig, type FlightPackAdapterOptions, type FlightPackBuildResult, type FlightPackChunkInfo, type FlightPackDevServerOptions, type FlightPackTransformOptions, type FlightPackTransformResult, type MultiEnvironmentBuildResult, type OutputFormat, type Platform, type SSGFallback, type SSGGeneratedPage, type SSGOptions, type SSGPageConfig, type SSGResult, type TargetEnvironment, VERSION, buildMultiEnvironment, flightpack as createFlightPackAdapter, flightpack as default, flightpack, generateSSG, utils };
|