await-try-catch-loader

1.0.8 • Public • Published

await-try-catch-loader

一个为await包裹上try/catch的webpack Loader

如果你想通过try/catch来暴露一些代码运行时的同步问题,但是又不想手动给代码里每个await函数来添加try/catch,那么该loader能完美的解决你的需求

推荐node版本

运行包中的测试用例,推荐:v11.x.x(v10.x.x及以上都可以)

Usage

// webpack.config.js
module: {
    rules: [
        {
            test: /\.js$/,
            use:{
                loader:'await-try-catch-loader',
                options: {
                	identifier: 'err',
                	catchCode: `alert(err)`
                }
            }
        }
    ]
}

loader options

字段 类型 默认值 描述
identifier string e catch语句中错误对象
catchCode string console.error(e) catch语句中的代码

Package Sidebar

Install

npm i await-try-catch-loader

Weekly Downloads

2

Version

1.0.8

License

ISC

Unpacked Size

9.95 kB

Total Files

11

Last publish

Collaborators

  • zhaoxiaoyang