npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a35hie/ts-pkg

v0.3.1

Published

TypeScript-based package.json with magical features

Readme

TS Package Config

✨ TypeScript-based package.json with magical features.

Define your package configuration in TypeScript with type safety, auto-complete, and powerful features like automatic version resolution, script presets, config inheritance, and conditional configuration.

IMPORTANT: It is imperative to read this page before using this package.

Features

  • Auto-resolve versions – List package names, latest versions are fetched automatically
  • Script presets – Common scripts for TypeScript, React, testing, etc.
  • Config inheritance – Extend from base configurations
  • Conditional config – Different settings based on environment, CI, platform
  • Full TypeScript - Type-safe with autocomplete

Installation

bun add -D @a35hie/ts-pkg
# or
npm add -D @a35hie/ts-pkg
# or whatever you prefer

Usage

Create a package.ts file:

import { definePackage } from '@a35hie/ts-pkg'

export default definePackage({
  name: 'my-awesome-package',
  version: '1.0.0',
  description: 'An awesome package',
  type: 'module',

  // ✨ Script presets - auto-generates common scripts
  scriptPresets: ['typescript', 'testing', 'prettier'],

  // Add or override scripts
  scripts: {
    dev: 'tsx watch src/index.ts',
  },

  // ✨ Just list packages - versions resolved automatically!
  dependencies: [
    'lodash', // → "lodash": "^4.17.23"
    'zod', // → "zod": "^4.3.6"
  ],

  devDependencies: [
    'typescript',
    'vitest',
    '@types/lodash@^4', // Can specify version constraints
  ],

  // ✨ Conditional configuration
  conditions: [
    {
      when: { env: 'production' },
      set: { private: false },
    },
    {
      when: { ci: true },
      set: {
        scripts: { test: 'vitest run --coverage' },
      },
    },
  ],
})

Generate your package.json:

ts-pkg
# or
ts-pkg package.ts package.json

Syncing Dependencies

When you install packages with bun add or npm install, sync them back to your config:

# After installing packages
bun add lodash axios
ts-pkg sync

# Or specify paths
ts-pkg sync package.ts package.json

This keeps your package.ts as the source of truth while still allowing quick installs via your package manager.

Script Presets

| Preset | Scripts | | ------------ | ------------------------------------- | | typescript | build, build:watch, typecheck | | react | dev, build, preview | | node | start, dev, build | | testing | test, test:watch, test:coverage | | prettier | format, format:check | | eslint | lint, lint:fix |

Config Inheritance

Extend from a base config:

// base.config.ts
export default definePackage({
  author: 'Your Name',
  license: 'MIT',
  scriptPresets: ['typescript', 'prettier'],
  devDependencies: ['typescript', 'prettier'],
})

// package.ts
export default definePackage({
  extends: './base.config.ts',
  name: 'my-package',
  dependencies: ['lodash'],
})

Conditional Configuration

Apply different settings based on the environment:

conditions: [
  {
    when: { env: 'production' },
    set: { private: false },
  },
  {
    when: { platform: 'win32' },
    set: {
      scripts: { build: 'tsc && copy assets dist' },
    },
  },
  {
    when: { ci: true },
    set: {
      scripts: { test: 'vitest run --reporter=junit' },
    },
  },
]

API

definePackage(config: PackageConfig): PackageConfig

Type-safe helper for defining your configuration.

createPackageJson(config: PackageConfig, options?): Promise<string>

Generate package.json content as a string.

writePackageJson(config: PackageConfig, options?): Promise<void>

Generate and write package.json to disk.