/** * Bun bundler plugin that turns `loadDir`/`registerDir` calls with literal * string paths into explicit static imports. Only runs during `tekir build * --compile` so single-executable binaries can include the auto-loaded * controllers, jobs, listeners, etc. that would otherwise miss the bundle. * * AST-based (oxc-parser) so it never confuses commented-out calls or * string literals for real call expressions. * * `oxc-parser` is an optional peer dependency. When the user runs * `--compile` without it installed, the build helper prints a friendly * install hint and skips the plugin (the binary will still run on * runtime fs, breaking on missing files; the warning makes that obvious). */ interface CallSite { type: 'loadDir' | 'registerDir'; start: number; end: number; path: string; } /** * Build-time file read pattern site. The inliner reads `path` from disk * during the bundle and replaces the original call with a literal value * matching `shape`, so the resulting bundle has no runtime fs lookup * for these inputs and can run from any working directory. * * Shapes are determined by the call form: * - sync-string: `readFileSync(p, 'utf-8')` or with `{ encoding }` * - sync-buffer: `readFileSync(p)` (no encoding → returns Buffer) * - async-string: `await readFile(p, 'utf-8')` (from `fs/promises`) * - async-buffer: `await readFile(p)` (from `fs/promises`, no encoding) * - bun-text: `await Bun.file(p).text()` * - bun-arraybuffer: `await Bun.file(p).arrayBuffer()` */ type FsReadShape = 'sync-string' | 'sync-buffer' | 'async-string' | 'async-buffer' | 'bun-text' | 'bun-arraybuffer'; interface FsReadCallSite { type: 'fsRead'; start: number; end: number; path: string; shape: FsReadShape; } type Site = CallSite | FsReadCallSite; /** * Walk the AST and collect every recognizable inline target: * - `loadDir('literal')` and `*.registerDir('literal')` calls (existing) * - `readFileSync(literal, ...)`, `readFile(literal, ...)` (new) * - `Bun.file(literal).text()` / `.arrayBuffer()` chains (new) * * Sites without a literal first argument or without an analyzable * encoding are skipped so the runtime fallback handles them. */ declare function findCallSites(source: string, filename: string, parseSync: (f: string, s: string) => any): Site[]; /** * List the eligible module files inside a directory, sorted, for the * inliner to import. Skips type-declaration siblings and matches the * default `loadDir` extension list. */ declare function listFiles(dir: string): string[]; declare function toRel(target: string, from: string): string; declare function transformSource(source: string, sites: Site[], fileDir: string, parseSync?: (f: string, s: string) => any): string | null; /** * Build a Bun plugin that inlines `loadDir`/`registerDir` literal-string * calls. Returns `null` when `oxc-parser` is not available; the caller * surfaces an install hint to the user. */ export declare function createInlinerPlugin(): Promise; /** * Test-only helpers exposed for the unit tests. The plugin itself uses * them through the closure above. */ export declare const __internal: { findCallSites: typeof findCallSites; transformSource: typeof transformSource; listFiles: typeof listFiles; toRel: typeof toRel; }; export {};