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

ts-publish-helper

v3.0.5

Published

Deterministic TypeScript publishing for ESM, CJS, and types

Readme

ts-publish-helper

Deterministic TypeScript publishing for ESM, CJS, and type-safe consumers.

ts-publish exists to solve one problem properly:

If your package builds successfully with ts-publish, it will work in Node (ESM + CJS) and TypeScript consumers — without broken imports or missing types.

This tool is opinionated by design. It favors correctness over flexibility.


Requirements

  • Node.js: >18
  • TypeScript: Installed in your project
  • Library packages only (not apps)

Installation

Install as a dev dependency:

npm install --save-dev ts-publish-helper

Or use without installing:

npx ts-publish

Quick Start

1. Initialize config

From your project root:

npx ts-publish init

This creates:

ts-publish.config.json

Default config:

{
  "entry": "src/index.ts",
  "outDir": "dist",
  "formats": ["esm", "cjs"],
  "types": true,
  "sourcemap": true,
  "target": "node18",
  "strict": true
}

Do not rename this file.


2. Build your package

npx ts-publish build

This will:

  1. Clean the output directory
  2. Build ESM and CJS bundles
  3. Generate .d.ts files
  4. Generate a production package.json with correct exports

Output structure:

dist/
├── esm/index.js
├── cjs/index.cjs
├── types/index.d.ts
└── package.json

If any step fails, the build fails. No partial output.


3. Verify (coming next)

npx ts-publish verify

This will simulate real consumers (ESM, CJS, TypeScript) and fail if imports or types break.


Configuration

All configuration lives in ts-publish.config.json.

Options

| Field | Type | Description | | ----------- | -------------------- | -------------------------------- | | entry | string | Entry file for your library | | outDir | string | Output directory | | formats | ("esm" \| "cjs")[] | Module formats to build | | types | boolean | Generate .d.ts files | | sourcemap | boolean | Emit source maps | | target | string | Node target (node18, node20) | | strict | boolean | Enforce strict type generation |

Invalid config fails fast with clear error codes.


Generated package.json

ts-publish owns the published package.json.

Example:

{
  "type": "module",
  "main": "./cjs/index.cjs",
  "module": "./esm/index.js",
  "types": "./types/index.d.ts",
  "exports": {
    ".": {
      "types": "./types/index.d.ts",
      "import": "./esm/index.js",
      "require": "./cjs/index.cjs"
    }
  }
}

This prevents:

  • dual-package hazards
  • broken default imports
  • missing type resolution
  • runtime vs type mismatches

What ts-publish Does NOT Do

By design, v1 does not support:

  • React / Vue / browser bundling
  • CSS or asset pipelines
  • Monorepos
  • Native addons
  • Custom bundler plugins

If you need those, this tool is not for you (yet).


Error Handling

All failures are explicit and actionable.

Example:

TP030: Type generation failed. Fix TypeScript errors.

No silent failures. No ignored warnings.


Typical Workflow

# once
npx ts-publish init

# every release
npx ts-publish build
npm publish dist

Yes — you publish from dist/.


Status

  • Pre-alpha
  • APIs may change
  • Focused on correctness first

Philosophy

Most publishing tools optimize for convenience. ts-publish optimizes for truth.

If your library builds here, your users won’t suffer.