Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/growingio/growing-babel-plugin-setname
set the function name for the anonymous function
https://github.com/growingio/growing-babel-plugin-setname
Last synced: 2 months ago
JSON representation
set the function name for the anonymous function
- Host: GitHub
- URL: https://github.com/growingio/growing-babel-plugin-setname
- Owner: growingio
- Created: 2021-04-14T11:08:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-19T02:20:01.000Z (over 3 years ago)
- Last Synced: 2024-10-08T09:40:45.126Z (3 months ago)
- Language: JavaScript
- Size: 146 KB
- Stars: 6
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## babel-plugin-setname
> 为匿名函数设置函数名
### 使用
```sh
npm install babel-plugin-setname --save-dev
```修改babel配置,如`babel.config.js`
```javascript
module.exports = {
plugins: [
[
"babel-plugin-setname",
{
includes: ["src"],
callee: '__setname__',
package: '@gio/setname',
lower: false,
test: /^on[A-Z][a-zA-Z]+/
}
]
]
}
```- includes: 需要设置函数名的包
- callee: 设置函数名的方法名(default: `_GIO_DI_NAME_`)
- package: 设置提供setname函数的包(default: `babel-plugin-setname/lib/setname`)
- lower: 如果是从Taro2升级来的,可以配置为true已能兼容大部分的已圈选的无埋点事件(无法完全)
- test: 自定义要转换的jsx属性(default: `/^on[A-Z][a-zA-Z]+/`)