Skip to content

Commit e1aa8a8

Browse files
authored
fix: 修复支付宝小程序开发预览报错问题 (#16715)
* chore: 补全缺失的依赖 #16515 * feat(alipay): 新增 browserslist 配置 #16560
1 parent 5148dd6 commit e1aa8a8

File tree

9 files changed

+74
-9
lines changed

9 files changed

+74
-9
lines changed

packages/taro-cli/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"dependencies": {
4444
"@tarojs/binding": "workspace:*",
4545
"@tarojs/helper": "workspace:*",
46+
"@tarojs/plugin-doctor": "^0.0.13",
4647
"@tarojs/service": "workspace:*",
4748
"@tarojs/shared": "workspace:*",
48-
"@tarojs/plugin-doctor": "^0.0.13",
4949
"adm-zip": "^0.5.12",
5050
"axios": "^1.6.8",
5151
"cli-highlight": "^2.1.11",
@@ -60,11 +60,11 @@
6060
},
6161
"devDependencies": {
6262
"@babel/types": "^7.24.0",
63-
"@tarojs/taro": "workspace:*",
64-
"@tarojs/plugin-platform-weapp": "workspace:*",
6563
"@tarojs/plugin-platform-h5": "workspace:*",
64+
"@tarojs/plugin-platform-weapp": "workspace:*",
65+
"@tarojs/taro": "workspace:*",
6666
"@tarojs/webpack5-runner": "workspace:*",
67-
"@types/babel__traverse": "^7.20.2",
67+
"@types/babel__traverse": "^7.20.6",
6868
"babel-preset-taro": "workspace:*",
6969
"eslint-plugin-react": "^7.34.1",
7070
"eslint-plugin-react-hooks": "^4.4.0"

packages/taro-cli/src/util/createPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { babelKit } from '@tarojs/helper'
22

33
import { ConfigModificationState, ModifyCallback } from '../create/page'
44

5-
import type { NodePath } from '@babel/traverse'
65
import type { ArrayExpression, ExportDefaultDeclaration, ObjectExpression, ObjectProperty } from '@babel/types'
6+
import type { NodePath } from 'babel__traverse'
77

88
const t = babelKit.types
99

packages/taro-extend/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@
2222
},
2323
"engines": {
2424
"node": ">= 18"
25+
},
26+
"devDependencies": {
27+
"@tarojs/runtime": "workspace:*",
28+
"@tarojs/taro": "workspace:*"
29+
},
30+
"peerDependencies": {
31+
"@tarojs/runtime": "workspace:*",
32+
"@tarojs/taro": "workspace:*"
2533
}
2634
}

packages/taro-platform-alipay/src/program.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default class Alipay extends TaroPlatformBase {
3636
this.modifyMiniConfigs()
3737
this.modifyComponents()
3838
this.modifyWebpackConfig()
39+
this.generateBrowserslistConfig()
3940
this.generateProjectConfig('project.alipay.json', 'mini.project.json')
4041
}
4142
})
@@ -106,4 +107,19 @@ export default class Alipay extends TaroPlatformBase {
106107
})
107108
})
108109
}
110+
111+
/**
112+
* 生成 .browserslistrc 文件以解决支付宝小程序开发工具报错问题。
113+
* 详情请参阅:https://github.com/NervJS/taro/issues/16560
114+
*/
115+
generateBrowserslistConfig () {
116+
this.ctx.modifyBuildAssets(({ assets }) => {
117+
const browserslistStr = 'defaults and fully supports es6-module'
118+
119+
assets['.browserslistrc'] = {
120+
size: () => browserslistStr.length,
121+
source: () => browserslistStr
122+
}
123+
})
124+
}
109125
}

packages/taro-platform-tt/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
"engines": {
3030
"node": ">= 18"
3131
},
32+
"dependencies": {
33+
"webpack-sources": "^3.2.3"
34+
},
3235
"devDependencies": {
3336
"@tarojs/components": "workspace:*",
3437
"@tarojs/service": "workspace:*",
3538
"@tarojs/shared": "workspace:*"
3639
},
3740
"peerDependencies": {
38-
"@tarojs/shared": "workspace:*",
39-
"@tarojs/service": "workspace:*"
41+
"@tarojs/service": "workspace:*",
42+
"@tarojs/shared": "workspace:*"
4043
}
4144
}

packages/taro-router-rn/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@react-navigation/native-stack": "^6.3.29",
3636
"@react-navigation/routers": "^6.1.9",
3737
"@react-navigation/stack": "^6.3.29",
38+
"lodash": "^4.17.21",
3839
"query-string": "^9.0.0",
3940
"react-native-gesture-handler": "^2.16.0",
4041
"react-native-safe-area-context": "4.5.0",

packages/taro-transformer-wx/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
"@babel/types": "^7.24.0",
4444
"@tarojs/helper": "workspace:*",
4545
"babel-eslint": "^10.0.1",
46+
"babel-helper-evaluate-path": "^0.5.0",
47+
"babel-helper-mark-eval-scopes": "^0.4.3",
48+
"babel-helper-remove-or-void": "^0.4.3",
4649
"babel-plugin-preval": "^5.1.0",
4750
"babel-plugin-transform-define": "^2.1.4",
4851
"eslint": "^8.57.0",

packages/taroize/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@tarojs/helper": "workspace:*",
6565
"@tarojs/shared": "workspace:*",
6666
"himalaya-wxml": "^1.1.0",
67+
"html": "^1.0.0",
6768
"lodash": "^4.17.21",
6869
"prettier": "^2.8.8"
6970
},

pnpm-lock.yaml

Lines changed: 35 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)