1.0.1 • Published 5 years ago

babel-plugin-transform-dbg v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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()