{"id":21886,"library":"rolldown-plugin-dist-package","title":"dist-package","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/bartholomej/rolldown-plugin-dist-package","tags":["javascript","rollup","plugin","rolldown","vite","tsdown","tsup","rolldown-plugin","rollup-plugin","typescript"],"install":[{"cmd":"npm install rolldown-plugin-dist-package","lang":"bash","label":"npm"},{"cmd":"yarn add rolldown-plugin-dist-package","lang":"bash","label":"yarn"},{"cmd":"pnpm add rolldown-plugin-dist-package","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Rolldown integration. Must be installed if using Rolldown as bundler.","package":"rolldown","optional":true},{"reason":"Peer dependency for Rollup integration. Must be installed if using Rollup as bundler.","package":"rollup","optional":true},{"reason":"Peer dependency for Vite integration. Must be installed if using Vite as bundler.","package":"vite","optional":true}],"imports":[{"note":"This package exports a named function, not a default export. Common mistake to use default import.","wrong":"import distPackage from 'rolldown-plugin-dist-package'","symbol":"distPackage","correct":"import { distPackage } from 'rolldown-plugin-dist-package'"},{"note":"Options type is exported as a type only; use 'import type' to avoid runtime errors in TypeScript.","wrong":"import { DistPackageOptions } from 'rolldown-plugin-dist-package'","symbol":"type DistPackageOptions","correct":"import type { DistPackageOptions } from 'rolldown-plugin-dist-package'"},{"note":"In CommonJS, destructure the named export. Using require directly returns an object with distPackage property.","wrong":"const distPackage = require('rolldown-plugin-dist-package')","symbol":"distPackage (CommonJS)","correct":"const { distPackage } = require('rolldown-plugin-dist-package')"}],"quickstart":{"code":"import { defineConfig } from 'rolldown';\nimport { distPackage } from 'rolldown-plugin-dist-package';\n\nexport default defineConfig({\n  input: 'src/index.ts',\n  output: { dir: 'dist' },\n  plugins: [\n    distPackage({\n      removeFields: ['scripts', 'devDependencies', 'lint-staged'],\n      set: { sideEffects: false, type: 'module' },\n    }),\n  ],\n});","lang":"typescript","description":"Configure rolldown-plugin-dist-package in a Rolldown config to strip dist/ prefixes, remove devDependencies, and set sideEffects: false."},"warnings":[{"fix":"Explicitly set the outDir option in the plugin configuration, e.g., distPackage({ outDir: 'dist' }).","message":"Plugin auto-detects outDir from bundler output options; if output.dir is not set or overridden, paths may not be cleaned correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update your bundler to a supported version or pin a compatible plugin version.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review bin paths after build; they should be without './' (e.g., 'cli.js' not './cli.js').","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"","message":"No deprecated features as of version 1.0.1.","severity":"deprecated","affected_versions":""}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use named import: import { distPackage } from 'rolldown-plugin-dist-package'","cause":"Using default import instead of named import: import distPackage from 'rolldown-plugin-dist-package'","error":"TypeError: distPackage is not a function"},{"fix":"Install the package: npm install -D rolldown-plugin-dist-package; ensure tsconfig.json has 'moduleResolution': 'node16' or 'bundler'.","cause":"Package not installed or TypeScript module resolution not configured for ESM.","error":"Error: Cannot find module 'rolldown-plugin-dist-package' or its corresponding type declarations."},{"fix":"Update Rollup to ^4.0.0 or ensure your Rollup version supports async hooks.","cause":"The plugin's generateBundle hook may be async and not properly handled if used in an older Rollup version.","error":"RollupError: The plugin 'dist-package' hook 'generateBundle' returned a promise that was not awaited.","affected_versions":"rollup <4.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}