babel-preset-taro 3.3.20 → 3.4.0-beta.3

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 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
- plugins.push([require('react-refresh/babel')])
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
 
@@ -159,6 +166,8 @@ module.exports = (_, options = {}) => {
159
166
  plugins.push([require('babel-plugin-dynamic-import-node')])
160
167
  }
161
168
 
169
+ plugins.push(require('./remove-define-config'))
170
+
162
171
  return {
163
172
  sourceType: 'unambiguous',
164
173
  overrides: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-taro",
3
- "version": "3.3.20",
3
+ "version": "3.4.0-beta.3",
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,30 @@
25
26
  "@babel/core": "*"
26
27
  },
27
28
  "dependencies": {
28
- "@babel/plugin-proposal-class-properties": "7.10.4",
29
- "@babel/plugin-proposal-decorators": "7.10.5",
30
- "@babel/plugin-syntax-jsx": "^7.10.4",
31
- "@babel/plugin-transform-runtime": "7.11.0",
32
- "@babel/preset-env": "^7.11.0",
33
- "@babel/preset-react": "7.12.13",
34
- "@babel/preset-typescript": "7.12.17",
35
- "@babel/runtime": "^7.11.2",
36
- "@babel/runtime-corejs3": "^7.14.8",
37
- "@tarojs/helper": "3.3.20",
38
- "@tarojs/taro-h5": "3.3.20",
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.3",
40
+ "@tarojs/taro-h5": "3.4.0-beta.3",
41
+ "@tarojs/taro-rn": "3.4.0-beta.3",
39
42
  "@vue/babel-plugin-jsx": "^1.0.6",
40
43
  "@vue/babel-preset-jsx": "^1.2.4",
41
- "babel-plugin-dynamic-import-node": "^2.3.3",
42
- "babel-plugin-global-define": "^1.0.3",
43
- "babel-plugin-jsx-attributes-array-to-object": "^0.3.0",
44
- "babel-plugin-transform-imports-api": "^1.0.0",
45
- "babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.3.20",
46
- "babel-plugin-transform-taroapi": "3.3.20",
44
+ "babel-plugin-dynamic-import-node": "2.3.3",
45
+ "babel-plugin-global-define": "1.0.3",
46
+ "babel-plugin-jsx-attributes-array-to-object": "0.3.0",
47
+ "babel-plugin-transform-imports-api": "1.0.0",
48
+ "babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.4.0-beta.3",
49
+ "babel-plugin-transform-taroapi": "3.4.0-beta.3",
47
50
  "core-js": "^3.6.5",
48
51
  "metro-react-native-babel-preset": "^0.66.2",
49
52
  "react-refresh": "0.9.0"
50
53
  },
51
- "devDependencies": {
52
- "@tarojs/taro-rn": "3.3.20"
53
- },
54
- "gitHead": "f98ceefaa3e419db5a6c3bcd3bf123ce5a0a0124"
54
+ "gitHead": "2ef7e8c10c9e5784e98bb1ad3a803d5fd6a46c8b"
55
55
  }
@@ -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
+ }