export declare class BuildError extends Error { readonly phase: string; constructor(message: string, phase: string); } export interface BuildOptions { readonly outputDir?: string | undefined; readonly introspect?: boolean | undefined; /** * When true, write build output directly into outputDir without nesting * under a package-name subdirectory (P3-2 / `rill build --flat`). */ readonly flat?: boolean | undefined; } export interface BuildResult { readonly outputPath: string; readonly checksum: string; } /** * Inline `_require("...package.json")` / `__require("...package.json")` calls * left by esbuild's CJS-to-ESM shim by replacing them with the literal JSON * contents. Both single- and double-underscore shim names are covered so the * downstream CJS scan sees no leftover package.json references when inlining * ran. Returns the (possibly-modified) bundled string. */ export declare function inlinePackageJsonRequires(bundled: string, sourcePkgJson: string): string; /** * Find any remaining `_require("X")` / `__require("X")` shim calls left in a * bundled extension. esbuild emits these when bundling CJS source to ESM and * cannot statically resolve a `require()` call. Each such call throws * `Dynamic require of "X" is not supported` at runtime. * * A target is considered safe — and the whole offender list suppressed — in * two cases: * 1. The inline step above has replaced all package.json references with * literal JSON, leaving no `_require`/`__require` calls in the bundle. * 2. The bundle wires `_require` or `__require` via * `createRequire(import.meta.url)` (detected by `REQUIRE_WIRING`), so * Node resolves all remaining calls at runtime. * * Returns sorted, distinct require targets. Empty array means the bundle is * free of dynamic-require shims (or all calls are safely wired). */ export declare function findOffendingDynamicRequires(bundled: string): string[]; /** * Compile a rill project into a self-contained output directory. * * Reads rill-config.json from projectDir, compiles local TypeScript extensions, * copies .rill files, rewrites extension mount paths in output config, * validates the completed output via loadProject() dry-run, then enriches * rill-config.json with a build metadata section. * * Output structure: * build/ * / * main.rill * rill-config.json ← enriched with build metadata * extensions/ * * @param projectDir - Directory containing rill-config.json * @param options - Optional outputDir (default: 'build/') * @returns BuildResult with package output path and checksum * @throws BuildError for file/compilation/bundling/validation failures */ export declare function buildPackage(projectDir: string, options?: BuildOptions): Promise; /** * Recursively collect all file paths under a directory. */ export declare function walkDir(dir: string): Promise;