{"record":{"id":"917b8146758bc474","repo":"swc-project/swc","slug":"minify-command-is-not-yet-implemented","errorCode":null,"errorMessage":"Minify command is not yet implemented","messagePattern":"Minify command is not yet implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_cli_impl/src/commands/minify.rs","lineNumber":8,"sourceCode":"use clap::Parser;\n\n#[derive(Parser)]\npub struct MinifyOptions {}\n\nimpl super::CommandRunner for MinifyOptions {\n    fn execute(&self) -> anyhow::Result<()> {\n        unimplemented!(\"Minify command is not yet implemented\")\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":11,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_cli_impl/src/commands/minify.rs#L1-L11","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nswc minify ./src/app.js\n\n# after (via compile + .swcrc with jsc.minifier, or JS API)\n# .swcrc: { \"jsc\": { \"minify\": { \"compress\": true, \"mangle\": true } } }\nswc compile ./src/app.js","handlingStrategy":"try-catch","validationCode":"# Verify minify support before adding it to a pipeline\nprintf 'const x=1;' > /tmp/probe.js\nswc minify /tmp/probe.js >/dev/null 2>/tmp/swc_min.err\nif grep -q 'Minify command is not yet implemented' /tmp/swc_min.err; then\n  echo 'swc minify is a stub — use swc compile with jsc.minify, or @swc/core minify()'\nfi","typeGuard":null,"tryCatchPattern":"set +e\nswc minify app.js 2>/tmp/min.err\nstatus=$?\nset -e\nif [ \"$status\" -eq 101 ] && grep -q 'Minify command is not yet implemented' /tmp/min.err; then\n  echo 'falling back to @swc/core minify' >&2\n  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));'\nfi\nexit \"$status\"","preventionTips":["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."],"tags":["swc","cli","minify","unimplemented","panic","exit-101"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}