@vyriy/package

Part of Vyriy - a calm architecture toolkit for TypeScript, React, SSR, SSG, APIs, and cloud-ready apps.

Helpers for reading and caching package.json in Vyriy projects.

Purpose

This package provides a small helper for reading the project package.json.

The file is read lazily:

  • the first call reads and parses package.json
  • the parsed result is cached
  • all next calls return the cached object

Install

With npm:

npm install @vyriy/package

With Yarn:

yarn add @vyriy/package

Usage

import { getPackage } from '@vyriy/package';

const package = getPackage();

console.log(package.name);
console.log(package.version);

You can also narrow the fields you need:

import { getPackage } from '@vyriy/package';

const { name, scripts } = getPackage();

console.log(name);
console.log(scripts?.build);

API

getPackage()

  • reads the root package.json file on first access
  • caches the parsed object
  • returns the cached Package object on later calls

Exported Types

  • Package