Registry /
devops / rolldown-plugin-dist-package
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
muslnode 18–223 runs
build_error
glibcnode 18–223 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.fixExplicitly 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.fixUpdate 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.fixReview 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'
fixUse 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.
fixInstall 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.
fixUpdate Rollup to ^4.0.0 or ensure your Rollup version supports async hooks.
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.