Babel Plugin Eliminator banner
egoist egoist

Babel Plugin Eliminator

Development community

Description

A babel plugin to remove specific named exports and more

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

babel-plugin-eliminator

What is this?

This is a babel plugin for removing specific named exports in your JavaScript code, this is how Next.js implements `getServerSideProps` and `getStaticProps`, it essentially removes thoses exports and referenced variables.

Install

npm i babel-plugin-eliminator

Usage

Removing specific named exports

Options:

{
  "plugins": [
    ["eliminator", {"namedExports": ["foo"]}]
  ]
}

Input:

import pkg from 'some-pkg'

const someVariable = 'some-string'

export const foo = () => {
    return pkg(someVariable)
}

Output:

export var foo = 1

Options

type PluginState = {
  refs: Set>
  opts: PluginOpts
  /** Removed named exports */
  removedNamedExports: Set
}

type PluginOpts = {
  /** Removing specific named exports */
  namedExports?: string[]
  /** Called at the end of transpiling */
  done?: (state: PluginState) => void
}

Credits

This plugin is essentially a fork of [next.js/next-ssg-transform](https://github.com/vercel/next.js/blob/574fe0b582d5cc1b13663121fd47a3d82deaaa17/packages/next/build/babel/plugins/next-ssg-transform.ts).

License

MIT © [EGOIST](https://github.com/sponsors/egoist)