babel-plugin-transform-taroapi 4.0.1 → 4.0.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -8
- package/__tests__/index.spec.ts +1 -1
- package/babel.config.json +1 -2
- package/package.json +15 -9
- package/src/index.ts +5 -5
package/LICENSE
CHANGED
|
@@ -154,15 +154,8 @@ See `/LICENSE` for details of the license.
|
|
|
154
154
|
|
|
155
155
|
==================
|
|
156
156
|
|
|
157
|
-
MIT (stencil-vue2-output-target):
|
|
158
|
-
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
|
-
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
|
-
See `/LICENSE` for details of the license.
|
|
161
|
-
|
|
162
|
-
==================
|
|
163
|
-
|
|
164
157
|
MIT (weui):
|
|
165
|
-
The following files embed [
|
|
158
|
+
The following files embed [weui](https://github.com/Tencent/weui) MIT:
|
|
166
159
|
`/packages/taro-components/src/components/*.scss`
|
|
167
160
|
See `/LICENSE.txt` for details of the license.
|
|
168
161
|
|
|
@@ -172,3 +165,10 @@ Apache-2.0 (intersection-observer):
|
|
|
172
165
|
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
|
|
173
166
|
`/packages/taro-api/src/polyfill/intersection-observer.ts`
|
|
174
167
|
See `/LICENSE.txt` for details of the license.
|
|
168
|
+
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
MIT (babel-plugin-jsx-dom-expressions):
|
|
172
|
+
The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
|
|
173
|
+
`/packages/babel-plugin-transform-solid-jsx/src/*`
|
|
174
|
+
See `/LICENSE` for details of the license.
|
package/__tests__/index.spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as babel from '@babel/core'
|
|
2
2
|
import * as t from '@babel/types'
|
|
3
|
-
import * as definition from '@tarojs/plugin-platform-h5/dist/definition.json'
|
|
4
3
|
|
|
4
|
+
import * as definition from '../../taro-platform-h5/dist/definition.json'
|
|
5
5
|
import plugin from '../src'
|
|
6
6
|
|
|
7
7
|
type ImportType = babel.types.ImportSpecifier | babel.types.ImportDefaultSpecifier | babel.types.ImportNamespaceSpecifier
|
package/babel.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-transform-taroapi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3-alpha.0",
|
|
4
|
+
"author": "O2Team",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"main": "dist/index.js",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">= 18"
|
|
9
|
+
},
|
|
5
10
|
"dependencies": {
|
|
6
11
|
"lodash": "^4.17.21"
|
|
7
12
|
},
|
|
8
13
|
"devDependencies": {
|
|
9
|
-
"@babel/core": "
|
|
10
|
-
"@babel/types": "
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"typescript": "^4.7.4"
|
|
14
|
+
"@babel/core": "7.24.4",
|
|
15
|
+
"@babel/types": "7.24.0",
|
|
16
|
+
"@types/babel__core": "7.20.5"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@babel/core": "^7.0.0"
|
|
16
20
|
},
|
|
17
|
-
"license": "MIT",
|
|
18
21
|
"scripts": {
|
|
22
|
+
"prod": "pnpm run build",
|
|
23
|
+
"prebuild": "pnpm run clean",
|
|
24
|
+
"clean": "rimraf --impl=move-remove ./dist",
|
|
19
25
|
"build": "tsc",
|
|
20
26
|
"test": "cross-env NODE_ENV=jest jest",
|
|
21
27
|
"test:ci": "cross-env NODE_ENV=jest jest --ci -i --coverage --silent",
|
package/src/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
60
60
|
this.apis = apis
|
|
61
61
|
},
|
|
62
62
|
visitor: {
|
|
63
|
-
ImportDeclaration (ast) {
|
|
63
|
+
ImportDeclaration (ast: BabelCore.NodePath<any>) {
|
|
64
64
|
if (ast.node.source.value !== this.packageName) return
|
|
65
65
|
|
|
66
66
|
ast.node.specifiers.forEach(node => {
|
|
@@ -91,7 +91,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
91
91
|
}
|
|
92
92
|
})
|
|
93
93
|
},
|
|
94
|
-
MemberExpression (ast) {
|
|
94
|
+
MemberExpression (ast: BabelCore.NodePath<any>) {
|
|
95
95
|
/* 处理Taro.xxx */
|
|
96
96
|
const isTaro = t.isIdentifier(ast.node.object, { name: taroName })
|
|
97
97
|
const property = ast.node.property
|
|
@@ -110,7 +110,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
110
110
|
|
|
111
111
|
// 同一api使用多次, 读取变量名
|
|
112
112
|
if (this.apis.has(propertyName)) {
|
|
113
|
-
const parentNode = ast.parent
|
|
113
|
+
const parentNode = ast.parent as BabelCore.types.AssignmentExpression
|
|
114
114
|
const isAssignment = t.isAssignmentExpression(parentNode) && parentNode.left === ast.node
|
|
115
115
|
|
|
116
116
|
if (!isAssignment) {
|
|
@@ -129,7 +129,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
129
129
|
needDefault = true
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
|
-
CallExpression (ast) {
|
|
132
|
+
CallExpression (ast: BabelCore.NodePath<any>) {
|
|
133
133
|
if (!ast.scope.hasReference(this.canIUse)) return
|
|
134
134
|
const callee = ast.node.callee
|
|
135
135
|
if (t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: taroName })) {
|
|
@@ -188,7 +188,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
188
188
|
ast.node.specifiers = namedImports
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
|
-
CallExpression (ast) {
|
|
191
|
+
CallExpression (ast: BabelCore.NodePath<any>) {
|
|
192
192
|
if (!invokedApis.has(that.canIUse)) return
|
|
193
193
|
const callee = ast.node.callee
|
|
194
194
|
const { name } = t.identifier(invokedApis.get(that.canIUse)!)
|