Registry / devops / rolldown-plugin-dist-package

rolldown-plugin-dist-package

JSON →
library1.0.1jsnpmunverified

A Rolldown/Rollup/Vite/tsdown/tsup plugin that automatically cleans up package.json for distribution. It strips outDir prefixes from paths (e.g., ./dist/index.js → ./index.js), removes unwanted fields like scripts and devDependencies, handles bin paths, copies extra files, rewrites dependency versions (e.g., workspace: protocol), and allows custom transforms. Version 1.0.1 is current stable; the plugin is actively maintained and works across multiple bundlers. Key differentiator: no manual post-build editing of package.json. Ships TypeScript types.

npm install rolldown-plugin-dist-package
INSTALL
IMPORT
SIG · ROLLDOWN-PLUGIN-DI
R
rolldown-plugin-dist-package
devopsjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

distPackage
import { distPackage } from 'rolldown-plugin-dist-package'
import distPackage from 'rolldown-plugin-dist-package'
This package exports a named function, not a default export. Common mistake to use default import.
type DistPackageOptions
import type { DistPackageOptions } from 'rolldown-plugin-dist-package'
import { DistPackageOptions } from 'rolldown-plugin-dist-package'
Options type is exported as a type only; use 'import type' to avoid runtime errors in TypeScript.
distPackage (CommonJS)
const { distPackage } = require('rolldown-plugin-dist-package')
const distPackage = require('rolldown-plugin-dist-package')
In CommonJS, destructure the named export. Using require directly returns an object with distPackage property.

Configure rolldown-plugin-dist-package in a Rolldown config to strip dist/ prefixes, remove devDependencies, and set sideEffects: false.

import { defineConfig } from 'rolldown'; import { distPackage } from 'rolldown-plugin-dist-package'; export default defineConfig({ input: 'src/index.ts', output: { dir: 'dist' }, plugins: [ distPackage({ removeFields: ['scripts', 'devDependencies', 'lint-staged'], set: { sideEffects: false, type: 'module' }, }), ], });
Debug
Known issues
gotchaPlugin auto-detects outDir from bundler output options; if output.dir is not set or overridden, paths may not be cleaned correctly.
fix
Explicitly set the outDir option in the plugin configuration, e.g., distPackage({ outDir: 'dist' }).
affects: >=1.0.0
gotchaWhen using with Rollup <4 or Vite <7, ensure peer dependency version ranges are satisfied. The plugin requires rollup ^3.0.0 || ^4.0.0 and vite ^7.0.0 || ^8.0.0.
fix
Update your bundler to a supported version or pin a compatible plugin version.
affects: >=1.0.0
gotchaThe bin field handling strips outDir prefix but does NOT add './' prefix; Node.js expects bare paths for executables. If you need './' prefix for other fields, use bareFields option carefully.
fix
Review bin paths after build; they should be without './' (e.g., 'cli.js' not './cli.js').
affects: >=1.0.0
deprecatedNo deprecated features as of version 1.0.1.
Errors
Common errors & fixes
TypeError: distPackage is not a function
Using default import instead of named import: import distPackage from 'rolldown-plugin-dist-package'
fix
Use named import: import { distPackage } from 'rolldown-plugin-dist-package'
Error: Cannot find module 'rolldown-plugin-dist-package' or its corresponding type declarations.
Package not installed or TypeScript module resolution not configured for ESM.
fix
Install the package: npm install -D rolldown-plugin-dist-package; ensure tsconfig.json has 'moduleResolution': 'node16' or 'bundler'.
RollupError: The plugin 'dist-package' hook 'generateBundle' returned a promise that was not awaited.
The plugin's generateBundle hook may be async and not properly handled if used in an older Rollup version.
fix
Update Rollup to ^4.0.0 or ensure your Rollup version supports async hooks.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
rolldownoptionalPeer dependency for Rolldown integration. Must be installed if using Rolldown as bundler.
rollupoptionalPeer dependency for Rollup integration. Must be installed if using Rollup as bundler.
viteoptionalPeer dependency for Vite integration. Must be installed if using Vite as bundler.
Agent activity
5 hits · last 30 days
node
4
Resources
rolldown-plugin-dist-package — npm install rolldown-plugin-dist-package · libregistry