v2.8.46
What's Changed in v2.8.46
New features
- New
createWorkeroption inconfigure()to create the web workers, taking precedence overworkerURI. It enables the standard bundler patternnew Worker(new URL("./zip-worker.js", import.meta.url), { type: "module" }), letting bundlers like webpack and Vite detect the worker script statically and compile it with its imports into a separate asset - New
initWorker()function exposed by the new@zip.js/zip.js/workerentry point to write custom worker scripts. It can register alternative implementations ofCompressionStream/DecompressionStreamused to compress/decompress data, e.g. based on fflate, and aninithook called with the configuration, e.g. to load a WebAssembly module. The API reference ofinitWorker()includes a complete example based on fflate. Existing custom worker scripts relying on theinitModuleconvention keep working - New
@zip.js/zip.js/lib/zip-core-custom.jsentry point offering the full API without embedding any web worker code or deflate implementation. Combined withcreateWorkerand a custom worker script, the compression engine of your choice ships only once, in the worker script - New
CompressionStreamFallbackandDecompressionStreamFallbackoptions inconfigure()replacing the deprecatedCompressionStreamZlibandDecompressionStreamZliboptions. The new names reflect the role of these implementations: the fallback used whenuseCompressionStreamis set tofalseor when the Compression Streams API is unavailable
Other changes
- New section in the documentation covering custom web workers and compression engines: https://gildas-lormeau.github.io/zip.js/#custom-workers
- The files embedding the web worker code and the WebAssembly module are now generated with rollup plugins instead of placeholder replacements, and the development and release build configurations have been merged
Full Changelog: v2.8.45...v2.8.46