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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rollup-plugin-code-raker

v1.0.2

Published

A Rollup plugin that rakes your bundle to remove dead leaves.

Readme

NPM Version Rollup 4.0 Vite 5.0 MIT License

rollup-plugin-code-raker

A Rollup/Vite plugin that rakes your bundle to remove dead leaves.

Features

  • Removes leftover comments, console.* calls and debugger statements from your bundle.
  • Does not come in the way of treeshaking: remaining function annotations are removed after Rollup/Vite did their magic.
  • Fully configurable.
  • Comes with sensible defaults for both application and library bundling.

Requirements

This plugin requires Rollup 4 or later or Vite 5 or later.

Usage

Install the plugin using your favorite package manager:

npm install --save-dev rollup-plugin-code-raker

Then import the plugin in your rollup.config.js/vite.config.js:

import rake from 'rollup-plugin-code-raker'

export default {
    ...
    plugins: [
        rake(/* options */)
    ]
}

Options

code-raker uses presets to decide what to remove from code.

  • The default preset is a "kill'em all" preset that blindly removes all comments (including licensing and documentation comments), all console.* calls and debugger statements.
  • The application preset preserves licensing comments and console.info, console.warn, console.error and console.debug calls.
  • The library preset preserves licensing and documentation comments.

[!NOTE]

  • Licensing comments are block comments that start with /*! followed by a space or a newline, or documentation comments that contain the @license tag.
  • Documentation, or JsDoc/TsDoc comments, are block comments that start with /** followed by a space or a newline.
  • Annotations are block comments that contain one of these strings: #__PURE__, @__PURE__, #__NO_SIDE_EFFECTS__, @__NO_SIDE_EFFECTS__. See https://rollupjs.org/configuration-options/#treeshake-annotations for more info.

All options are optional.

export interface Options {
    /**
     * The name of a preset to use or extend upon.
     *
     * Default: undefined.
     */
    preset?: 'library' | 'application'

    /**
     * Set to `true` to remove all comments, `false` to remove none, or an object
     * to only remove select comments.
     *
     * Default depends on the selected preset:
     * - default: remove all comments.
     * - library: preserve licensing and JsDoc/TsDoc comments, remove everything else.
     * - application: preserve licensing comments, remove everything else.
     *
     * Note that this setting only targets "meaningful" comments; common block comments (`/*`)
     * and line comments (`//`) are always removed.
     */
    comments?: boolean | {
        /**
         * Whether to remove licensing comments.
         */
        licenses?: boolean | ((comment: string) => boolean)

        /**
         * Whether to remove documentation comments.
         */
        docs?: boolean | ((comment: string) => boolean)

        /**
         * Whether to remove annotations.
         */
        annotations?: boolean
    }

    /**
     * Set to `true` to remove all `console` calls, `false` to remove none, or a callback
     * or an object to only remove select `console` calls.
     *
     * Default depends on the selected preset:
     * - default: remove all `console` methods calls.
     * - library: remove all `console` methods calls.
     * - application: preserve `info`, `warn`, `error` and `debug` methods calls,
     *   remove all others.
     */
    console?:  boolean | ((method: string, statement: string) => boolean) | {
        /**
         * An array of console methods names to remove.
         */
        include?: string[]
        /**
         * An array of console methods names to preserve.
         */
        exclude?: string[]
    }

    /**
     * Set to `true` to remove `debugger` statements, or `false` to leave them in code.
     *
     * Default: `true` in all presets.
     */
    debugger?: boolean
}

License

MIT.