Response compression middleware for the lws (local-web-server) framework, enabling gzip compression for HTTP responses. Current stable version is 3.1.0, compatible with Node.js >=12.17. It adds --compress and --compress.threshold CLI options to lws, with a default compression threshold of 1024 bytes. Published under the lwsjs organization, this middleware is a lightweight, focused solution for local development servers, following the standard.js code style.
npm install lws-compressVerified import paths — ran on the pinned version, not inferred.
Starts an lws server with response compression middleware, setting a custom compression threshold of 2048 bytes.
Use ESM imports (import compress from 'lws-compress') or upgrade to Node.js >=12.17 and set type: 'module' in package.json. For CJS, use dynamic import: const compress = (await import('lws-compress')).default.Use default import only: import compress from 'lws-compress'.
Ensure threshold is specified in bytes (e.g., 1024 for 1KB).
Use --compress (or -z) when launching lws, or pass compress: true in lws options.
Check lws documentation for compressible content types or implement custom logic.
Use default import: import compress from 'lws-compress'
Switch to ESM: use import or type: 'module' in package.json. Or use dynamic import: const compress = (await import('lws-compress')).defaultEnsure you use default import: import compress from 'lws-compress' or const compress = require('lws-compress').default