Registry / devops / rollup-plugin-code-raker

rollup-plugin-code-raker

JSON →
library2.0.1jsnpmunverified

A Rollup/Vite plugin that removes comments, console.* calls, and debugger statements from bundles after tree-shaking. Current stable version is 2.0.1, requiring Rollup >=4.0.0 or Vite >=5.0.0. It offers presets for application and library bundling with sensible defaults: the default preset removes all comments and console calls; the application preset preserves licensing comments and console.log/info/warn/error; the library preset preserves licensing and JSDoc comments. Fully configurable via options object, allowing fine-grained control over which comments and console methods to remove.

npm install rollup-plugin-code-raker
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-CODE
R
rollup-plugin-code-raker
devopsjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

codeRaker
import codeRaker from 'rollup-plugin-code-raker'
import { codeRaker } from 'rollup-plugin-code-raker'
Default export; named import does not exist.
codeRaker
const codeRaker = require('rollup-plugin-code-raker').default
const codeRaker = require('rollup-plugin-code-raker')
CommonJS requires .default access due to ESM-first package.
codeRaker
import codeRaker from 'rollup-plugin-code-raker'
import * as codeRaker from 'rollup-plugin-code-raker'
Namespace import used as default works but not idiomatic; prefer default import.

Example Rollup config using code-raker with application preset, removing only debug/trace console calls and preserving licenses but removing docs.

// rollup.config.js import codeRaker from 'rollup-plugin-code-raker' export default { input: 'src/index.js', plugins: [ codeRaker({ preset: 'application', console: { include: ['debug', 'trace'] }, comments: { docs: true, licenses: false } }) ], output: { file: 'dist/bundle.js', format: 'es' } }
Debug
Known issues
breakingVersion 2.0.0 dropped support for Rollup <4 and Vite <5. Ensure your build tools are updated.
fix
Upgrade Rollup to >=4.0.0 or Vite to >=5.0.0.
affects: >=2.0.0
gotchaThe plugin runs after tree-shaking, so annotations like /*#__PURE__*/ are preserved by default. If you set 'comments.annotations: true' you may break tree-shaking.
fix
Avoid removing annotations unless you understand the impact on tree-shaking.
affects: *
deprecatedThe 'preset' option is not deprecated, but note that the 'default' preset is verbose; use 'application' or 'library' for more sensible defaults.
fix
Use preset: 'application' or 'library' instead of relying on defaults.
affects: *
gotchaComments that are not block comments (e.g., line comments //) are always removed regardless of settings.
fix
If you need to preserve line comments, consider using a different plugin or preprocessing.
affects: *
breakingVersion 1.0.0 used a different API with options like 'removeComments' and 'removeConsole'. Migration required.
fix
Update to v2 and adjust options to the new interface (preset, comments, console).
affects: <2.0.0
Errors
Common errors & fixes
Cannot find module 'rollup-plugin-code-raker'
Package not installed or missing from devDependencies.
fix
Run 'npm install --save-dev rollup-plugin-code-raker'.
The requested module 'rollup-plugin-code-raker' does not provide an export named 'default'
Using named import '{ codeRaker }' instead of default import.
fix
Use 'import codeRaker from 'rollup-plugin-code-raker''.
rollup-plugin-code-raker: Rollup version must be >=4.0.0, but found 3.x
Incompatible Rollup version.
fix
Upgrade Rollup to >=4.0.0 or use an older version of the plugin (<=1.x).
TypeError: codeRaker is not a function
Incorrect import (e.g., using require without .default in CJS).
fix
Use 'const codeRaker = require('rollup-plugin-code-raker').default'.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
rollupoptionalPeer dependency; the plugin requires Rollup ^4.0.0 or Vite ^5.0.0.
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-code-raker — npm install rollup-plugin-code-raker · libregistry