GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sindresorhus/strip-debug: Strip console, alert, and debugger statements from JavaScript code

BranchesTags
Open more actions menu

Latest commit

 

History

50 Commits
50 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
index.d.ts
index.d.ts
 
 
index.js
index.js
 
 
license
license
 
 
package.json
package.json
 
 
readme.md
readme.md
 
 
test.js
test.js
 
 

Repository files navigation

strip-debug

Strip console, alert, and debugger statements from JavaScript code

Useful for making sure you didn't leave any logging in production code.

Usage

npm install @babel/core strip-debug

Usage

import {transformSync} from '@babel/core';
import stripDebug from 'strip-debug';

transformSync('function foo(){console.log("foo");alert("foo");debugger;}', {
	plugins: [stripDebug]
}).code;
//=> 'function foo() { void 0;void 0; }'

To prevent any side-effects, console.*/alert* is replaced with void 0 instead of being stripped.

If you shadow the console global with your own local variable, it will still be removed.

Ignoring specific lines

You can ignore specific statements from being stripped by using special comments:

// strip-debug-ignore-next
console.log('This will NOT be stripped');

console.log('This will be stripped'); // strip-debug-ignore

Both comment styles work:

  • // strip-debug-ignore-next - Ignores the next line
  • // strip-debug-ignore - Ignores the current line (inline comment)
  • /* strip-debug-ignore-next */ - Block comment style also works

Related

  • strip-debug-cli - API for this package

About

Strip console, alert, and debugger statements from JavaScript code

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

86 stars

Watchers

4 watching

Forks

16 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.