/** * @zveltio/sdk/build * * Public API for authors who want to compile their extension bundle * from a custom build script (not via `zveltio extension pack`). * * The canonical pipeline is still `zveltio extension pack` — it * understands the manifest, computes the hash, and patches the * integrity block. This module exposes the underlying `Bun.build` * plugin so authors with non-standard build flows (monorepo * orchestration, custom entrypoints, IDE integration) can produce * the SAME artifact bytes. * * Usage: * * ```ts * import { createExtensionBuildConfig } from '@zveltio/sdk/build'; * * const result = await Bun.build({ * ...createExtensionBuildConfig({ * entry: './engine/index.ts', * outdir: './engine', * resolveDir: process.cwd(), * }), * }); * ``` * * After build, compute SHA-256 of `engine/index.js` and write it to * `manifest.integrity.engineSha256` — the engine refuses to load any * bundled extension whose on-disk bytes don't match the declared hash. */ import type { BunPlugin } from 'bun'; /** * Packages that the engine ships in its compiled binary AND that * Bun's bundler resolves to `.d.ts` (not `.js`) due to an exports- * condition quirk. The plugin below forces them to resolve to their * ESM JavaScript entrypoints so the bundle actually runs. */ export declare const EXTENSION_BUNDLE_CORE_DEPS: readonly ["hono", "zod", "kysely", "@hono/zod-validator"]; /** * Bun plugin that forces the core extension deps (hono / zod / kysely * / @hono/zod-validator) to resolve to their ESM `.js` entrypoints * during build. Works around Bun's exports-condition matching picking * `.d.ts` for hono-style packages. */ export declare function createExtensionBundleResolvePlugin(resolveFromDir: string): BunPlugin; export interface ExtensionBuildConfigOptions { /** Absolute path to the extension's `engine/index.ts`. */ entry: string; /** Directory the build output lands in (typically `/engine`). */ outdir: string; /** Extension root — used to walk node_modules for peer-dep resolution. */ resolveDir: string; /** External packages to leave as bare imports. Use sparingly — Bun's * compiled binary cannot resolve bare specifiers from dynamically- * imported disk files. Default: []. */ external?: string[]; /** Emit a `.map` next to the bundle. Default: false. */ sourcemap?: boolean; } /** * Build a `Bun.build` config object the SAME way `zveltio extension * pack` does. Returns the full options object including the resolve * plugin and bundle conditions — spread it into your own `Bun.build` * call. */ export declare function createExtensionBuildConfig(opts: ExtensionBuildConfigOptions): { entrypoints: string[]; outdir: string; target: "bun"; format: "esm"; sourcemap: "linked" | "none"; external: string[]; conditions: ("default" | "import" | "bun" | "node")[]; plugins: BunPlugin[]; }; //# sourceMappingURL=index.d.ts.map