Isolating parts of the library using Terser #73
-
Dear @101arrowz Hey! I need to isolate parts of this library, preferably keeping the type annotations, but a JS output would be ok too. For example, I want to "dump" the Inflate and Deflate functions into their own modules. Normally I would just do this manually, but having all the exported members in a single file, plus using short names makes the code a bit hard to follow (at least for my extraction purposes). Can some of this process be automated using Terser? It could be similar to those small bundles which only export a limited set of features. Is it possible to get a clean un-minified output? Do you have a config or template project to share? I read in another thread that you already have some of these small builds but chose not to provide them due to the (understandably) wide range of possible configurations. I want to generate one of these configurations myself. Thanks for the great lib! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
To generate custom builds myself, I usually run the build through Unrelated, but I'm curious why you don't just use bindings to native Zlib written in Lua. They would probably be faster than |
Beta Was this translation helpful? Give feedback.
To generate custom builds myself, I usually run the build through
terser
. You can just paste the CJS build into a text editor, then find+replace all the exports with nothing (e.g. with the regexexports.*;$
and manually removingexports.FlateErrorCode
). Now, manually write the exports you want at the bottom (e.g.exports.unzipSync = unzipSync;
), then plug it throughterser
(since I'm lazy I use terser-online). Now you have a minified file that contains the exports, and you can use the TypeScript declaration file provided withfflate
to plug it through TypescriptToLua.Unrelated, but I'm curious why you don't just use bindings to native Zlib written in Lua. They would probably be faster than