npm-utils
Pure-Rust utilities for the npm registry and web assets — resolve a package
version, download npm tarballs and GitHub archives, and extract files. No Node or
npm at build time; just ureq + archive extraction. Handy from a build.rs to
vendor browser/JS dependencies into your own asset tree.
Modules
registry—Registry::npm();tarball_url(name, version)(handles@scope/pkg);packument(name);resolve(name, &VersionReq)→ the newest published version matching a semver range.download—fetch(url)(one retry, 100 MB cap);github_archive_url(...).extract—tar_gz(..)/zip(..)into a directory, selectingAll, an explicitFilesmap, or aMatchingpredicate; path-traversal-safe.cache— content-hash markers, a cross-processwith_lock, and directory helpers for skip-if-unchanged download caches.package_json— read pinned dependency versions from apackage.json.
Example
use ;
#
See examples/date-converter for a runnable Lit +
Temporal demo that vendors its dependencies with this crate.
License
MIT — see LICENSE.