M+Minify++

Integration · C++17

A seven-function library surface, plus one format dispatcher.

The public API accepts whole buffers and returns either a complete transformed buffer or a controlled error. File discovery, naming and write policy stay with the caller.

Include and link

#include <minify/Minify.h>

std::string output;
std::string error;
if (!minify::javascript(source, output, error)) {
    // Preserve the original and report error.
}

Minify++ is written in C++17. The public header does not expose Nift types or a third-party runtime.

Format-specific entry points

bool minify::html(input, output, error);
bool minify::css(input, output, error);
bool minify::javascript(input, output, error);
bool minify::jsx(input, output, error);
bool minify::json(input, output, error);
bool minify::xml(input, output, error);
bool minify::svg(input, output, error);

Every entry point has the same shape. A successful call supplies the complete output. A failed call supplies an explanatory error and must not be treated as usable partial output.

Dispatch by format

minify::Format format;
if (!minify::format_for_extension(".css", format)) {
    // Unsupported extension.
}
if (!minify::run(format, input, output, error)) {
    // Format-specific failure.
}

Format contains Html, Css, JavaScript, Jsx, Json, Xml and Svg. The integer minify::format_version is currently 1; it identifies the supported format/API contract rather than the CLI release number.

Ownership and concurrency

The library is stateless and whole-buffer. Inputs are immutable strings supplied by the caller; output and error strings are caller-owned. No global project state, current directory, build graph or framework configuration is consulted.

What the library deliberately does not do

  • open, replace or rename files;
  • walk directories or infer a build graph;
  • compile TypeScript, JSX or Sass;
  • bundle, mangle identifiers or tree-shake modules;
  • choose whether a failed optimisation should block deployment.

Those boundaries make embedding predictable. A host can choose its own transaction, logging and failure policy while reusing exactly the same transformation engine tested by the standalone CLI.

Nift integration

Nift build engine
      ↓ configured output extension only
public Minify++ API
      ↓
final artifact

Nift’s copy is protected by an exact synchronization gate covering the implementation, public API and associated contract assets. Minify++ remains independently buildable and testable.

Integration checklist

  • Select the format explicitly or validate the extension.
  • Keep the original until minification succeeds.
  • Treat an error as a failed optimisation, never as partial output.
  • Use atomic or recoverable destination replacement where appropriate.
  • Retain format-specific regressions for any production defect.