{"record":{"id":"26702dbaac9eb73d","repo":"handlebars-lang/handlebars.js","slug":"unable-to-minimize-simple-output","errorCode":null,"errorMessage":"Unable to minimize simple output","messagePattern":"Unable to minimize simple output","errorType":"exception","errorClass":"Handlebars.Exception","httpStatus":null,"severity":"error","filePath":"lib/precompiler.js","lineNumber":168,"sourceCode":"      }\n    }\n  );\n}\n\nexport async function cli(opts) {\n  if (opts.version) {\n    console.log(Handlebars.VERSION);\n    return;\n  }\n\n  if (!opts.templates.length && !opts.hasDirectory) {\n    throw new Handlebars.Exception(\n      'Must define at least one template or directory.'\n    );\n  }\n\n  if (opts.simple && opts.min) {\n    throw new Handlebars.Exception('Unable to minimize simple output');\n  }\n\n  const multiple = opts.templates.length !== 1 || opts.hasDirectory;\n  if (opts.simple && multiple) {\n    throw new Handlebars.Exception(\n      'Unable to output multiple templates in simple mode'\n    );\n  }\n\n  // Force simple mode if we have only one template and it's unnamed.\n  if (opts.templates.length === 1 && !opts.templates[0].name) {\n    opts.simple = true;\n  }\n\n  // Convert the known list into a hash\n  let known = {};\n  if (opts.known && !Array.isArray(opts.known)) {\n    opts.known = [opts.known];","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/handlebars-lang/handlebars.js/blob/13a7a679910d2adbfe7f6fad61ce8f98426b0378/lib/precompiler.js#L150-L186","documentation":"The precompiler CLI throws when --simple (-s) and --min (-m) are combined. Simple mode emits a bare anonymous template function, which cannot be minimized since minification requires the full registry wrapper format.","triggerScenarios":"Running `handlebars -s -m templates/` or an npm script/CI config that sets both flags.","commonSituations":"Copying an existing script and toggling flags without knowing they are mutually exclusive; enabling minification for smaller bundles without realizing simple mode was already on.","solutions":["Remove the -s/--simple flag to keep minimization","Remove the -m/--min flag if bare simple output is required"],"exampleFix":"// before\nhandlebars -s -m src/templates/ -f dist/tpl.js\n\n// after (keep minification)\nhandlebars src/templates/ -f dist/tpl.js --min\n// or (keep simple mode)\nhandlebars -s src/templates/ -f dist/tpl.js","handlingStrategy":"validation","validationCode":"if (flags.simple && flags.min) {\n  throw new Error('Cannot combine --simple and --min in the handlebars CLI');\n}","typeGuard":null,"tryCatchPattern":"try {\n  execSync(cliCmd);\n} catch (e) {\n  if (/Unable to minimize simple output/.test(e.message)) {\n    // drop -s or -m from the script and rerun\n  } else throw e;\n}","preventionTips":["Treat -s and -m as mutually exclusive in build scripts and wrappers","Document the flags used per build target in package.json scripts","Lint CI configs for forbidden flag combinations"],"tags":["handlebars","cli","precompiler","conflicting-options"],"backgroundTag":"incompatible-cli-options","analyzedSha":"13a7a679910d2adbfe7f6fad61ce8f98426b0378","analyzedAt":"2026-09-02T20:25:07.518Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}