JSPM

fn-try-catch-loader

1.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q17426F
  • License ISC

一个为await做try/catch处理的webpack Loader

Package Exports

  • fn-try-catch-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fn-try-catch-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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语句中的代码