/** In-pipeline import rewriter for Bun.build outputs. * * Replaces the previous post-build `rewriteImports` + `rewriteVendorDirectories` * passes that walked file paths captured at scheduling time and read them off * disk later — a race window where the next rebuild could sweep a path between * capture and read, producing ENOENT. * * Now: the rewrite operates on the `BuildArtifact` outputs returned by * `Bun.build()` itself, in the same await chain. Each output's content is * transformed (using the native Zig scanner when available, falling back to * the JS regex implementation), then written back to disk. The standalone * iteration over a captured path list goes away. */ import type { BuildArtifact, BuildOutput } from 'bun'; /** JS fallback: regex-based import rewriting. */ export declare const jsRewriteImports: (content: string, replacements: [string, string][]) => string; /** Apply the bare-specifier → vendor-URL rewrite to a single chunk of text. */ export declare const rewriteImportsInContent: (content: string, vendorPaths: Record) => string; /** Workaround for a Bun bundler bug: when a module does both * `import { x } from 'X'` AND `export * from 'X'`, and `X` is externalized, * Bun synthesizes a `__reExport(exports_Y, ns)` call but drops the * corresponding `import * as ns from "X"` declaration. The resulting chunk * references an undeclared identifier and crashes at module evaluation. * * Detects the pattern and injects the missing namespace import. The source * path is recovered from a sibling named-import in the same chunk (Bun keeps * that intact). */ export declare const fixMissingReExportNamespacesInContent: (content: string) => string; /** In-pipeline output rewrite. Reads each emitted .js artifact, applies the * rewrite, and writes back. Operates on `BuildArtifact[]` straight off * `Bun.build()`'s result so paths are guaranteed-current — no race window. */ export declare const rewriteBuildOutputs: (outputs: BuildArtifact[], vendorPaths: Record) => Promise; /** Like `rewriteBuildOutputs`, but takes a separate per-artifact resolver to * produce path maps. Used for the SSR-side @angular/* rewrite which uses * paths relative to each artifact's directory. */ export declare const rewriteBuildOutputsWith: (outputs: BuildArtifact[], resolveVendorPaths: (artifact: BuildArtifact) => Record) => Promise; /** Apply the rewrite + re-export fix to every .js file inside a list of * vendor directories. Used after vendor builds where each pipeline emits * files that may externalize specifiers owned by another pipeline. * * This still walks the directory because the cross-vendor rewrite happens * AFTER all vendor builds complete (so every framework's path map is * available) — it doesn't have a single `BuildArtifact[]` to operate on. * ENOENT during read/write is tolerated for the same race-protection * reason as the in-pipeline path. */ export declare const rewriteVendorDirectories: (vendorDirs: string[], vendorPaths: Record) => Promise; /** Helper to wrap a `Bun.build` call so the rewrite happens in-pipeline. * Use as: `const result = await buildWithImportRewrite(bunBuild(config), vendorPaths)`. */ export declare const buildWithImportRewrite: (pendingBuild: Promise, vendorPaths: Record) => Promise;