1.0.4 • Published 1 year ago

@namchee/bun-plugin-strip-debug v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@namchee/bun-plugin-strip-debug

A Bun plugin that strips console.* and debugger statements from your Bun.build output.

Example

Given the following code:

console.log('Hello World!');

function add(a: number, b: number): number {
    debugger;
    return a + b;
}

console['table']({ foo: 'bar' });

This transformer will transform your code to the following code:

function add(a: number, b: number): number {
    return a + b;
}

Installation

# Using npm
npm install -D @namchee/bun-plugin-strip-debug

# Using yarn
yarn add -D @namchee/bun-plugin-strip-debug

# Using pnpm
pnpm install -D @namchee/bun-plugin-strip-debug

# Using bun
bun install -D @namchee/bun-plugin-strip-debug

Usage

import { stripDebug } from '@namchee/bun-plugin-strip-debug';

Bun.build({
  entrypoints: ['<your_entrypoint>'],
  outdir: '<your_outdir>',
  plugins: [stripDebug()],
});

See sample for complete example.

Options

NameTypeDefaultDescription
filesRegExpAll JS and TS files in the project directory, including the eXtended variantsList of files to be processed by the plugin
excludestring[][]List of console methods to ignore when stripping console statements.
debuggerbooleantrueAllows the plugin to strip debugger statements.
tsconfigPathstringprocess.cwd()/tsconfig.json, if not found will use { target: "es2015" }Path to TypeScript configuration file. Will be used for code traversal and transformation.

License

This project is licensed under the MIT License

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

2 years ago