//#region src/lib/native-packages.d.ts /** * The architecture, OS and libc a Neon Function runs on. Native packages are installed for * this triple rather than for the machine running the deploy, which is usually a macOS or * linux-x64 laptop. */ declare const RUNTIME_TARGET: { readonly cpu: "arm64"; readonly os: "linux"; readonly libc: "glibc"; }; /** Human-readable form of {@link RUNTIME_TARGET}, for error messages. */ declare const RUNTIME_TARGET_LABEL: string; /** * Size ceilings the deploy must respect. The build service rejects an archive over these, * with an error that surfaces long after the CLI has exited, so they are checked here where * the message can name the files responsible. * * These mirror the service's limits rather than defining them. Passing them in lets a caller * track a change on the service side without editing this module. */ type ArchiveLimits = { /** Compressed archive bytes — the ZIP that is uploaded. */ maxZipBytes: number; /** Total uncompressed bytes across every archive entry. */ maxTotalBytes: number; /** Number of archive entries. */ maxEntries: number; }; declare const DEFAULT_ARCHIVE_LIMITS: ArchiveLimits; /** Injectable side effects, so the tracing logic is testable without a registry or npm. */ type NativeTraceDeps = { /** Install `specs` for the runtime target into `cwd`. Resolves on success. */ install: (cwd: string, specs: string[]) => Promise; /** Trace `entry` within `base`, returning archive-relative file paths. */ /** * Trace `entry` within `base`. * * `files` are archive-relative paths. `unresolved` are the specifiers the tracer could * not follow, which are classified rather than reported wholesale — see * {@link concreteUnresolved}. */ trace: (base: string, entry: string) => Promise<{ files: string[]; unresolved?: string[]; }>; /** Version of `pkg` as resolved in the user's project, or undefined if not installed. */ installedVersion: (projectDir: string, pkg: string) => string | undefined; }; /** Files to place in the archive under `node_modules/`, keyed by archive-relative path. */ type NativeTraceResult = { entries: Record; /** * Advisory findings from the staging run — currently a relative import the tracer could * not resolve, meaning that file will not be in the archive. * * The caller must surface these. They are advisory rather than fatal because the tracer * cannot tell a required import from one wrapped in a try/catch, but an unreported one is * a function that deploys clean and fails at invoke. */ warnings: string[]; }; /** * Collect the files the declared native packages need, ready to be merged into the archive. * * Three steps, in this order for reasons that are not interchangeable: * * 1. **Install for the runtime target into a throwaway directory.** The user's own * `node_modules` is never read for these files. Its binaries are built for their machine, * and a cross-platform install is not sticky — a later plain `npm install` re-resolves * optional dependencies for the host and replaces the target's packages with the host's. * Only the resolved *version* of the declared package is taken from the user's tree. That * is not the same as honouring their lockfile: transitive pins, overrides, patches, and * aliases are not carried across, so the staged graph can differ below the root. * 2. **Trace the installed tree.** The file set cannot be discovered by asking Node: * `@img/sharp-linux-arm64` exports only `./sharp.node` and `./package`, with no `.` and no * wildcard, so its directory is unreachable through the resolver. A tracer that follows * `createRequire` is required — which is also why esbuild cannot see these files, and why * `sharp` bundles cleanly today and then fails at invoke. * 3. **Copy the traced files, preserving the `node_modules` layout.** A `.node` addon locates * its sibling shared libraries by a path relative to its own directory, so flattening the * tree breaks loading even though every file is present. */ declare function traceNativePackages(options: { slug: string; packages: readonly string[]; projectDir: string; limits?: ArchiveLimits; deps?: Partial; }): Promise; /** * Check the archive against the build service's limits, naming the largest contributors. The * compressed size is not known until the archive is zipped, so only the counts and * uncompressed total are checked here; {@link assertZipWithinLimits} covers the rest. * * Exported so the caller can re-check the **final** archive: these entries are the staged * files alone, and the bundle is merged in afterwards. */ declare function enforceLimits(slug: string, entries: Record, limits?: ArchiveLimits): void; /** * Check the compressed archive, which is only measurable once it exists. Separate from * {@link enforceLimits} for that reason, and exported so the bundler can call it on the * finished ZIP. */ declare function assertZipWithinLimits(slug: string, zip: Uint8Array, entries: Record, limits?: ArchiveLimits): void; //#endregion export { ArchiveLimits, DEFAULT_ARCHIVE_LIMITS, NativeTraceDeps, NativeTraceResult, RUNTIME_TARGET, RUNTIME_TARGET_LABEL, assertZipWithinLimits, enforceLimits, traceNativePackages }; //# sourceMappingURL=native-packages.d.ts.map