babel-plugin-function-try-catch

1.1.0 • Public • Published

babel-plugin-function-try-catch

Babel plugin that can add try/catch to function automatically.(一个能为函数自动添加 try/catch 的 babel 插件)

Usage

Install:

yarn add babel-plugin-function-try-catch
or
npm install babel-plugin-function-try-catch

Example

before:

var fn = function(){
  console.log('hello world');
}

after:

var fn = function () {
  try {
    console.log(2);
  } catch (error) {
    console.log(error);
  }
};

How to config

webpack:

rules: [{
  test: /\.js$/,
  exclude: /node_modules/,
  use: [
+    "babel-plugin-function-try-catch",
    "babel-loader",
  ]
}]

/babel-plugin-function-try-catch/

    Package Sidebar

    Install

    npm i babel-plugin-function-try-catch

    Weekly Downloads

    1

    Version

    1.1.0

    License

    ISC

    Unpacked Size

    8.7 kB

    Total Files

    4

    Last publish

    Collaborators

    • allan2coder