rotemdan / lzutf8.js

A high-performance Javascript string compression library
MIT License
322 stars 26 forks source link

Warning: CommonJS or AMD dependencies can cause optimization bailouts. #45

Closed CosminCraciun closed 2 years ago

CosminCraciun commented 2 years ago

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.

rotemdan commented 2 years ago

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!

CosminCraciun commented 2 years ago

I fully understand. Will start looking for an alternative.