babel-plugin-transform-taroapi 4.1.5-beta.7 → 4.1.5-beta.8

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.
@@ -1,98 +1,10 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`babel-plugin-transform-taroapi > should canIUse support! 1`] = `
3
+ exports[`babel-plugin-transform-taroapi should canIUse support scheme with numeric attributes! 1`] = `
4
4
  "import { canIUse as _canUse } from '@tarojs/taro-h5';
5
- // 对象的属性或方法
6
- false;
7
- false;
8
- false;
9
- false;
10
-
11
- // 接口参数、回调或者返回值
12
- true;
13
- false;
14
- false;
15
- false;
16
- false;
17
- true;
18
-
19
- // 组件的属性
5
+ // 入参带有数字属性的对象路径
20
6
  true;
21
- true;
22
- false;"
23
- `;
24
-
25
- exports[`babel-plugin-transform-taroapi > should canIUse work or skip! 1`] = `
26
- "import Taro from '@tarojs/taro-h5';
27
- function canIUse() {}
28
- false;
29
- false;
30
- canIUse('showToast.object.image');"
31
- `;
32
-
33
- exports[`babel-plugin-transform-taroapi > should leave other apis untouched 1`] = `
34
- "import Taro from '@tarojs/taro-h5';
35
- Taro.noop;"
36
- `;
37
-
38
- exports[`babel-plugin-transform-taroapi > should move static apis under "Taro" 1`] = `
39
- "import Taro from '@tarojs/taro-h5';
40
- Taro.noop;
41
- Taro.noop();"
42
- `;
43
-
44
- exports[`babel-plugin-transform-taroapi > should not go wrong when using an api twice 1`] = `
45
- "import Taro, { createAnimation as _createAnimation } from '@tarojs/taro-h5';
46
- const animation = _createAnimation({
47
- duration: dura * 1000,
48
- timingFunction: 'linear'
49
- });
50
- const resetAnimation = _createAnimation({
51
- duration: 0,
52
- timingFunction: 'linear'
53
- });"
54
- `;
55
-
56
- exports[`babel-plugin-transform-taroapi > should not import taro duplicity 1`] = `
57
- "import Taro, { createAnimation as _createAnimation, initPxTransform as _initPxTransform } from '@tarojs/taro-h5';
58
- Taro.Component;
59
- _createAnimation();
60
- _initPxTransform();"
61
- `;
62
-
63
- exports[`babel-plugin-transform-taroapi > should preserve assignments in left hands 1`] = `
64
- "import Taro, { createAnimation as _createAnimation, request as _request } from '@tarojs/taro-h5';
65
- let animation;
66
- animation = _createAnimation({
67
- transformOrigin: "50% 50%",
68
- duration: 1000,
69
- timingFunction: "ease",
70
- delay: 0
71
- });
72
- _request();
73
- Taro.request = '';
74
- Taro['request'] = '';"
75
- `;
76
-
77
- exports[`babel-plugin-transform-taroapi > should preserve default imports 1`] = `
78
- "import Taro from '@tarojs/taro-h5';
79
- console.log(Taro);"
80
- `;
81
-
82
- exports[`babel-plugin-transform-taroapi > should support rename of imported names 1`] = `
83
- "// import { inject as mobxInject, observer as mobxObserver } from '@tarojs/mobx'
84
- import Taro from '@tarojs/taro-h5';
85
- export class Connected extends Taro.Component {}"
86
- `;
87
-
88
- exports[`babel-plugin-transform-taroapi > should work! 1`] = `
89
- "import Taro, { setStorage as _setStorage, initPxTransform as _initPxTransform, getStorage as _getStorage } from '@tarojs/taro-h5';
90
- _initPxTransform(Taro.param);
91
- _initPxTransform();
92
- _initPxTransform();
93
- _getStorage();
94
- _setStorage();
95
- export { Taro };"
7
+ true;"
96
8
  `;
97
9
 
98
10
  exports[`babel-plugin-transform-taroapi should canIUse support! 1`] = `
@@ -114,7 +26,7 @@ true;
114
26
  // 组件的属性
115
27
  true;
116
28
  true;
117
- false;"
29
+ true;"
118
30
  `;
119
31
 
120
32
  exports[`babel-plugin-transform-taroapi should canIUse work or skip! 1`] = `
@@ -0,0 +1,96 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`babel-plugin-transform-taroapi should canIUse support! 1`] = `
4
+ "import { canIUse as _canUse } from '@tarojs/taro-h5';
5
+ // 对象的属性或方法
6
+ false;
7
+ false;
8
+ false;
9
+ false;
10
+
11
+ // 接口参数、回调或者返回值
12
+ true;
13
+ false;
14
+ false;
15
+ false;
16
+ false;
17
+ true;
18
+
19
+ // 组件的属性
20
+ true;
21
+ true;
22
+ false;"
23
+ `;
24
+
25
+ exports[`babel-plugin-transform-taroapi should canIUse work or skip! 1`] = `
26
+ "import Taro from '@tarojs/taro-h5';
27
+ function canIUse() {}
28
+ false;
29
+ false;
30
+ canIUse('showToast.object.image');"
31
+ `;
32
+
33
+ exports[`babel-plugin-transform-taroapi should leave other apis untouched 1`] = `
34
+ "import Taro from '@tarojs/taro-h5';
35
+ Taro.noop;"
36
+ `;
37
+
38
+ exports[`babel-plugin-transform-taroapi should move static apis under "Taro" 1`] = `
39
+ "import Taro from '@tarojs/taro-h5';
40
+ Taro.noop;
41
+ Taro.noop();"
42
+ `;
43
+
44
+ exports[`babel-plugin-transform-taroapi should not go wrong when using an api twice 1`] = `
45
+ "import Taro, { createAnimation as _createAnimation } from '@tarojs/taro-h5';
46
+ const animation = _createAnimation({
47
+ duration: dura * 1000,
48
+ timingFunction: 'linear'
49
+ });
50
+ const resetAnimation = _createAnimation({
51
+ duration: 0,
52
+ timingFunction: 'linear'
53
+ });"
54
+ `;
55
+
56
+ exports[`babel-plugin-transform-taroapi should not import taro duplicity 1`] = `
57
+ "import Taro, { createAnimation as _createAnimation, initPxTransform as _initPxTransform } from '@tarojs/taro-h5';
58
+ Taro.Component;
59
+ _createAnimation();
60
+ _initPxTransform();"
61
+ `;
62
+
63
+ exports[`babel-plugin-transform-taroapi should preserve assignments in left hands 1`] = `
64
+ "import Taro, { createAnimation as _createAnimation, request as _request } from '@tarojs/taro-h5';
65
+ let animation;
66
+ animation = _createAnimation({
67
+ transformOrigin: "50% 50%",
68
+ duration: 1000,
69
+ timingFunction: "ease",
70
+ delay: 0
71
+ });
72
+ _request();
73
+ Taro.request = '';
74
+ Taro['request'] = '';"
75
+ `;
76
+
77
+ exports[`babel-plugin-transform-taroapi should preserve default imports 1`] = `
78
+ "import Taro from '@tarojs/taro-h5';
79
+ console.log(Taro);"
80
+ `;
81
+
82
+ exports[`babel-plugin-transform-taroapi should support rename of imported names 1`] = `
83
+ "// import { inject as mobxInject, observer as mobxObserver } from '@tarojs/mobx'
84
+ import Taro from '@tarojs/taro-h5';
85
+ export class Connected extends Taro.Component {}"
86
+ `;
87
+
88
+ exports[`babel-plugin-transform-taroapi should work! 1`] = `
89
+ "import Taro, { setStorage as _setStorage, initPxTransform as _initPxTransform, getStorage as _getStorage } from '@tarojs/taro-h5';
90
+ _initPxTransform(Taro.param);
91
+ _initPxTransform();
92
+ _initPxTransform();
93
+ _getStorage();
94
+ _setStorage();
95
+ export { Taro };"
96
+ `;
@@ -1,6 +1,5 @@
1
1
  import * as babel from '@babel/core'
2
2
  import * as t from '@babel/types'
3
- import { describe, expect, test } from 'vitest'
4
3
 
5
4
  import plugin from '../src'
6
5
  import * as definition from './__mocks__/harmony-definition.json'
@@ -1,6 +1,5 @@
1
1
  import * as babel from '@babel/core'
2
2
  import * as t from '@babel/types'
3
- import { describe, expect, test } from 'vitest'
4
3
 
5
4
  import plugin from '../src'
6
5
  import * as definition from './__mocks__/h5-definition.json'
@@ -0,0 +1,18 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "node": "current"
8
+ }
9
+ }
10
+ ]
11
+ ],
12
+ "plugins": ["@babel/plugin-transform-react-jsx"],
13
+ "env": {
14
+ "test": {
15
+ "plugins": ["@babel/plugin-transform-runtime"]
16
+ }
17
+ }
18
+ }
package/jest.config.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { Config } from 'jest'
2
+
3
+ const config: Config = {
4
+ collectCoverage: false,
5
+ moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
6
+ preset: 'ts-jest',
7
+ testEnvironment: 'node',
8
+ testMatch: ['**/__tests__/**/?(*.)+(spec|test).[jt]s?(x)'],
9
+ testPathIgnorePatterns: [
10
+ 'node_modules',
11
+ ],
12
+ transform: {
13
+ '^.+\\.jsx?$': 'babel-jest',
14
+ '^.+\\.tsx?$': ['ts-jest', {
15
+ diagnostics: false,
16
+ tsconfig: {
17
+ allowJs: true
18
+ }
19
+ }],
20
+ },
21
+ transformIgnorePatterns: ['<rootDir>/node_modules/']
22
+ }
23
+
24
+ export default config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-taroapi",
3
- "version": "4.1.5-beta.7",
3
+ "version": "4.1.5-beta.8",
4
4
  "author": "O2Team",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -23,9 +23,10 @@
23
23
  "prebuild": "pnpm run clean",
24
24
  "clean": "rimraf ./dist",
25
25
  "build": "tsc",
26
- "test": "vitest run",
27
- "test:ci": "vitest run --coverage",
28
- "test:dev": "vitest",
29
- "updateSnapshot": "vitest run --updateSnapshot"
26
+ "test": "cross-env NODE_ENV=jest jest",
27
+ "test:ci": "cross-env NODE_ENV=jest jest --ci -i --coverage --silent",
28
+ "test:dev": "cross-env NODE_ENV=jest jest --watch",
29
+ "test:coverage": "cross-env NODE_ENV=jest jest --coverage",
30
+ "updateSnapshot": "cross-env NODE_ENV=jest jest --updateSnapshot"
30
31
  }
31
32
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../tsconfig.root.json",
3
+ "compilerOptions": {
4
+ "allowJs": true
5
+ }
6
+ }
@@ -1,205 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`babel-plugin-transform-taroapi > should canIUse support scheme with numeric attributes! 1`] = `
4
- "import { canIUse as _canUse } from '@tarojs/taro-h5';
5
- // 入参带有数字属性的对象路径
6
- true;
7
- true;"
8
- `;
9
-
10
- exports[`babel-plugin-transform-taroapi > should canIUse support! 1`] = `
11
- "import { canIUse as _canUse } from '@tarojs/taro-h5';
12
- // 对象的属性或方法
13
- false;
14
- false;
15
- false;
16
- false;
17
-
18
- // 接口参数、回调或者返回值
19
- true;
20
- false;
21
- false;
22
- false;
23
- false;
24
- true;
25
-
26
- // 组件的属性
27
- true;
28
- true;
29
- true;"
30
- `;
31
-
32
- exports[`babel-plugin-transform-taroapi > should canIUse work or skip! 1`] = `
33
- "import Taro from '@tarojs/taro-h5';
34
- function canIUse() {}
35
- false;
36
- false;
37
- canIUse('showToast.object.image');"
38
- `;
39
-
40
- exports[`babel-plugin-transform-taroapi > should leave other apis untouched 1`] = `
41
- "import Taro from '@tarojs/taro-h5';
42
- Taro.noop;"
43
- `;
44
-
45
- exports[`babel-plugin-transform-taroapi > should move static apis under "Taro" 1`] = `
46
- "import Taro from '@tarojs/taro-h5';
47
- Taro.noop;
48
- Taro.noop();"
49
- `;
50
-
51
- exports[`babel-plugin-transform-taroapi > should not go wrong when using an api twice 1`] = `
52
- "import Taro, { createAnimation as _createAnimation } from '@tarojs/taro-h5';
53
- const animation = _createAnimation({
54
- duration: dura * 1000,
55
- timingFunction: 'linear'
56
- });
57
- const resetAnimation = _createAnimation({
58
- duration: 0,
59
- timingFunction: 'linear'
60
- });"
61
- `;
62
-
63
- exports[`babel-plugin-transform-taroapi > should not import taro duplicity 1`] = `
64
- "import Taro, { createAnimation as _createAnimation, initPxTransform as _initPxTransform } from '@tarojs/taro-h5';
65
- Taro.Component;
66
- _createAnimation();
67
- _initPxTransform();"
68
- `;
69
-
70
- exports[`babel-plugin-transform-taroapi > should preserve assignments in left hands 1`] = `
71
- "import Taro, { createAnimation as _createAnimation, request as _request } from '@tarojs/taro-h5';
72
- let animation;
73
- animation = _createAnimation({
74
- transformOrigin: "50% 50%",
75
- duration: 1000,
76
- timingFunction: "ease",
77
- delay: 0
78
- });
79
- _request();
80
- Taro.request = '';
81
- Taro['request'] = '';"
82
- `;
83
-
84
- exports[`babel-plugin-transform-taroapi > should preserve default imports 1`] = `
85
- "import Taro from '@tarojs/taro-h5';
86
- console.log(Taro);"
87
- `;
88
-
89
- exports[`babel-plugin-transform-taroapi > should support rename of imported names 1`] = `
90
- "// import { inject as mobxInject, observer as mobxObserver } from '@tarojs/mobx'
91
- import Taro from '@tarojs/taro-h5';
92
- export class Connected extends Taro.Component {}"
93
- `;
94
-
95
- exports[`babel-plugin-transform-taroapi > should work! 1`] = `
96
- "import Taro, { setStorage as _setStorage, initPxTransform as _initPxTransform, getStorage as _getStorage } from '@tarojs/taro-h5';
97
- _initPxTransform(Taro.param);
98
- _initPxTransform();
99
- _initPxTransform();
100
- _getStorage();
101
- _setStorage();
102
- export { Taro };"
103
- `;
104
-
105
- exports[`babel-plugin-transform-taroapi should canIUse support scheme with numeric attributes! 1`] = `
106
- "import { canIUse as _canUse } from '@tarojs/taro-h5';
107
- // 入参带有数字属性的对象路径
108
- true;
109
- true;"
110
- `;
111
-
112
- exports[`babel-plugin-transform-taroapi should canIUse support! 1`] = `
113
- "import { canIUse as _canUse } from '@tarojs/taro-h5';
114
- // 对象的属性或方法
115
- false;
116
- false;
117
- false;
118
- false;
119
-
120
- // 接口参数、回调或者返回值
121
- true;
122
- false;
123
- false;
124
- false;
125
- false;
126
- true;
127
-
128
- // 组件的属性
129
- true;
130
- true;
131
- true;"
132
- `;
133
-
134
- exports[`babel-plugin-transform-taroapi should canIUse work or skip! 1`] = `
135
- "import Taro from '@tarojs/taro-h5';
136
- function canIUse() {}
137
- false;
138
- false;
139
- canIUse('showToast.object.image');"
140
- `;
141
-
142
- exports[`babel-plugin-transform-taroapi should leave other apis untouched 1`] = `
143
- "import Taro from '@tarojs/taro-h5';
144
- Taro.noop;"
145
- `;
146
-
147
- exports[`babel-plugin-transform-taroapi should move static apis under "Taro" 1`] = `
148
- "import Taro from '@tarojs/taro-h5';
149
- Taro.noop;
150
- Taro.noop();"
151
- `;
152
-
153
- exports[`babel-plugin-transform-taroapi should not go wrong when using an api twice 1`] = `
154
- "import Taro, { createAnimation as _createAnimation } from '@tarojs/taro-h5';
155
- const animation = _createAnimation({
156
- duration: dura * 1000,
157
- timingFunction: 'linear'
158
- });
159
- const resetAnimation = _createAnimation({
160
- duration: 0,
161
- timingFunction: 'linear'
162
- });"
163
- `;
164
-
165
- exports[`babel-plugin-transform-taroapi should not import taro duplicity 1`] = `
166
- "import Taro, { createAnimation as _createAnimation, initPxTransform as _initPxTransform } from '@tarojs/taro-h5';
167
- Taro.Component;
168
- _createAnimation();
169
- _initPxTransform();"
170
- `;
171
-
172
- exports[`babel-plugin-transform-taroapi should preserve assignments in left hands 1`] = `
173
- "import Taro, { createAnimation as _createAnimation, request as _request } from '@tarojs/taro-h5';
174
- let animation;
175
- animation = _createAnimation({
176
- transformOrigin: "50% 50%",
177
- duration: 1000,
178
- timingFunction: "ease",
179
- delay: 0
180
- });
181
- _request();
182
- Taro.request = '';
183
- Taro['request'] = '';"
184
- `;
185
-
186
- exports[`babel-plugin-transform-taroapi should preserve default imports 1`] = `
187
- "import Taro from '@tarojs/taro-h5';
188
- console.log(Taro);"
189
- `;
190
-
191
- exports[`babel-plugin-transform-taroapi should support rename of imported names 1`] = `
192
- "// import { inject as mobxInject, observer as mobxObserver } from '@tarojs/mobx'
193
- import Taro from '@tarojs/taro-h5';
194
- export class Connected extends Taro.Component {}"
195
- `;
196
-
197
- exports[`babel-plugin-transform-taroapi should work! 1`] = `
198
- "import Taro, { setStorage as _setStorage, initPxTransform as _initPxTransform, getStorage as _getStorage } from '@tarojs/taro-h5';
199
- _initPxTransform(Taro.param);
200
- _initPxTransform();
201
- _initPxTransform();
202
- _getStorage();
203
- _setStorage();
204
- export { Taro };"
205
- `;
package/vitest.config.ts DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from 'vitest/config'
2
-
3
- // https://cn.vitest.dev/guide/
4
- export default defineConfig({
5
- test: {
6
- include: ['tests/**/*.spec.ts?(x)'],
7
- coverage: {
8
- provider: 'istanbul',
9
- include: ['src/**/*.ts'],
10
- }
11
- }
12
- })