babel-plugin-sitrep
Log all assignments and the return value of a function with a simple comment
Example
In
// sitrep { var a = 'foo' const b = 'bar' let c = a b return c} // sitrepvar x // sitrepvar { x = x + 2 x return x} // sitrepvar { return 'foo'} const obj = // sitrep { let a = 5 return a + 5 } // sitrep { let a = 2 return a + 5 } // sitrep prefix { var a = 'foo' return a}
↓ ↓ ↓ ↓ ↓ ↓
Out
// sitrep { console; var a = 'foo'; console; const b = 'bar'; console; let c = a b; console; var _returnValue = c; console; console; return _returnValue;} // sitrepvar { console; var _returnValue3 = x; console; console; return _returnValue3;}; // sitrepvar { console; x = x + 2; console; x; var _returnValue4 = x; console; console; return _returnValue4;}; // sitrepvar { console; var _returnValue5 = 'foo'; console; console; return _returnValue5;}; const obj = // sitrep { console; let a = 5; console; var _returnValue6 = a + 5; console; console; return _returnValue6; }; // sitrep { console; let a = 2; console; var _returnValue7 = a + 5; console; console; return _returnValue7; } // sitrep prefix { console; var a = 'foo'; console; var _returnValue8 = c; console; console; return _returnValue8;}
Installation
npm install --save-dev babel-plugin-sitrep
Usage
.babelrc
(Recommended)
Via .babelrc
Without options:
Via CLI
babel --plugins sitrep script.js
Via Node API
;
Options
label
string
, defaults to sitrep
.
This option changes the label that enables the plugin
Example
If we set label
to "log-all-the-things"
In
// log-all-the-things { a = a return a}
↓ ↓ ↓ ↓ ↓ ↓
Out
// log-all-the-things { console; a = a; console; var _returnValue = a; console; console; return _returnValue;}
collapsed
boolean
, defaults to true
.
This option enables the following:
- Collapse the group of console logs associated with a function