🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

console.macro

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console.macro

A Babel macro that removes console prints in production

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

console.macro

因为eslint对于console的一些方法会进行校验,阻碍git的提交,所以简化了这些方法的调用并在process.env.NODE_ENV等于production的时候 移除这些方法。

默认是log方法,还支持error, warn, info, table, time, timeEnd

Installation

npm install --save-dev babel-plugin-macros console.macro 
yarn add babel-plugin-macros console.macro --dev

Usage


// babel.config.js add babel-plugin-macros

plugins = ['babel-plugin-macros'];

import log, { error, info } from 'dev-console.macro';

const logMsg = 'log message';
log('This is a', logMsg);
error('this is a error');

// process.env.NODE_ENV !== 'production'
const logMsg = 'log message';
console.log('This is a', logMsg);
console.error('this is a error');

// process.env.NODE_ENV === 'production'
// remove all support method
const logMsg = 'log message';

Keywords

console

FAQs

Package last updated on 28 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts