Registry / data / oxc-minify

oxc-minify

JSON →
library0.126.0jsnpmunverified

Oxc Minify is a JavaScript minifier built in Rust, providing a Node.js API for synchronous and asynchronous code minification. Currently at version 0.126.0, it is under active and rapid development, with frequent releases often introducing breaking changes as the project matures. It is designed for high performance, already outperforming `esbuild` in some benchmarks, and aims to eventually include advanced minification techniques like constant inlining and dead code removal. A key differentiator is its Rust-based architecture, offering potential speed advantages over JavaScript-based minifiers like Terser or UglifyJS. However, it is explicitly alpha software, making assumptions about semantically correct input and using a fast parsing mode that skips some semantic error checks to maximize performance.

npm install oxc-minify
INSTALL
IMPORT
SIG · OXC-MINIFY
O
oxc-minify
datajavascriptv0.126.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

minifySync
✓ import { minifySync } from 'oxc-minify';
✗ const { minifySync } = require('oxc-minify');
The documentation primarily shows ESM `import` syntax. While CommonJS might work for some versions/environments, ESM is the officially demonstrated approach. Ensure your project is configured for ESM.
minify
✓ import { minify } from 'oxc-minify';
✗ import minify from 'oxc-minify'; // Not a default export
`minify` is the asynchronous version, useful for I/O-bound or concurrent tasks. Both `minify` and `minifySync` are named exports.
MinifyOptions
✓ import type { MinifyOptions } from 'oxc-minify';
Import types separately using `import type` for TypeScript projects.

This example demonstrates both synchronous and asynchronous minification of a JavaScript code string, showcasing common options for compression, mangling, and code generation, along with sourcemap generation.

import { minifySync } from "oxc-minify"; const filename = "test.js"; const code = "const x = 'a' + 'b'; console.log(x); function sum(a, b) { return a + b; } console.log(sum(1,2));"; const options = { compress: { target: "esnext", // Example of a common compression option inline: 2 // Inline small functions where possible }, mangle: { toplevel: false, // Example of a common mangling option properties: false // Do not mangle properties for now }, codegen: { removeWhitespace: true, // Example of a common code generation option quote: 'single' // Use single quotes for strings }, sourcemap: true, }; // Synchronous minification const resultSync = minifySync(filename, code, options); console.log('Synchronous result:'); console.log(resultSync.code); // console.log(resultSync.map); // Source map can be logged if needed // Asynchronous minification (uncomment to use) // (async () => { // const resultAsync = await minify(filename, code, options); // console.log('\nAsynchronous result:'); // console.log(resultAsync.code); // // console.log(resultAsync.map); // })();
oxc-minify --version
Debug
Known issues
breakingThe `allocator` module's `Box` and `Vec` methods were renamed, which can affect custom Rust-based extensions or deeper integrations.
fix
Review your Rust FFI bindings or custom allocator usage to align with the new method names in `oxc_allocator`.
affects: >=0.126.0
breakingThe `oxc_str` crate underwent multiple breaking changes, including the removal of identity `FromIn` impl for `Ident` and re-exports of string types from `oxc_span`, along with the introduction of a new `static_ident!` macro.
fix
Update any code relying on `oxc_str` or `oxc_span` string type re-exports according to the new API and macro usage.
affects: >=0.125.0
gotchaOxc Minify is currently alpha software and may produce incorrect results or not fully optimize code as expected. It lacks some advanced minification techniques like constant inlining and dead code removal.
fix
Thoroughly test minified output in your target environment. Monitor the Oxc project's GitHub releases for updates on feature completeness and stability. Avoid using in production without extensive validation.
affects: >=0.1.0
gotchaTo maximize performance, `oxc-minify` assumes the input code is semantically correct. It uses a fast parsing mode that skips checks for semantic errors related to symbols and scopes.
fix
Ensure your input code is syntactically and semantically valid before passing it to `oxc-minify`. Use linters or other parsers (e.g., `oxc-parser` in full mode) for prior validation if semantic correctness is not guaranteed.
affects: >=0.1.0
breakingOxlint's internal `span` and `str` crate re-exports were removed, potentially impacting applications that directly interfaced with these internal Rust crates.
fix
Adjust any direct Rust-level integrations to align with the revised module structure and exports.
affects: >=0.125.0
Errors
Common errors & fixes
Error: The 'filename' argument must be of type string. Received type undefined
The `filename` parameter in `minifySync` or `minify` was not provided or was `undefined`.
fix
Always provide a string for the `filename` argument, even if it's a placeholder like `'input.js'`.
SyntaxError: Expected an identifier but found 'class'
Input code contains syntax errors that `oxc-minify`'s parser cannot handle, potentially due to unsupported syntax or malformed code.
fix
Ensure the input `sourceText` is valid JavaScript/TypeScript. `oxc-minify` expects semantically correct code and may not gracefully handle all malformed inputs.
TypeError: Cannot read properties of undefined (reading 'code')
The `minifySync` or `minify` function might have thrown an error, causing `result` to be undefined, and then you tried to access `result.code`.
fix
Wrap your minification call in a `try...catch` block for `minifySync` or use `.catch()` for `minify` to handle potential errors during the minification process.
Upgrade
Version history
0.126.0latest on npm
Audit
Dependencies
noderequiredRuntime environment requirement for the Node.js API.
Agent activity
2 hits · last 30 days
node
2
Resources
oxc-minify — npm install oxc-minify · libregistry