Thank you for contributing to Condense! Please review this document before submitting issues or pull requests.
- Clone the repository:
git clone https://github.com/studioframes/Condense.git cd Condense - Install dependencies:
npm install
- Smoke-test the published CLI entry point locally:
You can also use
npx @studioframes/condense
npm startas a local shorthand for the same CLI runner. - Run the test suite:
npm test
Because Condense is distributed as an npm package, you must maintain compatibility across its public integration paths:
- No Local Disk Access First: Do not write temporary files to the disk (
/tmp,multer.diskStorage, etc.) by default. Use pure in-memory Buffers and Node Streams to maintain statelessness. (Exception: Very specific structural overrides like MP4 faststart which strictly require file buffering). - Keep Core Helpers Modular: Ensure helper files inside
src/services/are decoupled from Express HTTP objects (req,res) so they can still be safely imported programmatically. - Respect Bypass Directives: If adding new language processors, ensure they respect bypass parameters or check for
data-condense-ignore//* condense-ignore */patterns. - Support Three Quality Tiers: When implementing new optimizers, always handle
quality,balanced, andextrememethods appropriately. - Update Tests: When modifying service functions, add or update corresponding tests in the
tests/folder. Runnpm testto verify all tests pass.
Condense uses Node's built-in test framework. Tests live in the tests/ directory and cover:
- imageService.test.js — Image optimization, perceptual SSIM search, responsive matrix generation
- textService.test.js — Code/markup minification (JS, CSS, HTML, XML, YAML, ignore directives)
- mediaService.test.js — Media streaming (audio/video processing, error handling)
- esbuildService.test.js — TypeScript and React minification tests
- wasmService.test.js — WebAssembly stripping tests
- cacheService.test.js — LRU caching tests
- archiveService.test.js — In-memory ZIP archive decompression and recompression
- fontService.test.js — SFNT/WOFF OpenType font metadata table stripping
- pdfService.test.js — In-memory PDF comment and stream compression
- pipelineService.test.js — Fluent chainable pipeline processing
- presetService.test.js — Preset resolution and custom recipe registration
- ssimService.test.js — SSIM and PSNR image quality calculations
- svgSpriteService.test.js — SVG symbol spritesheet packing
- telemetryService.test.js — Telemetry, byte savings, ROI, and carbon tracking
- tokenManglingService.test.js — Coordinated HTML/CSS/JS token shortening
- workerPool.test.js — Worker thread pool parallel task dispatching
- helpers.js — Shared test utilities
Tests are development-only and excluded from published npm packages via .npmignore.
Condense uses Prettier for automatic code formatting. Before committing, run:
npm run formatThis ensures consistent code style across the project (2-space indentation, single quotes, semicolons).
Condense uses ESLint to catch bugs and code quality issues:
npm run lintCommon issues caught: unused variables, unreachable code, inconsistent spacing, and more.
Before submitting a PR, ensure:
npm run lint # No linting errors
npm run format # Code is formatted
npm test # All tests pass
npm run build # Current repository build step remains valid- Fork the repo and create your branch from
main. - Commit your changes and ensure they don't break existing package exports.
- Run
npm run lintto check for code quality issues. - Run
npm run formatto auto-format code. - Run
npm testto verify all tests pass before submitting a PR. - Submit a Pull Request targeting
main.