pkg_json.ts

The curated, publish-safe subset of package.json.

PkgJson is the shape served by the virtual:pkg.json Vite module (see fuz_ui's vite_plugin_pkg_json) and fed to LibraryJson.pkg_json. It exists to keep the rest of package.jsonscripts, dependencies, devDependencies, engines, files, internal config — out of client bundles and rendered output. The plugin strips to pkg_json_keys at build time; PkgJson is Picked from the same list, so the runtime strip and the type can't drift, and the type is strict (accessing a stripped field like pkg_json.scripts is a compile error).

Declarations
#

4 declarations

view source

pkg_json_from_package_json
#

pkg_json.ts view source

(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

type { [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

type readonly string[]
default pkg_json_keys

returns

PkgJson

pkg_json_keys
#

pkg_json.ts view source

readonly ["name", "version", "private", "description", "tagline", "glyph", "logo", "logo_alt", "license", "homepage", "repository", "funding", "exports"] import {pkg_json_keys} from '@fuzdev/fuz_util/pkg_json.js';

The keys kept when stripping package.json down to a PkgJson — package identity plus the Fuz extension fields (tagline, glyph, logo, logo_alt). exports and private are kept because a consumer derives a library's published status from them; everything omitted stays out of the client.

PkgJson
#

pkg_json.ts view source

PkgJson import type {PkgJson} from '@fuzdev/fuz_util/pkg_json.js';

Publish-safe subset of PackageJson.

name

type string

version?

type string

description?

type string

private?

type boolean

tagline?

type string

glyph?

type string

logo?

type string

logo_alt?

type string

license?

type string

homepage?

type string

repository?

type string | { [x: string]: unknown; type: string; url: string; directory?: string | undefined; }

funding?

type string | { [x: string]: unknown; type: string; url: string; } | (string | { [x: string]: unknown; type: string; url: string; })[]

exports?

type string | Record<string, unknown>

PkgJsonKey
#

pkg_json.ts view source

"name" | "version" | "description" | "private" | "tagline" | "glyph" | "logo" | "logo_alt" | "license" | "homepage" | "repository" | "funding" | "exports" import type {PkgJsonKey} from '@fuzdev/fuz_util/pkg_json.js';

Depends on
#

Imported by
#