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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@startupjs/babel-plugin-eliminator

v0.61.0

Published

Cut out specific named exports or do the opposite -- only keep the ones you specify

Readme

@startupjs/babel-plugin-eliminator

Cut out specific named exports or do the opposite -- only keep the ones you specify

Install

npm i @startupjs/babel-plugin-eliminator

Usage

Removing specific named exports

Options:

{
  "plugins": [
    ["@startupjs/babel-plugin-eliminator", {"removeExports": ["foo", "default"]}]
  ]
}

Input:

import usedByFoo from 'used-by-foo'
import usedByDefault from 'used-by-default'
import usedByBar from 'used-by-bar'

const varInFoo = 'var-in-foo'
const varInDefault = 'var-in-default'
const varInBar = 'var-in-bar'

export const foo = () => {
  return usedByFoo(varInFoo)
}

export default () => {
  return usedByDefault(varInDefault)
}

export function bar () {
  return usedByBar(varInBar)
}

Output:

import usedByBar from 'used-by-bar'

const varInBar = 'var-in-bar'

export var foo = 1

export default 1

export function bar () {
  return usedByBar(varInBar)
}

Keep only the specified exports

Options:

{
  "plugins": [
    ["@startupjs/babel-plugin-eliminator", {"keepExports": ["foo", "default"]}]
  ]
}

Input:

import usedByFoo from 'used-by-foo'
import usedByDefault from 'used-by-default'
import usedByBar from 'used-by-bar'

const varInFoo = 'var-in-foo'
const varInDefault = 'var-in-default'
const varInBar = 'var-in-bar'

export const foo = () => {
  return usedByFoo(varInFoo)
}

export default () => {
  return usedByDefault(varInDefault)
}

export function bar () {
  return usedByBar(varInBar)
}

Output:

import usedByFoo from 'used-by-foo'
import usedByDefault from 'used-by-default'

const varInFoo = 'var-in-foo'
const varInDefault = 'var-in-default'

export const foo = () => {
  return usedByFoo(varInFoo)
}

export default () => {
  return usedByDefault(varInDefault)
}

export var bar = 1

Removing Keys within Objects of Magic Function Calls

This feature in the @startupjs/babel-plugin-eliminator allows selective retention or removal of keys within objects passed to specific functions. It's particularly useful for customizing the shape of large objects or configurations passed to 'magic' functions.

To utilize this feature, configure the keepObjectKeysOfFunction option in your Babel plugin settings. This allows you to specify the functions and the particular keys within their object arguments that you want to keep.

Options:

{
  "plugins": [
    [
      "@startupjs/babel-plugin-eliminator",
      {
        "keepObjectKeysOfFunction": {
          "createProject": {
            "magicImports": ["startupjs/registry", "@startupjs/registry"],
            "targetObjectJsonPath": "$.plugins.*",
            "ensureOnlyKeys": ["client", "isomorphic", "server", "build"],
            "keepKeys": ["client", "isomorphic"]
          }
        }
      }
    ]
  ]
}

In this configuration:

  • createProject is the function where object key manipulation occurs.
  • magicImports specifies the module imports that identify createProject as a magic function.
  • targetObjectJsonPath (optional) is the JSON path to the target object path within the function's first argument. By default the top-level object itself is used.
  • keepKeys specifies which keys in the object should be retained in the output.
  • ensureOnlyKeys (optional) lists all possible keys in the object, providing a way to validate the object structure.

Input

import { createProject } from 'startupjs/registry'

// ...other imports...

export default createProject({
  plugins: {
    'serve-static-promo': {
      client: {
        redirectUrl: '/promo',
        // ...other client properties...
      },
      server: {
        // ...server properties...
      },
      build: {
        // ...build properties...
      },
      isomorphic: {
        // ...isomorphic properties...
      }
    },
    permissions: {
      client: {
        // ...permissions client properties...
      },
      server: {
        // ...permissions server properties...
      },
      build: {
        // ...permissions build properties...
      },
      isomorphic: {
        // ...permissions isomorphic properties...
      }
    }
  }
})

Output

import { createProject } from "startupjs/registry";

// ...other imports...

export default createProject({
  plugins: {
    "serve-static-promo": {
      client: {
        redirectUrl: "/promo",
        // ...retained client properties...
      },
      isomorphic: {
        // ...retained isomorphic properties...
      }
    },
    permissions: {
      client: {
        // ...retained permissions client properties...
      },
      isomorphic: {
        // ...retained permissions isomorphic properties...
      }
    }
  }
});

Options

type PluginOpts = {
  /** Removing specific named exports (use 'default' for default export) */
  removeExports?: string[],
  /** Keep only these exports (use 'default' for default export) */
  keepExports?: string[],
  /**
   * Specify keys within objects of specific function calls to be kept.
   * Applies to the objects passed as arguments to the specified functions.
   */
  keepObjectKeysOfFunction?: {
    [functionName: string]: {
      /** Array of module import paths which identify the function as a 'magic' function */
      magicImports: string[],
      /** JSON path to the object within the function where the keys are located */
      targetObjectJsonPath?: string,
      /** List of all possible keys within the object (for validation purposes) */
      ensureOnlyKeys?: string[],
      /** Array of keys that should be kept in the final output */
      keepKeys: string[]
    }
  }
}

Credits

This plugin is a fork of egoist/babel-plugin-eliminator with the following changes:

  1. refactor to pure JS
  2. rename namedExports to removeExports
  3. add an alternative keepExports option. If specified, only these ones are gonna be kept and all other exports will be removed
  4. handle default export
  5. add feature to remove object keys within magic function calls

License

MIT