babel-preset-taro 3.3.17 → 3.4.0-beta.2
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 +13 -3
- package/package.json +22 -20
- package/remove-define-config.js +18 -0
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = (_, options = {}) => {
|
|
|
9
9
|
const presets = []
|
|
10
10
|
const plugins = []
|
|
11
11
|
const overrides = []
|
|
12
|
-
const isReact = options.framework === 'react'
|
|
12
|
+
const isReact = options.framework === 'react' || options.framework === 'preact'
|
|
13
13
|
const isNerv = options.framework === 'nerv'
|
|
14
14
|
const isVue = options.framework === 'vue'
|
|
15
15
|
const isVue3 = options.framework === 'vue3'
|
|
@@ -27,7 +27,14 @@ module.exports = (_, options = {}) => {
|
|
|
27
27
|
runtime: options.reactJsxRuntime || 'automatic'
|
|
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')])
|
|
32
|
+
} else if (options.framework === 'preact') {
|
|
33
|
+
overrides.push({
|
|
34
|
+
include: /\.[jt]sx$/,
|
|
35
|
+
plugins: [require('@prefresh/babel-plugin')]
|
|
36
|
+
})
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
|
|
@@ -154,10 +161,13 @@ module.exports = (_, options = {}) => {
|
|
|
154
161
|
packageName: '@tarojs/taro',
|
|
155
162
|
apis
|
|
156
163
|
}])
|
|
157
|
-
}
|
|
164
|
+
}
|
|
165
|
+
if (options['dynamic-import-node'] || process.env.TARO_ENV !== 'h5') {
|
|
158
166
|
plugins.push([require('babel-plugin-dynamic-import-node')])
|
|
159
167
|
}
|
|
160
168
|
|
|
169
|
+
plugins.push(require('./remove-define-config'))
|
|
170
|
+
|
|
161
171
|
return {
|
|
162
172
|
sourceType: 'unambiguous',
|
|
163
173
|
overrides: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-taro",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-beta.2",
|
|
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": {
|
|
@@ -25,31 +26,32 @@
|
|
|
25
26
|
"@babel/core": "*"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@babel/plugin-proposal-class-properties": "7.
|
|
29
|
-
"@babel/plugin-proposal-decorators": "7.
|
|
30
|
-
"@babel/plugin-syntax-jsx": "^7.
|
|
31
|
-
"@babel/plugin-transform-runtime": "7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
33
|
-
"@babel/preset-react": "7.
|
|
34
|
-
"@babel/preset-typescript": "7.
|
|
35
|
-
"@babel/runtime": "^7.
|
|
36
|
-
"@babel/runtime-corejs3": "^7.14.
|
|
37
|
-
"@
|
|
38
|
-
"@tarojs/
|
|
29
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
30
|
+
"@babel/plugin-proposal-decorators": "^7.14.5",
|
|
31
|
+
"@babel/plugin-syntax-jsx": "^7.14.5",
|
|
32
|
+
"@babel/plugin-transform-runtime": "^7.14.5",
|
|
33
|
+
"@babel/preset-env": "^7.14.5",
|
|
34
|
+
"@babel/preset-react": "^7.14.5",
|
|
35
|
+
"@babel/preset-typescript": "^7.14.5",
|
|
36
|
+
"@babel/runtime": "^7.14.5",
|
|
37
|
+
"@babel/runtime-corejs3": "^7.14.5",
|
|
38
|
+
"@prefresh/babel-plugin": "^0.4.1",
|
|
39
|
+
"@tarojs/helper": "3.4.0-beta.2",
|
|
40
|
+
"@tarojs/taro-h5": "3.4.0-beta.2",
|
|
39
41
|
"@vue/babel-plugin-jsx": "^1.0.6",
|
|
40
42
|
"@vue/babel-preset-jsx": "^1.2.4",
|
|
41
|
-
"babel-plugin-dynamic-import-node": "
|
|
42
|
-
"babel-plugin-global-define": "
|
|
43
|
-
"babel-plugin-jsx-attributes-array-to-object": "
|
|
44
|
-
"babel-plugin-transform-imports-api": "
|
|
45
|
-
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.
|
|
46
|
-
"babel-plugin-transform-taroapi": "3.
|
|
43
|
+
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
44
|
+
"babel-plugin-global-define": "1.0.3",
|
|
45
|
+
"babel-plugin-jsx-attributes-array-to-object": "0.3.0",
|
|
46
|
+
"babel-plugin-transform-imports-api": "1.0.0",
|
|
47
|
+
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.4.0-beta.2",
|
|
48
|
+
"babel-plugin-transform-taroapi": "3.4.0-beta.2",
|
|
47
49
|
"core-js": "^3.6.5",
|
|
48
50
|
"metro-react-native-babel-preset": "^0.66.2",
|
|
49
51
|
"react-refresh": "0.9.0"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@tarojs/taro-rn": "3.
|
|
54
|
+
"@tarojs/taro-rn": "3.4.0-beta.2"
|
|
53
55
|
},
|
|
54
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "ac3eb29f11aec15d25e061775d9e970efabc2c98"
|
|
55
57
|
}
|
|
@@ -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
|
+
}
|