npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qilin-agent/lazy-require

v3.1.5

Published

Caller-relative, success-cached lazy loading for CommonJS-compatible Host dependencies

Downloads

295

Readme


description: "按调用方解析并惰性加载 CommonJS 兼容的 Host 依赖,使应用启动时不初始化尚未使用的依赖。" kind: "package-library"

@qilin-agent/lazy-require

English | 中文

概述

qilin-lazy-require 会让 CommonJS 兼容的 Host 依赖保持未加载状态,直到首次实际操作。解析仍以消费方 package 为基准,同一进程 realm 会复用一次成功加载的模块值。

目录


使用本包

传入依赖的字面量 specifier 与调用方的 import.meta.url:

import { createLazyRequire } from '@qilin-agent/lazy-require'

interface NativeModule { open(): void }
const requireNative = createLazyRequire<NativeModule>('native-package', import.meta.url)

调用 requireNative() 时才加载依赖,并只加载一次。失败的加载不会被缓存。


理解实现

本工具使用传入的调用方 URL 创建 Node require,并且只缓存成功返回的值。显式调用方 URL 会在发布后保留 package 局部的依赖解析。

源码地图

| 文件 | 职责 | |---|---| | src/index.ts | 按调用方解析的 loader 与成功结果缓存 |


进一步探索


模型体验

无,因为本 Host 工具不注册任何模型可见行为。

KV Cache 影响

无。

已知限制与延期工作

  • 仅限兼容 CommonJS 的依赖——仅 ESM package 需要由调用方拥有异步 factory。
  • WebWorker 打包需要显式请求——静态 packer 无法发现仅在 createLazyRequire() 调用中命名的依赖。Preview image 使用的 package 必须通过受支持的字面量请求保持该依赖可达,直到 packer 能够识别此 helper。

开发备注

无。