Skip to main content

Module package_json

Module package_json 

Source
Expand description

Pure-Rust npm manifest + lockfile schemas, modeled on the npm specs:

A module of npm-utils (npm_utils::package_json). It parses, resolves, and renders — manifests and lockfiles as pure Value/string transforms — but never writes files, hits the network, or resolves untrusted paths, which keeps its strict spec-conformance tests pure and self-contained (the CLI does the file IO).

Four pieces:

  • this module root: package.json — its dependencies specs and a browser-favoring conditional-exports resolver (enough of Node’s algorithm to build an ES-module import map).
  • spec — the npm “package spec” dependency grammar (spec::Spec) and spec::version_req.
  • lockpackage-lock.json (v2/v3) parsing into a faithful lock::Lockfile, and lock::render_v3 for emitting one.
  • manifest — pure write-side package.json transforms (scaffold / upsert a dependency) for the CLI’s init/add.

Modules§

lock
package-lock.json (lockfileVersion 2 or 3) parsing, per https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json.
manifest
Pure package.json write-side transforms — the counterpart to this module’s readers.
spec
The npm “package spec” — the dependency-specifier grammar, per https://docs.npmjs.com/cli/v8/using-npm/package-spec.

Structs§

Dependency
A dependency parsed from a package.json dependencies map.
PackageJson
Browser-favoring conditional-exports resolver over a parsed package.json.

Enums§

Entry
An import-map-worthy entry derived from a package’s package.json.
PackageType
The "type" field of a package.json (Node defaults to CommonJS).

Functions§

parse_dependencies
Parse the dependencies section of a package.json.