我将所有 npm 包缩小 5%的失败尝试

  • In 2022, the author had an idea to decrease npm package sizes by 5% using Zopfli, which is a gzip-compatible compressor that creates smaller files but is slower. npm packages are distributed as gzipped tarballs.

    • Proof of concept: The author tested on their own npm packages and found a 6.2% reduction in size with Zopfli, and it was backwards compatible. They also published one module this way without issues.
  • On 2022-05-27, the author asked colleagues for feedback on compressing the entire npm registry with Zopfli. They got feedback that decompression time could be significant and npm's lockfile couldn't handle re-compressing existing packages easily.
  • On 2022-05-29, the author submitted an RFC "Improving tarball compression while maintaining backwards compatibility" with 708 words.
  • On 2022-06-01, the npm CLI people discussed the RFC and felt it was worth evaluating further but cautious. The author built a proof of concept web app and attended the next meeting.
  • On 2022-06-15, in the meeting, the author was wordy and unclear but made the point that npm packages could be 5% smaller with Zopfli at publish time. Questions like "Who benefits?" and concerns about WebAssembly, performance, and licensing were discussed. The author was tasked with some investigations.
  • On 2022-07-31, after research and discussion, the author posted a comment on the RFC with pros and cons. The pros were a 4.5% size reduction for the top 250 npm packages and backwards compatibility. The cons were difficulties in integrating Zopfli, slower publishing, and not applying retroactively. The author closed the RFC.
  • Lessons learned: The author learned about making proposals, verbal communication during meetings, and that obvious wins may have trade-offs. They are still compressing their own modules with Zopfli.
阅读 8
0 条评论