-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在 vite 中使用的问题 #75
Comments
请问你解决了吗 我也是在vite环境中无法自动解析ipa文件 么得办法让手动填写了 |
我没有很好解决这个问题 暂时采用的方案是引入一个Buffer 全局定义Buffer
解析失败是因为解析ipa时没有内置Buffer,出现的类型报错,引入之后可以绕过类型报错进行解析
但是我发现这样的解析方式会导致解析的ipa的icon有问题(因为ipa的icon是转化为buffer类型再解析的) 其他倒还好(不过我没有挨个核对字段)
希望对你有所帮助
import { Buffer } from 'buffer';
(window as any).global = window;
window.Buffer = window.Buffer || require('buffer').Buffer;
…------------------ 原始邮件 ------------------
发件人: "chenquincy/app-info-parser" ***@***.***>;
发送时间: 2022年5月26日(星期四) 中午11:13
***@***.***>;
***@***.******@***.***>;
主题: Re: [chenquincy/app-info-parser] 1.vite里无法使用require引入app-info-parser,不过可以通过添加‘vite-plugin-require-transform'支持 2.但是尽管引入了插件,在解析ipa文件时,没有内置Buffer,会出现解析失败的问题 (Issue #75)
请问你解决了吗 我也是在vite环境中无法自动解析ipa文件 么得办法让手动填写了
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@yangshenggirl @HeidaLay vite 还没有去适配过,不过看起来应该是打包的问题导致的,更优解是暂时采用 cdn 的方式去引入 app-info-parser。 |
可以用 unpkg 的 cdn 先试试: https://unpkg.com/browse/app-info-parser@1.1.3/dist/app-info-parser.min.js 。引入后直接使用全局变量 AppInfoParser 即可。 |
其实我也试过这种方法 但是不知道是不是基于ts的检验机制或者是我使用不太得当 但是不太成功
…------------------ 原始邮件 ------------------
发件人: "chenquincy/app-info-parser" ***@***.***>;
发送时间: 2022年5月26日(星期四) 中午1:07
***@***.***>;
***@***.******@***.***>;
主题: Re: [chenquincy/app-info-parser] 1.vite里无法使用require引入app-info-parser,不过可以通过添加‘vite-plugin-require-transform'支持 2.但是尽管引入了插件,在解析ipa文件时,没有内置Buffer,会出现解析失败的问题 (Issue #75)
可以用 unpkg 的 cdn 先试试: ***@***.***/dist/app-info-parser.min.js。引入后直接使用全局变量 AppInfoParser 即可。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
vite的编译使用的是另外一个开源的包rollup,开发时dev server是不会去使用cdn的代码的,只会引用我们安装的node_modules内部的代码,所以引入cdn之后使用AppInfoParser 会失败 |
我在node环境下解析没问题,在浏览器下解析ipa同样报“Buffer is not defined”,我看了下用的plist库的源码,https://github.com/TooTallNate/plist.js/blob/0a322c3918c7c0dc3d8ec36b3da98048b9b7dde3/lib/parse.js 这个文件第207行用了Buffer,我拷贝了它的源码,然后在浏览器环境(我的项目是用vite2和vue3搭建的)把Buffer类型改成uint8array就不会报错了 |
@yangshenggirl @arrosev 不好意思忘记跟进了,可以的话麻烦提供个最小的复现 demo,我看一下 |
|
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Node or Browser version (please complete the following information):
Package links for testing(downloadable links of the package, which making this issue)
描述 bug
请简明扼要的描述你所遇到的bug
复现
请描述复现该bug的步骤:
预期表现
请简明扼要的描述你所期望得到的效果
请填写您的Node或浏览器版本:
请提供测试用的安装包下载链接:
The text was updated successfully, but these errors were encountered: