Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aztack/babel-plugin-transform-dbg

A Babel plugin that automatically add __debug variable for debugging and logging
https://github.com/aztack/babel-plugin-transform-dbg

babel babel-plugin debugging filename line logging

Last synced: about 23 hours ago
JSON representation

A Babel plugin that automatically add __debug variable for debugging and logging

Awesome Lists containing this project

README

        

# A Babel plugin that automatically add `__debug` variable for debugging and logging

## Install
```
yarn add -D babel-plugin-transform-dbg
```

## .babelrc
```
{
"presets": ["@babel/env"],
"plugins": ["@babel/transform-runtime", "babel-plugin-transform-dbg"]
}

```

## Usage

### in Object methods
```
// component.vue
const vm = {
methods: {
onSomeEvent () {
console.log(__debug) // {file:"/absolute/path/to/component.vue",line:4,method:"onSomeEvent"}
}
}
}
```

## in function
```
// a.js
function test () {
console.log(__debug); // {file:"/absolute/path/to/a.js",line:2,method:"test"}
}
test()
```