夫子仰慕者
夫子仰慕者
  • 发布:2024-07-24 10:32
  • 更新:2024-10-28 17:50
  • 阅读:408

【报Bug】uniapp vue3 使用pako库直接无法运行

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: iOS14

手机系统: Android

手机系统版本号: Android 14

手机厂商: 华为

手机机型: 荣耀

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: CLI

CLI版本号: @vue/cli 4.5.19

示例代码:

<template>
<view class="content">
<image class="logo" src="/static/logo.png" />
<view class="text-area">
<text class="title">{{ title }}</text>
</view>
</view>
</template>

<script lang="ts">
import pako from 'pako';
import { ref } from 'vue'
const title = ref('Hello')
</script>

<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}

.text-area {
display: flex;
justify-content: center;
}

.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

操作步骤:

运行必现,

预期结果:

可以正常使用pako库

实际结果:

无法运行

bug描述:

请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。
vite是按需编译,运行时点击某个未编译页面会先编译后加载,导致显示较慢,发行后无此问题。
编译器版本:4.24(vue3)
正在编译中...
Port 5173 is in use, trying another one...

vite v5.2.8 dev server running at:

➜ Local: http://localhost:5174/
➜ Network: http://10.210.63.177:5174/

ready in 5814ms.

✘ [ERROR] Unbalanced delimiter found in string [plugin uni:dep-scan]

node_modules/xregexp/src/addons/matchrecursive.js:176:22:  
  176 │                 throw new Error('Unbalanced delimiter found in string');  
      ╵                       ^  

at Function.XRegExp.matchRecursive (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/xregexp/src/addons/matchrecursive.js:176:23)  
at matchReplacePass (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-cli-shared/lib/preprocess/lib/preprocess.js:310:27)  
at replaceRecursive (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-cli-shared/lib/preprocess/lib/preprocess.js:340:10)  
at preprocessor (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-cli-shared/lib/preprocess/lib/preprocess.js:165:10)  
at preprocess (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-cli-shared/lib/preprocess/lib/preprocess.js:89:10)  
at preJs (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-cli-shared/dist/preprocess/index.js:13:12)  
at /Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-h5-vite/dist/plugin/esbuild/esbuildPrePlugin.js:22:63  
at requestCallbacks.on-load (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:1435:28)  
at handleRequest (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:732:17)  
at handleIncomingPacket (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:757:7)  

This error came from the "onLoad" callback registered here:

node_modules/@dcloudio/uni-h5-vite/dist/plugin/esbuild/esbuildPrePlugin.js:15:18:  
  15 │             build.onLoad({ filter: exports.JS_TYPES_RE }, ({ path: id }) => {  
     ╵                   ~~~~~~  

at setup (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/@dcloudio/uni-h5-vite/dist/plugin/esbuild/esbuildPrePlugin.js:15:19)  
at handlePlugins (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:1293:21)  
at buildOrContextImpl (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:979:5)  
at Object.buildOrContext (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:788:5)  
at /Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:2224:68  
at new Promise (<anonymous>)  
at Object.context (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:2224:27)  
at Object.context (/Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/esbuild/lib/main.js:2048:58)  
at prepareEsbuildOptimizerRun (file:///Users/xiezhenggen/AndroidStudioProjects/HBuilderProjects/2024/07/my-vue3-07-24/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:52821:35)  

10:21:46 [vite] Build failed with 1 error:
node_modules/xregexp/src/addons/matchrecursive.js:176:22: ERROR: [plugin: uni:dep-scan] Unbalanced delimiter found in string

2024-07-24 10:32 负责人:无 分享
已邀请:
BFC

BFC

你好, 这个是因为pako库的内部注释和 uniapp的条件注释冲突导致的。

临时解决方案是,你可以将pako库的pako.esm.mjs 的注释移除掉。

  • 夫子仰慕者 (作者)

    好的,我试试

    2024-07-29 17:32

  • 夫子仰慕者 (作者)

    那后期uniapp会修复吗

    2024-07-29 17:36

  • BFC

    回复 夫子仰慕者: 后期会修复

    2024-07-29 17:45

  • 7***@qq.com

    回复 BFC: 能说清楚下是哪部分注释吗

    2024-08-07 15:54

  • BFC

    回复 7***@qq.com: #ifdef, #ifndef, #endif 这类的注释

    2024-08-07 15:59

  • 夫子仰慕者 (作者)

    回复 BFC: 那这个问题,多久会修复呢

    2024-08-08 08:42

2***@qq.com

2***@qq.com - 搬砖人员

哥,您解决了吗?就删除了注释就可以了吗?

  • 夫子仰慕者 (作者)

    删除内容还是不行,在等官方修复

    2024-08-08 08:41

  • BFC

    删除了注释还是不行么。 发一下错误信息提示

    2024-08-08 13:05

  • 夫子仰慕者 (作者)

    回复 BFC: 删除了是可以了用,但是这个BUG什么时候修复呢

    2024-10-08 09:44

夫子仰慕者

夫子仰慕者 (作者) - 厉害了吧

@DCloud_HB_WJ @DCloud_HB_DYF 这个问题好像现在还没修复

要回复问题请先登录注册