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

rolldown-plugin-dist-package

v1.0.0

Published

A Rolldown/Rollup/Vite/Tsdown/Tsup plugin to prepare package.json for distribution

Downloads

295

Readme

Rolldown compatibility Rollup compatibility Vite compatibility

dist-package — clean up package.json for publishing

A Rolldown / Rollup / Vite / tsup / tsdown plugin that automatically writes a cleaned package.json into your build output directory.

When you publish from a dist/ folder, your package.json contains paths like ./dist/index.js and fields like scripts or devDependencies that don't belong in the published package. This plugin fixes that at build time — no manual maintenance required.


What it does

  • Strips outDir prefixes./dist/index.js./index.js
  • Removes fields you don't want consumers to see (e.g. scripts, devDependencies)
  • Handles bin./dist/cli.jscli.js (Node.js expects bare paths for executables)
  • Copies extra files (README, LICENSE, CHANGELOG, …) into the output directory
  • Sets / overrides fields — e.g. force sideEffects: false or type: 'module'
  • Rewrites dependency versions — strip workspace: protocol, pin versions, etc.
  • Custom transform function — full control over the final package object
  • Validates the output — warns when required fields are missing
  • Works with Rolldown, Rollup, Vite, Tsdown, Tsup, …

Example

Let's say your package.json looks something like this — full of dist/ paths, scripts, and devDependencies that have no place in a published package. The plugin rewrites it and drops a clean copy into your output directory, ready to publish as-is. Everything is fully configurable:

  {
    "name": "my-lib",
    "version": "1.0.0",
-   "main": "./dist/index.js",
-   "types": "./dist/index.d.ts",
+   "main": "./index.js",
+   "types": "./index.d.ts",
    "exports": {
      ".": {
-       "import": "./dist/index.js",
-       "types": "./dist/index.d.ts"
+       "import": "./index.js",
+       "types": "./index.d.ts"
      }
    },
    "bin": {
-     "my-cli": "./dist/cli.js"
+     "my-cli": "cli.js"
    },
-   "scripts": { "build": "rolldown" },
-   "devDependencies": { "rolldown": "^1.0.0" }
+   "funding": "https://github.com/sponsors/you"
  }

Installation

npm install -D rolldown-plugin-dist-package
# yarn add -D rolldown-plugin-dist-package
# pnpm add -D rolldown-plugin-dist-package

Usage

🐶 Fun fact: This plugin builds and packages itself — it's eating its own dog food! Check out tsdown.config.ts for a real-world example.

// rolldown.config.ts, rollup.config.ts, tsdown.config.ts, ...
import { defineConfig } from 'rolldown';
import { distPackage } from 'rolldown-plugin-dist-package';

export default defineConfig({
  input: 'src/index.ts',
  output: { dir: 'dist' },
  plugins: [
    distPackage({
      // outDir: 'dist',         // auto-detected from bundler output options
      removeFields: ['scripts', 'devDependencies', 'lint-staged'],
      // bareFields: ['bin'],    // strip outDir prefix without adding './'
      // copyFiles: ['README.md', 'LICENSE', 'CHANGELOG.md'],
      // set: { sideEffects: false, type: 'module' },
      // rewriteDependencies: (_, v) => v.startsWith('workspace:') ? v.slice(10) || '*' : undefined,
      // transform: (pkg) => ({ ...pkg, funding: 'https://github.com/sponsors/you' }),
      // validate: true,         // warn if name or version is missing
    }),
  ],
});

Options

| Option | Type | Default | Description | | --------------------- | ------------------------------------ | ------------- | --------------------------------------------------------------------------------------------------- | | outDir | string | auto-detected | Output directory. If omitted, read from the bundler's own output options. | | removeFields | string[] | [] | Top-level fields to delete from the output. | | bareFields | string[] | ['bin'] | Fields whose path values are stripped of the outDir prefix but do not get the ./ prepended. | | copyFiles | string \| string[] | — | Files to copy from the project root into the output directory. | | set | Record<string, unknown> | — | Fields to add or override in the output package.json. | | rewriteDependencies | Record<string, string> \| Function | — | Rewrite versions in all dependency fields. See below. | | transform | (pkg) => pkg \| Promise<pkg> | — | Custom transform applied last, after all other options. | | validate | boolean \| string[] | false | Warn about missing fields. true checks name and version. |

rewriteDependencies

Object form — replace specific versions:

distPackage({
  rewriteDependencies: { 'my-local-pkg': '^1.2.0' },
});

Function form — strip Yarn workspace: protocol:

distPackage({
  rewriteDependencies: (_, version) =>
    version.startsWith('workspace:')
      ? version.slice('workspace:'.length) || '*'
      : undefined,
});

transform

Runs last, after all other options. Full control over the final package object:

distPackage({
  transform: (pkg) => ({
    ...pkg,
    // add fields, remove conditionally, etc.
    funding: 'https://github.com/sponsors/yourname',
  }),
});

⭐️ Support

If you find this project useful and you are brave enough consider making a donation for some 🍺 or 🍵 ;)

Your support helps maintain and improve this library! 🙏

🔒 Privacy & Security

This library does not collect, store, or transmit any user data.

I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.

📝 License

MIT © 2026 Lukas Bartak

See LICENSE for full details.


Built with ❤️ by Lukas Bartak

Powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺