(source: { [x: string]: unknown; name: string; version?: string | undefined; private?: boolean | undefined; description?: string | undefined; tagline?: string | undefined; glyph?: string | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; }, keys?: readonly string[]): PkgJson import {pkg_json_from_package_json} from '@fuzdev/fuz_util/pkg_json.js'; Picks the curated, publish-safe subset from a full package.json-shaped
object — the runtime counterpart of the PkgJson type, keyed off the same
pkg_json_keys so the strip and the type can't drift. Idempotent: an
already-curated PkgJson passes through unchanged.
Use it at every boundary that feeds package.json into a LibraryJson so the
curation the type promises actually holds at runtime — otherwise the full
manifest rides along, typed as the subset (see fuz_ui's vite_plugin_pkg_json
for the parallel build-time strip).
keys overrides the field set to keep — pass a wider list (typically
`` [...pkg_json_keys, 'keywords'] ``) to expose extra publish-safe fields.
The result is then a superset of PkgJson, so the extra fields stay
statically untyped; the same keys must reach library_json_from_modules
(and the consumer's virtual:pkg.json ambient type) for them to survive end
to end.
source
{ [x: string]: unknown; name: string; version?: string | undefined; private?: boolean | undefined; description?: string | undefined; tagline?: string | undefined; glyph?: string | undefined; logo?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; }keys
readonly string[]pkg_json_keysreturns
PkgJson