swc-project/swc · error
Minify command is not yet implemented
Error message
Minify command is not yet implemented
What it means
The `swc` CLI's `minify` subcommand is registered in clap but MinifyOptions::execute is a stub that calls unimplemented!() at minify.rs:8, so `swc minify ...` panics immediately (exit 101). The minifier itself exists in swc_core::ecma_minifier — only the CLI wiring is missing.
Source
Thrown at crates/swc_cli_impl/src/commands/minify.rs:8
use clap::Parser;
#[derive(Parser)]
pub struct MinifyOptions {}
impl super::CommandRunner for MinifyOptions {
fn execute(&self) -> anyhow::Result<()> {
unimplemented!("Minify command is not yet implemented")
}
}
View on GitHub (pinned to d7d7434666)
Solutions
- Minify via the supported surface: `swc compile` with a .swcrc containing `"minify": true` (jsc.minifier options), or the JS API `@swc/core`'s minify().
- From Rust, call swc_core::ecma_minifier directly (optimize() with MinifyOptions).
- Alternatively use esbuild/terser for the minify step.
- If you own the binary, implement CommandRunner for MinifyOptions or make the stub return a clean anyhow error.
Example fix
# before
swc minify ./src/app.js
# after (via compile + .swcrc with jsc.minifier, or JS API)
# .swcrc: { "jsc": { "minify": { "compress": true, "mangle": true } } }
swc compile ./src/app.js Defensive patterns
Strategy: try-catch
Validate before calling
# Verify minify support before adding it to a pipeline printf 'const x=1;' > /tmp/probe.js swc minify /tmp/probe.js >/dev/null 2>/tmp/swc_min.err if grep -q 'Minify command is not yet implemented' /tmp/swc_min.err; then echo 'swc minify is a stub — use swc compile with jsc.minify, or @swc/core minify()' fi
Try / catch
set +e
swc minify app.js 2>/tmp/min.err
status=$?
set -e
if [ "$status" -eq 101 ] && grep -q 'Minify command is not yet implemented' /tmp/min.err; then
echo 'falling back to @swc/core minify' >&2
exec node -e 'const swc=require("@swc/core");const fs=require("fs");swc.minify(fs.readFileSync("app.js","utf8")).then(r=>fs.writeFileSync("app.min.js",r.code));'
fi
exit "$status" Prevention
- Reach for `swc compile` + `.swcrc` jsc.minify settings, or the JS/Rust minifier API — not the CLI subcommand.
- Probe third-party CLIs in a subprocess before relying on them in build scripts.
- Keep terser/esbuild as a fallback minifier in the pipeline.
- Pin tool versions and smoke-test after upgrades.
When it happens
Trigger: Executing `swc minify file.js` with the swc_cli_impl binary; clap parses successfully, lib.rs dispatches Command::Minify(options) => options.execute(), and the process panics.
Common situations: Teams switching from terser/esbuild assuming the native CLI exposes minification; npm scripts calling `swc minify`; users surprised the subcommand shows in help yet aborts.
Related errors
- Bundle command is not yet implemented
- Lint command is not yet implemented
- module string names unimplemented
- module string names unimplemented
- module string names unimplemented
AI-assisted analysis of swc-project/swc@d7d7434666 (2026-08-16).
Data as JSON: /api/errors/917b8146758bc474.
Report an issue: GitHub.