Open 5d-jh opened 1 year ago
yes, pako.js is needed only for encoding, not for decoding. You can manually delete the encoding parts from the UPNG.js file.
Yes, for now I'm using this library with encoding parts deleted.
But for everyone(including me) that want to use tree-shaked version, removing implementatinos that are not familiar with doesn't seem right.
Since this library doesn't have a lot of functions, it can be easily done. If you are okay with this, may I take over this issue?
What are your plans? Do you want to make two files? There are certain parts needed both by an encoder and by a decoder.
No I'm not separating into multiple files. Just going to use export
clause to each public function so let bundlers know which parts of the code are actually used.
This is example of tree-shakable version that I was talking of:
import pako from 'pako';
export function encode() {
...
someInternal()
}
export function decode() {
pako.dosomething();
someInternal()
...
}
function someInternal() {
...
}
My plan is to publish tree-shakable version as v3, and keep current version stay in v2 to prevent you from forcing adopt new toolchains(webpack, npm, etc...).
I can not use that code, as I want my program to be written in Javascript
That's not true.
export
is part of JavaScript syntax, and can be used on any platform(browser, nodejs) right in.
see JavaScript modules and Tree shaking.
I also think to use pako
makes this package bigger than it needs, can't you use something like:
https://www.npmjs.com/package/fflate
I made a fork and changed the module to fflate
https://github.com/lvcabral/UPNG.js
Hey guys! I found this project while testing photopea (also, great work on it @photopea!)
About the bundle size, if UPNG is tree-shakeable this will save almost 75% of the bundle size:
@photopea please take a look at this:
@danielbarion I am so confused. The UPNG.js library is 46.6 kB now, and it is 14.5 kB GZipped. If you want it to be small, do not use that tool that you are referring to.
Similar to this issue
I'm using this library with bundled by Webpack.
In my case, I only use
decode
function. However since this library is wrapped by an object, bundled file includespako
which seems not used when decoding.This results unnecessary large bundle size.