babel-preset-taro 3.4.0-beta.1 → 3.4.1
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/index.js +1 -1
- package/package.json +7 -9
- package/remove-define-config.js +18 -0
- package/rn/index.js +19 -12
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ module.exports = (_, options = {}) => {
|
|
|
28
28
|
}])
|
|
29
29
|
if (process.env.TARO_ENV === 'h5' && process.env.NODE_ENV !== 'production' && options.hot !== false) {
|
|
30
30
|
if (options.framework === 'react') {
|
|
31
|
-
plugins.push([require('react-refresh/babel')])
|
|
31
|
+
plugins.push([require('react-refresh/babel'), { skipEnvCheck: true }])
|
|
32
32
|
} else if (options.framework === 'preact') {
|
|
33
33
|
overrides.push({
|
|
34
34
|
include: /\.[jt]sx$/,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-taro",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "yuche <i@yuche.me>",
|
|
6
6
|
"homepage": "https://github.com/nervjs/taro/tree/master/packages/babel-preset-taro#readme",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"rn/",
|
|
11
|
+
"remove-define-config.js",
|
|
11
12
|
"index.js"
|
|
12
13
|
],
|
|
13
14
|
"repository": {
|
|
@@ -35,22 +36,19 @@
|
|
|
35
36
|
"@babel/runtime": "^7.14.5",
|
|
36
37
|
"@babel/runtime-corejs3": "^7.14.5",
|
|
37
38
|
"@prefresh/babel-plugin": "^0.4.1",
|
|
38
|
-
"@tarojs/helper": "3.4.
|
|
39
|
-
"@tarojs/taro-h5": "3.4.
|
|
39
|
+
"@tarojs/helper": "3.4.1",
|
|
40
|
+
"@tarojs/taro-h5": "3.4.1",
|
|
40
41
|
"@vue/babel-plugin-jsx": "^1.0.6",
|
|
41
42
|
"@vue/babel-preset-jsx": "^1.2.4",
|
|
42
43
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
43
44
|
"babel-plugin-global-define": "1.0.3",
|
|
44
45
|
"babel-plugin-jsx-attributes-array-to-object": "0.3.0",
|
|
45
46
|
"babel-plugin-transform-imports-api": "1.0.0",
|
|
46
|
-
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.4.
|
|
47
|
-
"babel-plugin-transform-taroapi": "3.4.
|
|
47
|
+
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.4.1",
|
|
48
|
+
"babel-plugin-transform-taroapi": "3.4.1",
|
|
48
49
|
"core-js": "^3.6.5",
|
|
49
50
|
"metro-react-native-babel-preset": "^0.66.2",
|
|
50
51
|
"react-refresh": "0.9.0"
|
|
51
52
|
},
|
|
52
|
-
"
|
|
53
|
-
"@tarojs/taro-rn": "3.4.0-beta.1"
|
|
54
|
-
},
|
|
55
|
-
"gitHead": "bd7b3674278d22f71e2658b530cc0be24bf9964e"
|
|
53
|
+
"gitHead": "a2437215b1966fd0b6dd09311bcb4fd894a871d0"
|
|
56
54
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = function pluginRemovePageConfig (babel) {
|
|
2
|
+
const { types: t } = babel
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
name: 'plugin:remove_pageconfig',
|
|
6
|
+
visitor: {
|
|
7
|
+
CallExpression (nodePath, state) {
|
|
8
|
+
if (!/src/.test(state.filename)) return
|
|
9
|
+
if (/\.config\.(t|j)sx?$/.test(state.filename)) return
|
|
10
|
+
|
|
11
|
+
const { callee } = nodePath.node
|
|
12
|
+
if (!t.isIdentifier(callee, { name: 'definePageConfig' })) return
|
|
13
|
+
|
|
14
|
+
nodePath.remove()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/rn/index.js
CHANGED
|
@@ -60,14 +60,16 @@ function getEnv () {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function parseDefineConst (config) {
|
|
63
|
+
const result = {}
|
|
63
64
|
Object.keys(config.defineConstants).forEach((key) => {
|
|
64
65
|
try {
|
|
65
|
-
|
|
66
|
+
result[key] = JSON.parse(config.defineConstants[key])
|
|
66
67
|
} catch (e) {
|
|
67
|
-
console.error('defineConstants
|
|
68
|
-
|
|
68
|
+
console.error('defineConstants error: ', e)
|
|
69
|
+
result[key] = ''
|
|
69
70
|
}
|
|
70
71
|
})
|
|
72
|
+
return result
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/**
|
|
@@ -77,17 +79,20 @@ function parseDefineConst (config) {
|
|
|
77
79
|
function getDefineConstants () {
|
|
78
80
|
const config = getProjectConfig()
|
|
79
81
|
const rnconfig = getRNConfig()
|
|
82
|
+
const env = getEnv()
|
|
80
83
|
if (rnconfig.defineConstants) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
return {
|
|
85
|
+
...parseDefineConst(rnconfig),
|
|
86
|
+
...env
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
if (config.defineConstants) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
return {
|
|
91
|
+
...parseDefineConst(config),
|
|
92
|
+
...env
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
|
-
return
|
|
95
|
+
return env
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
function getCSSModule () {
|
|
@@ -112,7 +117,6 @@ module.exports = (_, options = {}) => {
|
|
|
112
117
|
const nativeLibs = require('@tarojs/taro-rn/libList.js')
|
|
113
118
|
const nativeInterfaces = nativeApis.concat(nativeLibs)
|
|
114
119
|
|
|
115
|
-
getEnv()
|
|
116
120
|
const defineConstants = getDefineConstants()
|
|
117
121
|
const presets = []
|
|
118
122
|
const plugins = []
|
|
@@ -155,13 +159,16 @@ module.exports = (_, options = {}) => {
|
|
|
155
159
|
[require('babel-plugin-global-define'), defineConstants]
|
|
156
160
|
)
|
|
157
161
|
|
|
158
|
-
// 添加一个默认 plugin, 与小程序/h5保持一致.
|
|
162
|
+
// 添加一个默认 plugin, 与小程序/h5保持一致.
|
|
159
163
|
plugins.push(
|
|
160
164
|
[require('@babel/plugin-proposal-decorators'), {
|
|
161
165
|
decoratorsBeforeExport,
|
|
162
166
|
legacy: decoratorsLegacy !== false
|
|
163
167
|
}]
|
|
164
168
|
)
|
|
169
|
+
|
|
170
|
+
plugins.push(require('../remove-define-config'))
|
|
171
|
+
|
|
165
172
|
return {
|
|
166
173
|
presets,
|
|
167
174
|
plugins
|