babel-plugin-annotate-console-log
babel-plugin-annotate-console-log copied to clipboard
add script path
If you specify option "scriptPath": true:
"plugins": [
["annotate-console-log", {
"scriptPath": true
}]
]
it'll add a short script path (and line number)
console.log('hi')
// =>
console.log('[file.js:3]', 'foo()', 'hi')
If the filename was index.js it'll ad the parent foldername
console.log('[foo/index.js:5]', 'foo()', 'hi')
Use "fullScriptPath": true to add more detailed script path info
console.log('foo()', 'hi', {
scriptColumn: 4,
scriptLine: 9,
scriptPath: 'relative/to/nearest/package.json/full-script-path/index.js'
})
fixes #1
@gajus thoughts on this? I was also thinking maybe having only this (the short script path) without the function name. What would you say about making the function name optional, like {functionName: false, scriptPath: true}
Whats the reason for wanting to include the file name, line, column if this information is already present in the console?
As is "VM214:1" in this screenshot.
I'm using this in Node