crates/oxc_minifier/docs/CORRECTNESS.md
The Oxc minifier maintains correctness through comprehensive testing and validation.
Run conformance tests:
# Run all conformance tests
cargo coverage
# Run specific suite
cargo coverage js # test262
cargo coverage babel # Babel tests
cargo coverage ts # TypeScript tests
# Debug mode
cargo coverage -- --debug
# Filter specific tests
cargo coverage -- --filter "test-name"
Track compression performance:
# Update size benchmarks
just minsize
# Compare with esbuild
# See tasks/minsize/minsize.snap for results
Every optimization preserves:
// Correctly preserves TDZ semantics
{
console.log(x); // ReferenceError
let x = 1;
}
// Preserves sparse array behavior
const arr = [1, , 3];
arr.length; // 3
1 in arr; // false
// Maintains BigInt semantics
1n + 2n; // 3n
1n + 2; // TypeError
// Respects property descriptors
Object.defineProperty(obj, "prop", {
writable: false,
value: 1,
});
// Preserves iteration semantics
function* gen() {
yield 1;
yield 2;
}
All JavaScript coercion rules are preserved using oxc_ecmascript conversions:
ToJsString)ToNumber)ToBoolean)Located in crates/oxc_minifier/tests/:
cargo test -p oxc_minifier
Real-world code testing:
cd tasks/e2e
pnpm test
Minifying twice produces same result:
cargo run -p oxc_minifier --example minifier test.js --twice
Validates that transformations preserve semantics.
Shows exact changes made to the AST.
Compares runtime behavior of original vs minified code.
Ensures side effects occur in correct order.
The minifier makes certain assumptions (see ASSUMPTIONS.md) that are true for standard JavaScript but may not hold for unusual code patterns.
If you find correctness issues:
Our CI runs:
Every PR must pass all correctness tests.