description: "Caller-relative lazy loading for CommonJS-compatible Host dependencies whose initialization is not needed during application startup."
English | 中文
dsh-lazy-require keeps a CommonJS-compatible Host dependency unloaded until its first real operation. Resolution remains relative to the consuming package, and one successful module value is reused for the rest of the process realm.
Pass the dependency's literal specifier and the caller's import.meta.url:
import { createLazyRequire } from '@deepseek-ai/dsh-lazy-require'
interface NativeModule { open(): void }
const requireNative = createLazyRequire<NativeModule>('native-package', import.meta.url)
Calling requireNative() loads the dependency once. A failed load is not cached.
None, as this Host utility registers no model-facing behavior.
None.
createLazyRequire() calls. A package used in a Preview image must keep the dependency reachable through a supported literal request until the packer recognizes this helper.No runtime invariant companion is published because the loader holds no independently observable mutable relationship.
None.