dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
39.97k stars 3.62k forks source link

引用pako这个库之后编译的时候报错 #4963

Open Lazybin opened 4 months ago

Lazybin commented 4 months ago

用了有pako依赖的包。 编译运行的时候报这个错误: [plugin:commonjs--resolver] Unbalanced delimiter found in string

参考了:

4524

对esbuildPrePlugin.js进行了修改,编译h5可以通过,但是编译app又会报这个错

Otto-J commented 4 months ago

嗯,这个问题似曾相识,是 pako 这个用到了 #ifdef xxx ,但是没有 endif 导致的对吧。

Lazybin commented 4 months ago

嗯,这个问题似曾相识,是 pako 这个用到了 #ifdef xxx ,但是没有 endif 导致的对吧。

我发现是pako包里有类似这样的注释

/*#ifdef NO_INIT_GLOBAL_POINTERS
  static_l_desc.static_tree = static_ltree;
  static_l_desc.extra_bits = extra_lbits;
  static_d_desc.static_tree = static_dtree;
  static_d_desc.extra_bits = extra_dbits;
  static_bl_desc.extra_bits = extra_blbits;
#endif*/

我修改成

//修改后
//#ifdef NO_INIT_GLOBAL_POINTERS
  static_l_desc.static_tree = static_ltree;
  static_l_desc.extra_bits = extra_lbits;
  static_d_desc.static_tree = static_dtree;
  static_d_desc.extra_bits = extra_dbits;
  static_bl_desc.extra_bits = extra_blbits;
//#endif

就可以了

Otto-J commented 4 months ago

link https://github.com/dcloudio/uni-app/issues/4524

Otto-J commented 4 months ago

清提供一个复现问题的单页面代码或者工程吧,我尝试修复下

Lazybin commented 2 months ago

不好意思 现在才看到 提供一个会报错的示例代码

<template>
    <view>
        <button @click="openDeviceText">
            加载
        </button>
    </view>
</template>
<script setup>
import { PDFDocument, StandardFonts, rgb } from 'pdf-lib'
</script>
<style lang="scss"></style>

直接就会报错。 用了pdf-lib库,他里面依赖了pako