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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nathantreid/babel-plugin-remove-code

v0.0.7-rc.1

Published

Remove any code from your project.

Downloads

2

Readme

babel-plugin-remove-code

Remove any code from your project.

Build Status

Supported removals

Example

Debugger

In

// Debugger...
debugger;

Out

// Debugger...

Var

In

const stripA = 'foo';
const keepA = 'foo';
const stripBPattern = 'foo';
const keepBPattern = 'foo';

let stripC;
let keepC;
let stripFPattern;
let keepFPattern;

stripC = 'foo';
stripC = {};
keepC = 'foo';
stripFPattern = 'foo';
stripFPattern = {};
keepFPattern = 'foo';

export const stripG = {};
export const keepG = {};
export const stripHPattern = {};
export const keepHPattern = {};

export { stripD };
export { keepD };
export { stripIPattern };
export { keepIPattern };

export default { stripA, keepA, stripBPattern, keepBPattern };

console.log(stripA);
console.log(keepA);
console.log(stripBPattern);
console.log(keepBPattern);

if (stripA === 'foo') {}
if (keepA === 'foo') {}
if (stripBPattern === 'foo') {}
if (keepBPattern === 'foo') {}

if (stripC === 'foo' && keepC === 'foo') {}
if (stripFPattern === 'foo' && keepFPattern === 'foo') {}

keepA = stripA;
keepB = stripB && keepB;

Out


const keepA = 'foo';

const keepBPattern = 'foo';

let keepC;

let keepFPattern;

keepC = 'foo';

keepFPattern = 'foo';

export const keepG = {};

export const keepHPattern = {};

export { keepD };

export { keepIPattern };

export default { keepA, keepBPattern };

console.log(keepA);

console.log(keepBPattern);

if (keepA === 'foo') {}

if (keepBPattern === 'foo') {}

if (keepC === 'foo') {}
if (keepFPattern === 'foo') {}

keepB = keepB;

Export

In

export const stripA = {};
export const keepA = {};
export const stripBPattern = {};
export const keepBPattern = {};

export { stripC };
export { keepC };
export { stripDPattern };
export { keepDPattern };

export default { stripE, keepE, stripFPattern, keepFPattern };

Out


export const keepA = {};

export const keepBPattern = {};

export { keepC };

export { keepDPattern };

export default { keepE, keepFPattern };

Import

In

import { fsA } from "stripA";
import { fkA } from "keepA";
import { fsB } from "stripBPattern";
import { fkB } from "keepBPattern";
fsB('foo');
fkB('foo');

import fsC from "stripC";
import fkC from "keepC";
console.log(fsC);
console.log(fkC);

import fsD from "stripDPattern";
import fkD from "keepDPattern";
const fsDVar = fsD;
const fkDVar = fkD;

import { fsEProxy as fsE } from "stripE";
import { fkEProxy as fkE } from "keepE";
import { fsFProxy as fsF } from "stripFPattern";
import { fkFProxy as fkF } from "keepFPattern";

import "stripG";
import "keepG";
import "stripHPattern";
import "keepHPattern";

const keepI = fsF(fkF());
const keepJ = fkF(fsF());

Out


import { fkA } from "keepA";

import { fkB } from "keepBPattern";

fkB('foo');

import fkC from "keepC";

console.log(fkC);

import fkD from "keepDPattern";

const fkDVar = fkD;

import { fkEProxy as fkE } from "keepE";

import { fkFProxy as fkF } from "keepFPattern";

import "keepG";

import "keepHPattern";

const keepI;
const keepJ = fkF();

Function

In

function stripA () {}
function keepA () {}
const keepB = function stripB () {};

stripA();
console.keepC('foo');
console.keepC.stripC('foo');
console.stripD('bar');
console.stripD.keepD('bar');

stripA(keepC());
keepC(stripA());

Out


function keepA() {}
const keepB;

console.keepC('foo');

keepC();

Installation

npm install --save-dev babel-plugin-remove-code

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": [
    ["remove-code", {
        "debugger": true,
        "var": ["pattern"],
        "export": ["pattern"],
        "import": ["pattern"],
        "function": ["pattern"]
    }]
  ]
}

Note: Regex patterns work but the . is escaped.