/** * Extracts external dependency information from esbuild metafiles. * * Parses esbuild's metafile JSON to find all node_modules references, * then resolves their exact versions from the project's package.json * and/or yarn.lock to produce a minimal package.json. */ import type { Metafile } from 'esbuild'; /** * Extracts bare package names from esbuild metafile imports. * * When esbuild runs with `packages: 'external'`, external imports appear * in the metafile's outputs[].imports array with `external: true`. * This function collects all unique package names from those imports. */ export declare function extractExternalPackages(metafile: Metafile): Set; /** * Parses a bare import specifier into a package name. * * Handles scoped packages (`@scope/pkg`) and deep imports (`pkg/sub/path`). * Returns null for relative imports or other non-package specifiers. */ export declare function parsePackageName(specifier: string): string | null; /** * Resolves exact versions for a set of external package names. * * Shared by both bundler backends: esbuild derives the set from its metafile * (`extractExternalPackages`), while the Bun.build backend captures it via a * resolve plugin (Bun's metafile does not record external imports). */ export declare function resolveExternalVersions(externalPackages: Set, projectDir: string): Promise<{ exactDependencies: Record; exactOptionalDependencies: Record; }>; /** * Given an esbuild metafile, extracts all external packages and resolves * their versions from the project's dependency files. */ export declare function extractDependencies(metafile: Metafile, projectDir: string): Promise<{ exactDependencies: Record; exactOptionalDependencies: Record; }>; /** * Generates a minimal package.json content object for a unit bundle. */ export declare function generateMinimalPackageJson(unitName: string, dependencies: Record, optionalDependencies: Record): Record;