fex-team / fis3

FIS3
http://fis.baidu.com
BSD 2-Clause "Simplified" License
2.79k stars 693 forks source link

_handle.Pngquant is not a constructor #1318

Closed ZhangHang12135 closed 3 years ago

ZhangHang12135 commented 3 years ago
ZhangHang12135 commented 3 years ago

同类问题 _handle.Pagcrush is not a constructor.

造成这个的原因,和版本有一定的关系。 主要原因还是这两个node图片压缩的版本选择代码有bug。

fis-optimizer-png-compressor 这个插件只是根据conf.type来选择使用node-pngquant-native 还是node-pngcrush.

这两个包的index.js中的部分代码
if (process.versions.node >= '10.0.0') { out = (new _handle.Pngquant(buffer, this.params)).compress(); } else if (process.versions.node >= '4.0.0') { out = (new _handle(buffer, this.params)).compress(); } else { var handle = new _handle.Pngquant(); out = handle.compress(buffer, this.params, function nope(){}); } 其中在低于10.x的版本下,只会执行第一段if中的代码。而不是按照预期在第二段if。原因就是字符串比对,是根据ASCII来比对的。

所以我们只要去除掉 if (process.versions.node >= '10.0.0') { out = (new _handle.Pngquant(buffer, this.params)).compress(); } 即可。

或者我们可以选择更新fis-optimizer-png-compressor中的node-pngquant-native 和 node-pngcrush版本到最新版也行。

ZhangHang12135 commented 3 years ago

或者将fis3 安装 3.4.39版本应该就可以了

oxUnd commented 3 years ago

确实有bug,依赖包的 bug 早前就修复了; fis3 的依赖版本应该还没有更新,后面更新一下;

HuiSha notifications@github.com 于2020年10月26日周一 上午11:27写道:

或者将fis3 安装 3.4.39版本应该就可以了

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fex-team/fis3/issues/1318#issuecomment-716281759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2DGY37JR33E3Q3WCMVSLSMTUBHANCNFSM4S6C4KNA .