Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
optimizeFile
✓ import { optimizeFile } from 'squeezit'
✗ const { optimizeFile } = require('squeezit')
The primary API functions are ESM-first. While CJS might work via transpilation, direct require is not the idiomatic usage.
squeezitGulp
✓ import { squeezitGulp } from 'squeezit/gulp'
✗ import squeezitGulp from 'squeezit/gulp'
Gulp plugin is a named export from its specific subpath.
registerSqueezitTask
✓ const { registerSqueezitTask } = require('squeezit/grunt')
✗ import { registerSqueezitTask } from 'squeezit/grunt'
The Grunt plugin is designed for CommonJS `require` due to typical Gruntfile environments.
squeezitVite
✓ import { squeezitVite } from 'squeezit/vite'
✗ const { squeezitVite } = require('squeezit/vite')
Vite plugin is a named ESM export.
Demonstrates programmatic image optimization using the core `optimizeFile` API, creating a temporary file and reporting optimization results.
import { optimizeFile } from 'squeezit';
import { promises as fs } from 'fs';
import path from 'path';
async function runOptimization() {
const imagePath = path.join(process.cwd(), 'example.png');
const outputPath = path.join(process.cwd(), 'optimized-example.png');
// Create a dummy image file for demonstration if it doesn't exist
try {
await fs.access(imagePath);
} catch (error) {
console.log(`Creating dummy file at ${imagePath}`);
// Minimal PNG base64 representation (1x1 transparent PNG)
const dummyPngBuffer = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', 'base64');
await fs.writeFile(imagePath, dummyPngBuffer);
}
console.log(`Optimizing ${imagePath}...`);
const result = await optimizeFile(imagePath, {
output: outputPath,
overwrite: true, // Overwrite if target path is the same
dryRun: false // Set to true to preview without saving
});
if (result.success) {
console.log(`Optimization successful:`);
console.log(` Original size: ${result.originalSize} bytes`);
console.log(` Optimized size: ${result.optimizedSize} bytes`);
console.log(` Reduction: ${((1 - result.optimizedSize / result.originalSize) * 100).toFixed(2)}%`);
console.log(` Output to: ${outputPath}`);
} else {
console.error(`Optimization failed: ${result.error}`);
}
// Clean up the dummy file
await fs.unlink(imagePath);
if (result.success) {
await fs.unlink(outputPath);
}
}
runOptimization().catch(console.error);
squeezit --version
Errors
Common errors & fixes
command not found: squeezit
The `squeezit` CLI tool is not installed globally or is not in your system's PATH.
fixInstall globally with `npm install -g squeezit` or `bun add -g squeezit`. Alternatively, if installed locally, run with `npx squeezit`.
Error: Cannot find module 'webpack' from 'squeezit/webpack'
A Squeezit bundler plugin (e.g., Webpack, Vite, Gulp) was used without its corresponding peer dependency installed in the project.
fixInstall the missing peer dependency: `npm install webpack` (or `vite`, `gulp`, etc., depending on the plugin in use).
Error: Image processing failed for file 'path/to/image.png': [detailed error message]
An unexpected issue occurred during the image optimization process, potentially due to a corrupted file, unsupported image format variant, or an internal library error.
fixCheck the detailed error message for clues. Verify the image file's integrity and ensure it's a supported format. Consider reporting the issue to the Squeezit project with the full error and file details.
Audit
Dependencies
@babel/coreoptionalPeer dependency for the Babel plugin integration. Must be installed separately if using the plugin.
esbuildoptionalPeer dependency for the esbuild plugin integration. Must be installed separately if using the plugin.
gulpoptionalPeer dependency for the Gulp plugin integration. Must be installed separately if using the plugin.
gruntoptionalPeer dependency for the Grunt plugin integration. Must be installed separately if using the plugin.
nextoptionalPeer dependency for the Next.js wrapper integration. Must be installed separately if using the wrapper.
astrooptionalPeer dependency for the Astro wrapper integration. Must be installed separately if using the wrapper.
parceloptionalEngine and peer dependency for the Parcel optimizer plugin integration. Must be installed separately if using the plugin.
rollupoptionalPeer dependency for the Rollup plugin integration. Must be installed separately if using the plugin.
typescriptoptionalPeer dependency, especially relevant for TypeScript projects using the API or plugins. Must be installed separately.
viteoptionalPeer dependency for the Vite plugin integration. Must be installed separately if using the plugin.
webpackoptionalPeer dependency for the Webpack plugin integration. Must be installed separately if using the plugin.