babel-plugin-logfunctionname
A babel plugin to insert a log in function to show the function name
if you join in a large project but with no document, this plugin maybe could help you;
In
const functionName = { } { }const arrowFunction = { } { thisname = name; } { console }let classFunctionItem = 'sz-p' ;;;classFunctionItem;
out
"use strict"; { if !instance instanceof Constructor throw "Cannot call a class as a function"; } { for var i = 0; i < propslength; i++ var descriptor = propsi; descriptorenumerable = descriptorenumerable || false; descriptorconfigurable = true; if "value" in descriptor descriptorwritable = true; Object; } { if protoProps ; if staticProps ; return Constructor; } var { console;}; { console;} var { console;}; var ClassFunction =/*#__PURE__*/ { { console; ; thisname = name; } ; return ClassFunction;}; var classFunctionItem = 'sz-p';;;;classFunctionItem;
Installation
$ yarn add babel-plugin-logfunctionname -D
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
$ babel --plugins babel-plugin-logfunctionname script.js
Via Node API
;
Options
Key | Type | Description | Example |
---|---|---|---|
enable | boolean | enable or disable plugin | false |
functionWorkingHint | string | The string before functionName | function_working: |
excludeFunctionsName | array | exclude functions by function name | ['doNotLogThis', /^excludeByRegExp/] |
excludeFilesName | array | exclude functions by file name | ['subCode', /node_modules/] |
test
$ yarn install$ yarn transform$ yarn runOut