babel-preset-taro 3.5.6 → 3.5.7

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.
Files changed (2) hide show
  1. package/index.js +21 -1
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -1,4 +1,24 @@
1
1
  const path = require('path')
2
+ const fs = require('fs')
3
+
4
+ function hasBrowserslist () {
5
+ const root = process.cwd()
6
+ try {
7
+ const pkg = require(path.resolve(root, 'package.json'))
8
+ if (pkg.browserslist) {
9
+ return true
10
+ }
11
+ } catch {
12
+ //
13
+ }
14
+ if (fs.existsSync(path.resolve(root, '.browserslistrc'))) {
15
+ return true
16
+ }
17
+ if (process.env.BROWSERSLIST) {
18
+ return true
19
+ }
20
+ return false
21
+ }
2
22
 
3
23
  module.exports = (_, options = {}) => {
4
24
  if (process.env.TARO_ENV === 'rn') {
@@ -101,7 +121,7 @@ module.exports = (_, options = {}) => {
101
121
  targets = rawTargets
102
122
  } else if (ignoreBrowserslistConfig) {
103
123
  targets = { node: 'current' }
104
- } else {
124
+ } else if (!hasBrowserslist()) {
105
125
  targets = {
106
126
  ios: '9',
107
127
  android: '5'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-taro",
3
- "version": "3.5.6",
3
+ "version": "3.5.7",
4
4
  "description": "Taro babel preset",
5
5
  "author": "yuche <i@yuche.me>",
6
6
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/babel-preset-taro#readme",
@@ -28,15 +28,15 @@
28
28
  "@babel/preset-typescript": "^7.14.5",
29
29
  "@babel/runtime": "^7.14.5",
30
30
  "@babel/runtime-corejs3": "^7.14.5",
31
- "@tarojs/helper": "3.5.6",
32
- "@tarojs/taro-h5": "3.5.6",
31
+ "@tarojs/helper": "3.5.7",
32
+ "@tarojs/taro-h5": "3.5.7",
33
33
  "babel-plugin-dynamic-import-node": "2.3.3",
34
34
  "babel-plugin-global-define": "1.0.3",
35
35
  "babel-plugin-jsx-attributes-array-to-object": "0.3.0",
36
36
  "babel-plugin-minify-dead-code-elimination": "^0.5.2",
37
37
  "babel-plugin-transform-imports-api": "1.0.0",
38
- "babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.5.6",
39
- "babel-plugin-transform-taroapi": "3.5.6",
38
+ "babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.5.7",
39
+ "babel-plugin-transform-taroapi": "3.5.7",
40
40
  "core-js": "^3.6.5",
41
41
  "metro-react-native-babel-preset": "^0.70.3"
42
42
  },