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

@papit/bundle-ts

v0.0.3

Published

Rolls a package's TypeScript declarations up into one .d.ts file per entry point, and skips the work when no source file has changed since the last run.

Readme

@papit/bundle-ts

Rolls a package's TypeScript declarations up into one .d.ts file per entry point, and skips the work when no source file has changed since the last run.

Logo


Type Tests NPM version


Installation

npm install @papit/bundle-ts typescript

typescript is a peer dependency. Most packages never call this directly: npx @papit/build runs it for every package whose tsconfig has declaration: true.

Usage

Roll up the declarations of the package in the current folder:

import { tsBundle } from "@papit/bundle-ts";

const result = await tsBundle(new Set(), process.cwd());

if (result === "skipped") console.log("nothing changed");
else if (result) result.forEach(e => console.error(e.input, e.logs));

With package.json "types": "./lib/bundle.d.ts" and src/index.ts exporting hello, lib/bundle.d.ts ends up as:

export declare const hello: (n: string) => string;

export { }

Build explicit entries instead of the ones in package.json:

await tsBundle(new Set(["force"]), process.cwd(), {
    entryPointsArray: [{ input: "/abs/pkg/src/index.ts", output: "/abs/pkg/lib/bundle.d.ts" }],
});

API

tsBundle

function tsBundle(
    args: { has(key: string): boolean },
    location: string,
    options?: Partial<{
        tsconfig: ts.ParsedCommandLine,
        entryPoints: ReturnType<typeof getEntryPoints>,
        entryPointsArray: { input: string, output: string, name?: string }[],
        packageJSON: PackageJson,
    }>,
): Promise<"skipped" | Array<{ input: string, logs: string[] }> | undefined>

Emits declarations for every file under src/ into .temp/ts-bundle, then rolls each types entry up into its output file. A .ts or .tsx source maps to its emitted .d.ts. Resolves "skipped" when nothing changed and every output exists, the entries that failed or logged warnings, or undefined on success. On a TypeScript emit error (with noEmitOnError, any type error) it prints the diagnostics and resolves every entry with them as logs.

Entry points come from package.json through getEntryPoints in @papit/bundle-js, the same way the JavaScript bundle finds them. options lets a caller skip reading them again.

Every entry except the main one (bundle) also keeps the package's own name external, so an extra entry like ./react that imports @papit/x gets import { X } from "@papit/x" instead of a copy of the class, which wouldn't be assignable to the real one.

API Extractor leaves module augmentations out of a rollup, so the entry file's own top-level declare module "x" { ... } and declare global { ... } blocks are copied into its .d.ts afterwards. That's how a React wrapper's JSX.IntrinsicElements reach consumers.

Flags

The args passed in are checked for these keys:

| Flag | Effect | | --- | --- | | force, f | build even when nothing changed | | dev | also emit declaration maps | | prod | use tsconfig.prod.json when it exists |

Design notes

  • The roll-up currently runs on @microsoft/api-extractor. The package exists to replace it with a from-scratch bundler, so the dependency is expected to go away.
  • Change detection shares hasChanged with @papit/bundle-js, stored as .temp/mstime.papit-bundle-ts.json.

License

Licensed under the @Papit License 1.0 Copyright (c) 2024 Henry Pap (@onkelhoy)

Key points

  • ✅ Free to use in commercial projects
  • ✅ Free to modify and distribute
  • ✅ Attribution required
  • ❌ Cannot resell the component itself as a standalone product

See the LICENSE file for full details.

Related

  • @papit/build - runs this and @papit/bundle-js for every package
  • @papit/bundle-js - the matching JavaScript bundler, and where entry points are resolved