rotemdan / lzutf8.js

A high-performance Javascript string compression library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: CommonJS or AMD dependencies can cause optimization bailouts.

CosminCraciun opened this issue · comments

I get this warning when I build:
Warning: CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Running with Angular 13.

Hi, this library was developed in 2014: before JS modules and WebAssembly even exited and before frameworks like Angular, React and even tools like Webpack became popular.

It runs some dynamic checks at runtime to decide if it is running in Node or in the browser and goes through different code paths accordingly. It seems that modern frameworks use sophisticated static analysis (they inspect the code without actually executing it) and detect various false positives due to this.

Overall the API has become outdated and requires a rewrite (the core compression / decompression routines are still useful, though they should be rewritten in a language like C or Rust and ported via WebAssembly).

I am not really developing this anymore. I don't have time or interest for that.

Also, it is not truly a "high-performance" library by modern standards (at least not anymore). It was designed to run very fast in native JavaScript, but the moment WebAssembly received wide browser support it enabled porting well established native libraries like zlib to execute at near-native performance (and with higher compression ratios).

The only reason it might be still useful is for compressing large number of short strings. Unfortunately in this case a JavaScript-only implementation most likely performs significantly worse than a WebAssembly one due to the inability to reuse allocated memory space (if I recall correctly it allocates a brand new hash table for every single string it compresses! That is not very cheap!).

Sorry for the long explanation!

I fully understand. Will start looking for an alternative.