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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dtsroll

v1.4.1

Published

Bundle dts files

Readme

dtsroll is a CLI tool for bundling TypeScript declaration (.d.ts) files.

Why bundle .d.ts files?

  • Smaller distribution

    Tree-shaking removes unused code, keeping only what's needed and reducing the output size.

  • Bundle in private dependencies

    Inline types from private dependencies (e.g., monorepo packages) that aren't accessible to consumers.

  • Improve TS performance

    Flattens multiple files into one, reducing TypeScript's file resolution for type checking.

Install

npm install --save-dev dtsroll

Quick start

  1. Compile your TypeScript code with declaration (.d.ts) files

  2. Pass in the entry declaration file to dtsroll

    dtsroll --dry-run dist/index.d.ts

[!CAUTION] dtsroll is designed to run on compiled output so it modifies files in-place.

  • It will modify files you pass in, and files they import.
  • Only pass in backed up or generated files
  • Start with --dry-run
  1. If the changes look good, remove the --dry-run flag:

    dtsroll dist/index.d.ts

Recommended setup

Running dtsroll without specifying input files will auto-detect them from package.json.

Update your package.json to reference .d.ts files and include dtsroll in the build step:

 {
     "name": "my-package",
     "exports": {
+        "types": "./dist/index.d.ts",
         "default": "./dist/index.js"
     },
     "scripts": {
+        "build": "tsc && dtsroll"
     }
 }

Externalization

By default, dtsroll decides which dependencies to bundle or keep external by analyzing the package.json file. Packages in devDependencies are bundled, and packages in other dependency types are externalized.

When there is no package.json file, you can specify packages to externalize with the --external flag.

Handling @types packages

Some packages need separate @types/* packages for type definitions. In this setup, typically:

  • The main package is in dependencies.
  • The corresponding @types/* package is in devDependencies.

Because the main package is in dependencies, dtsroll externalizes it. However, consumers of your package won’t get the type definitions for it because the @types/* package is only in devDependencies.

To fix this, dtsroll will display a warning suggesting you move the @types/* package out of devDependencies.

CLI

Usage

dtsroll [-flags] [...entry dts files]

The default usage is to run dtsroll without any flags/arguments in a directory containing a package.json file. This allows the configuration to be inferred automatically.

--help, -h

Display usage instructions.

--dry-run, -d

Simulate the bundling process without modifying the disk and logs what would happen.

--external, -e

If there is no package.json file, you can specify package names to exclude from the bundle.

[!NOTE] This flag can only be used when there is no package.json. It's better to define dependencies appropriately in package.json instead of using this flag.

--conditions, -C

Provide resolution conditions to target specific entry points in dependencies, similar to Node’s --conditions.

Node.js API

import { dtsroll } from 'dtsroll'

await dtsroll(options as {

    /**
     * CWD to find the package.json in
     * @default process.cwd()
     */
    cwd?: string

    /**
     * Defaults to auto-detecting d.ts files from package.json
     */
    inputs?: string[]

    /**
     * Only used if there's no package.json
     * Defaults to auto-detecting dependencies from package.json
     */
    external?: string[]

    conditions?: string[]

    dryRun?: boolean
})

Vite plugin

Use it in conjunction with a plugin that generates the initial declaration files like vite-plugin-dts.

import { defineConfig } from 'vitest/config'
import dts from 'vite-plugin-dts'
import { dtsroll } from 'dtsroll/vite'

export default defineConfig({
    // ...
    plugins: [
        // ...
        dts(),
        dtsroll()
    ]
})

Related

pkgroll

For package bundling (along with dts bundling), check out pkgroll.