fix: 修复 使用了三方插件时,用 HBuilderX 发行打包 easycom 不生效的问题 #4911
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
开发微信小程序的时候,在项目下的 vite.config 里使用了 @dcloudio/vite-plugin-uni 插件时,开发运行没有问题,但是发行打包时 easycom 会不生效,easycom 里的组件不会打包到项目里,原因分析如下:
initEasycom 是在项目下的 vite.config 运行的
而 HBuilderX下的 @dcloudio/vite-plugin-uni 读取不到它的值
uni-app/packages/uni-cli-shared/src/easycom.ts
Line 190 in 7ea7d03
所以此时 hasEasycom 还是 false,直接返回了:
uni-app/packages/uni-cli-shared/src/easycom.ts
Line 191 in 7ea7d03
导致 source 没有值,未定义:
uni-app/packages/uni-mp-compiler/src/codegen.ts
Line 221 in 7ea7d03