Skip to content

Commit

Permalink
[merge]merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderXL committed Jan 10, 2025
2 parents 4418593 + d9e76ac commit 4ded781
Show file tree
Hide file tree
Showing 278 changed files with 10,331 additions and 5,470 deletions.
20 changes: 13 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ module.exports = {
sourceType: 'module'
},
extends: 'standard',
plugins: [
'html',
'jest'
],
plugins: ['html', 'jest'],
globals: {
wx: 'readonly',
my: 'readonly',
Expand All @@ -21,6 +18,7 @@ module.exports = {
Component: 'readonly',
Page: 'readonly',
App: 'readonly',
Mixin: 'readonly',
__mpx_mode__: 'readonly',
__mpx_env__: 'readonly',
__mpx_dynamic_runtime__: 'readonly',
Expand All @@ -30,7 +28,8 @@ module.exports = {
rules: {
'no-cond-assign': 0,
camelcase: 0,
indent: 0
indent: 0,
'symbol-description': 0
},
env: {
'jest/globals': true,
Expand All @@ -43,7 +42,7 @@ module.exports = {
extends: [
'standard',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended'
],
plugins: ['@typescript-eslint'],
rules: {
Expand All @@ -53,7 +52,14 @@ module.exports = {
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/no-unused-vars': 0,
camelcase: 0,
'@typescript-eslint/no-non-null-assertion': 0,
camelcase: 0
}
}, {
files: ['packages/webpack-plugin/lib/runtime/components/react/**/*.{js,jsx,ts,tsx}'],
plugins: ['react-hooks'],
rules: {
'react-hooks/rules-of-hooks': 'error'
}
}
]
Expand Down
3 changes: 2 additions & 1 deletion docs-vuepress/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const sidebar = {
'advance/plugin',
'advance/custom-output-path',
'advance/utility-first-css',
'advance/ssr'
'advance/ssr',
'advance/provide-inject'
]
},
{
Expand Down
22 changes: 21 additions & 1 deletion docs-vuepress/api/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mode 为 Mpx 编译的目标平台, 目前支持的有微信小程序(wx)\支
// 项目 package.json
{
"script": {
"build:cross": "mpx-cli-service build:mp --targets=wx,ali"
"build:cross": "mpx-cli-service build --targets=wx,ali"
}
}
```
Expand Down Expand Up @@ -965,6 +965,7 @@ module.exports = defineConfig({
}
})
```
**注意:** 建议使用`autoVirtualHostRules`配置项,不要使用微信组件内部的 options virtualHost 配置,因为组件内部的 options virtualHost 在跨平台输出时无法进行兼容抹平处理。

### partialCompileRules

Expand Down Expand Up @@ -1096,6 +1097,25 @@ module.exports = defineConfig({
})
```

### disableRequireAsync

`boolean = false`

Mpx 框架在输出 微信小程序、支付宝小程序、字节小程序、Web 平台时,默认支持分包异步化能力,但若在某些场景下需要关闭该能力,可配置该项。

```js
// vue.config.js
module.exports = defineConfig({
pluginOptions: {
mpx: {
plugin: {
disableRequireAsync: true
}
}
}
})
```

### optimizeSize

`boolean = false`
Expand Down
55 changes: 49 additions & 6 deletions docs-vuepress/api/extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,17 +459,58 @@ useFetch().fetch({
| ------------- |:-----:| :-----:| :-----: | :-----: |
| getSystemInfo|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getSystemInfoSync|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getDeviceInfo|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getWindowInfo|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getLaunchOptionsSync|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getEnterOptionsSync|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| nextTick |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| showToast |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| hideToast |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| showModal |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| showLoading |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| hideLoading |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| showActionSheet |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| createAnimation |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| onAppShow |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| onAppHide |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| offAppShow |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| offAppHide |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| onError |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| offError |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| onUnhandledRejection |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| offUnhandledRejection |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| createInnerAudioContext |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| closeBLEConnection |:white_check_mark:|:white_check_mark:|:x:|:x:|
| createBLEConnection |:white_check_mark:|:white_check_mark:|:x:|:x:|
| onBLEConnectionStateChange |:white_check_mark:|:white_check_mark:|:x:|:x:|
| createIntersectionObserver |:white_check_mark:|:white_check_mark:|:x:|:x:|
| createSelectorQuery |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getExtConfig |:white_check_mark:|:white_check_mark:|:x:|:x:|
| getExtConfigSync |:white_check_mark:|:white_check_mark:|:x:|:x:|
| onKeyboardHeightChange |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| offKeyboardHeightChange |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| hideKeyboard |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| getLocation |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| openLocation |:white_check_mark:|:white_check_mark:|:x:|:x:|
| chooseLocation |:white_check_mark:|:white_check_mark:|:x:|:x:|
| pageScrollTo |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| stopPullDownRefresh |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| startPullDownRefresh |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| redirectTo |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| navigateTo |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| navigateBack |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| reLaunch |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| switchTab |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| setTabBarItem |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| setTabBarStyle |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| showTabBar |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| hideTabBar |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| vibrateShort |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| vibrateLong |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| showNavigationBarLoading |:white_check_mark:|:white_check_mark:|:x:|:x:|
| hideNavigationBarLoading |:white_check_mark:|:white_check_mark:|:x:|:x:|
| setNavigationBarTitle |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| setNavigationBarColor |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
| setNavigationBarTitle |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| setNavigationBarColor |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| request |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| downloadFile |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|:x:|
| uploadFile |:white_check_mark:|:white_check_mark:|:x:|:x:|
Expand All @@ -487,6 +528,7 @@ useFetch().fetch({
| previewImage |:white_check_mark:|:white_check_mark:|:x:|:x:|
| compressImage |:white_check_mark:|:white_check_mark:|:x:|:x:|
| chooseImage |:white_check_mark:|:white_check_mark:|:x:|:x:|
| getImageInfo |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| getLocation |:white_check_mark:|:white_check_mark:|:x:|:x:|
| saveFile |:white_check_mark:|:white_check_mark:|:x:|:x:|
| removeSavedFile |:white_check_mark:|:white_check_mark:|:x:|:x:|
Expand All @@ -495,8 +537,8 @@ useFetch().fetch({
| addPhoneContact |:white_check_mark:|:white_check_mark:|:x:|:x:|
| setClipboardData |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| getClipboardData |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| setScreenBrightness |:white_check_mark:|:white_check_mark:|:x:|:x:|
| getScreenBrightness |:white_check_mark:|:white_check_mark:|:x:|:x:|
| setScreenBrightness |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| getScreenBrightness |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| makePhoneCall |:white_check_mark:|:white_check_mark:|:x:|:white_check_mark:|
| stopAccelerometer |:white_check_mark:|:white_check_mark:|:x:|:x:|
| startAccelerometer |:white_check_mark:|:white_check_mark:|:x:|:x:|
Expand All @@ -522,6 +564,7 @@ useFetch().fetch({
| getNetworkType |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| onNetworkStatusChange |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| offNetworkStatusChange |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
| createVideoContext |:white_check_mark:|:white_check_mark:|:white_check_mark:|:x:|
## webview-bridge
Mpx 支持小程序跨平台后,多个平台的小程序里都提供了 webview 组件,webview 打开的 H5 页面可以通过小程序提供的 API 来与小程序通信以及调用一些小程序的能力,但是各家小程序对于 webview 提供的API是不一样的。

Expand Down Expand Up @@ -773,8 +816,8 @@ Mpx框架项目包体积可以进行分组、分包、页面、冗余Npm包等
entryRules: {
include: ['@somegroup/someSdk/index', '@somegroup/someSdk2/index']
},
// 有的时候你可能希望计算纯 js 入口引入的体积(不包含组件和页面),这种情况下需要使用 noEntryModules
noEntryModules: {
// 有的时候你可能希望计算纯 js 入口引入的体积(不包含组件和页面),这种情况下需要使用 noEntryRules
noEntryRules: {
include: 'src/lib/sdk.js'
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs-vuepress/articles/unit-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In computer programming, unit testing is a software testing method by which indi
- 改进设计,促进重构

此外,单测高覆盖率的项目也会给公司节省大量支出:
![unit-test-money.png](https://cdn.nlark.com/yuque/0/2021/png/116604/1640872105786-b7b230b4-7f65-4a0f-8dbf-e8ba89f61837.png#averageHue=%23fcfbfa&clientId=u39d6bb3b-719d-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=577&id=u3d713c30&margin=%5Bobject%20Object%5D&name=unit-test-money.png&originHeight=1153&originWidth=2770&originalType=binary&ratio=1&rotation=0&showTitle=false&size=227658&status=done&style=none&taskId=u33caf2b6-ceb2-43ca-9da2-c631d845598&title=&width=1385)
![unit-test-money.png](https://cdn.nlark.com/yuque/0/2021/png/116604/1640872105786-b7b230b4-7f65-4a0f-8dbf-e8ba89f61837.png)
据微软统计单测效益结果,如上图展示,绝大多数bug都是在coding阶段产生,并且随着需求开发进度的推进,修复bug的成本会随指数级增长,当我们在unit test阶段发现并修复这个bug是能给公司带来巨大收益的。

下方介绍两种常见的项目单元测试规范:
Expand Down
9 changes: 8 additions & 1 deletion docs-vuepress/guide/advance/async-subpackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

具体功能介绍和功能目的可 [点击查看](https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/async.html), Mpx对于分包异步化功能进行了完整支持。

当前 Mpx 框架默认支持以下平台的分包异步化能力:
* 微信小程序
* 支付宝小程序
* 字节小程序
* Web

在非上述平台,异步分包代码会默认降级。

## 跨分包自定义组件引用
>一个分包使用其他分包的自定义组件时,由于其他分包还未下载或注入,其他分包的组件处于不可用的状态。通过为其他分包的自定义组件设置 占位组件,
我们可以先渲染占位组件作为替代,在分包下载完成后再进行替换。
Expand Down Expand Up @@ -88,5 +96,4 @@ require.async('../commonPackage/index.js?root=subPackageB').then(pkg => {
})
</script>
```
- 注意项:目前该能力仅微信平台下支持,其他平台下框架将会自动降级

3 changes: 2 additions & 1 deletion docs-vuepress/guide/advance/custom-output-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ module.exports = defineConfig({
pluginOptions: {
mpx: {
plugin: {
customOutputPath: (type, name, hash, ext) => {
customOutputPath: (type, name, hash, ext, resourcePath) => {
// type: 资源类型(page | component | static)
// name: 资源原有文件名
// hash: 8位长度的hash串
// ext: 文件后缀(.js| .wxml | .json 等)
// resourcePath: 资源路径

// 输出示例: pages/testax34dde3/index.js
return path.join(type + 's', name + hash, 'index' + ext)
Expand Down
2 changes: 1 addition & 1 deletion docs-vuepress/guide/advance/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ new MpxwebpackPlugin({
// 项目 package.json
{
"script": {
"build:cross": "mpx-cli-service build:mp --targets=wx,ali"
"build:cross": "mpx-cli-service build --targets=wx,ali"
}
}
```
Expand Down
Loading

0 comments on commit 4ded781

Please sign in to comment.