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

@savvy-web/rslib-builder

v0.7.0

Published

RSlib-based build system for Node.js libraries with automatic package.json transformation, TypeScript declaration bundling, and multi-target support

Readme

@savvy-web/rslib-builder

npm version License: MIT Node.js Version

Build modern ESM Node.js libraries with minimal configuration. Handles TypeScript declarations, package.json transformations, and PNPM workspace resolution automatically.

Building TypeScript packages for npm involves repetitive setup: configuring bundlers, generating declarations, transforming package.json exports, and resolving workspace references. rslib-builder handles these tasks so you can focus on your code.

Features

  • Zero Config - Auto-detects entry points from package.json exports
  • Fast Type Generation - Uses tsgo (native TypeScript) for 10-100x faster declaration generation
  • Bundled Declarations - Rolls up TypeScript types via API Extractor for cleaner public APIs
  • Multi-Target Builds - Separate dev (source maps) and npm (optimized) outputs
  • PNPM Integration - Automatically resolves catalog: and workspace: references
  • Package.json Transform - Converts .ts exports to .js, generates files array, removes dev-only fields
  • TSDoc Validation - Pre-build TSDoc validation with automatic public API discovery
  • API Model Generation - Optional API model and resolved tsconfig output for documentation tooling
  • Extensible - Add custom RSlib/Rsbuild plugins for advanced use cases

Prerequisites

  • Node.js 24.x or later
  • pnpm 10.x or later
  • TypeScript 5.9.x or later

Installation

pnpm add -D @savvy-web/rslib-builder

Peer Dependencies

Install the required peer dependencies:

pnpm add -D @rslib/core @microsoft/api-extractor @typescript/native-preview

Quick Start

Extend the provided tsconfig for optimal settings:

// tsconfig.json
{
  "extends": "@savvy-web/rslib-builder/tsconfig/ecma/lib.json",
  "compilerOptions": {
    "outDir": "dist"
  }
}

Create an rslib.config.ts in your project root:

import { NodeLibraryBuilder } from '@savvy-web/rslib-builder';

export default NodeLibraryBuilder.create({
  externals: ['@rslib/core'],
  transform({ pkg, target }) {
    if (target === 'npm') {
      delete pkg.devDependencies;
    }
    return pkg;
  },
});

Add scripts to your package.json:

{
  "scripts": {
    "build": "rslib build --env-mode dev",
    "build:npm": "rslib build --env-mode npm"
  }
}

Build Targets

Two build targets available via --env-mode:

  • dev - Unminified with source maps for local development
  • npm - Optimized for npm publishing (Node.js runtime)
rslib build --env-mode dev
rslib build --env-mode npm

API Overview

The package exports a main builder and several plugins:

| Export | Description | | ---------------------------- | --------------------------------------------- | | NodeLibraryBuilder | Main API for building Node.js libraries | | AutoEntryPlugin | Auto-extracts entry points from package.json | | DtsPlugin | Generates TypeScript declarations with tsgo | | PackageJsonTransformPlugin | Transforms package.json for distribution | | FilesArrayPlugin | Generates files array for npm publishing | | TsDocLintPlugin | Validates TSDoc comments before build | | TsDocConfigBuilder | Utility for TSDoc configuration | | ImportGraph | Traces TypeScript imports for file discovery |

See Configuration for all options.

Plugins

The builder includes several built-in plugins:

  1. TsDocLintPlugin - Validates TSDoc comments before build (optional)
  2. AutoEntryPlugin - Auto-extracts entry points from package.json exports
  3. DtsPlugin - Generates TypeScript declarations with tsgo/API Extractor
  4. PackageJsonTransformPlugin - Transforms package.json for targets
  5. FilesArrayPlugin - Generates files array, excludes source maps

How It Works

The builder automatically transforms your source package.json for distribution:

  • Entry Detection - Extracts entry points from package.json exports
  • Export Transformation - Converts .ts paths to .js in exports field
  • Bin Transformation - Converts bin entries from .ts to .js scripts
  • PNPM Resolution - Resolves catalog: and workspace: to real versions
  • Files Generation - Creates accurate files array for npm publishing
  • Declaration Bundling - Uses tsgo for fast generation and API Extractor for bundling

Documentation

For detailed documentation, see the docs/ directory:

Examples

This package builds itself using its own NodeLibraryBuilder. See rslib.config.ts for a production example demonstrating:

  • API model generation for documentation tooling
  • External package configuration
  • Custom package.json transformations
  • Copy patterns for static files

Programmatic Usage

Use ImportGraph to discover all files reachable from your package exports:

import { ImportGraph } from '@savvy-web/rslib-builder';

const result = ImportGraph.fromPackageExports('./package.json', {
  rootDir: process.cwd(),
});

console.log('Public API files:', result.files);
console.log('Entry points:', result.entries);

See Configuration for more examples.

Support

This software is provided as-is under the MIT License with no warranty or support guarantees. While we welcome bug reports and feature requests via GitHub Issues, we cannot guarantee response times or resolution.

For security vulnerabilities, please see SECURITY.md.

Links

Contributing

Contributions welcome! See CONTRIBUTING.md for setup and guidelines.

License

MIT