Super-fast HTML minifier native binary for macOS ARM64 (Apple Silicon)
npx @tessl/cli install tessl/npm-swc--html-darwin-arm64@1.13.0@swc/html-darwin-arm64 is a platform-specific native binary package for macOS ARM64 (Apple Silicon) that provides super-fast HTML minification capabilities. This package contains a compiled Rust binary that implements high-performance HTML parsing, minification, and optimization features as part of the SWC (Speedy Web Compiler) ecosystem.
@swc/html on macOS ARM64 systemsThis package is a platform-specific native dependency and is not used directly. Instead, it provides native implementation for the @swc/html package APIs. Import from the main package:
import { minify, minifySync, minifyFragment, minifyFragmentSync, type Options, type FragmentOptions } from "@swc/html";For CommonJS:
const { minify, minifySync, minifyFragment, minifyFragmentSync } = require("@swc/html");Note: The @swc/html-darwin-arm64 package is automatically selected as a dependency on macOS ARM64 systems and cannot be imported directly. Type definitions for TransformOutput, Element, Attribute, and Diagnostic are available from function return types.
import { minify, type Options } from "@swc/html";
// Basic HTML minification
const result = await minify(`
<html>
<head>
<title> Example Page </title>
</head>
<body>
<!-- This is a comment -->
<p class="text"> Hello World! </p>
</body>
</html>
`);
console.log(result.code); // Minified HTML
// With configuration options
const options: Options = {
collapseWhitespaces: "smart",
removeComments: true,
removeEmptyAttributes: true,
minifyJs: true,
minifyCss: true
};
const minified = await minify(htmlContent, options);The @swc/html-darwin-arm64 package provides native performance through:
Core HTML minification functionality with extensive configuration options for whitespace handling, comment removal, and attribute optimization.
/**
* Asynchronously minifies HTML content with options
* @param content - HTML content as string or Buffer
* @param options - Optional minification configuration
* @returns Promise resolving to TransformOutput with minified code
*/
function minify(
content: string | Buffer,
options?: Options
): Promise<TransformOutput>;
/**
* Synchronously minifies HTML content with options
* @param content - HTML content as string or Buffer
* @param options - Optional minification configuration
* @returns TransformOutput with minified code
*/
function minifySync(
content: string | Buffer,
options?: Options
): TransformOutput;HTML fragment minification with parsing context support for handling partial HTML documents.
/**
* Asynchronously minifies HTML fragment with context options
* @param content - HTML fragment as string or Buffer
* @param options - Optional fragment-specific configuration
* @returns Promise resolving to TransformOutput with minified fragment
*/
function minifyFragment(
content: string | Buffer,
options?: FragmentOptions
): Promise<TransformOutput>;
/**
* Synchronously minifies HTML fragment with context options
* @param content - HTML fragment as string or Buffer
* @param options - Optional fragment-specific configuration
* @returns TransformOutput with minified fragment
*/
function minifyFragmentSync(
content: string | Buffer,
options?: FragmentOptions
): TransformOutput;interface TransformOutput {
/** Minified HTML content */
code: string;
/** Optional array of diagnostic messages */
errors?: Array<Diagnostic>;
}
interface Diagnostic {
/** Diagnostic level (error, warning, etc.) */
level: string;
/** Diagnostic message text */
message: string;
/** Source location span information */
span: any;
}
type MinifierType = "js-module" | "js-script" | "json" | "css" | "html";interface Options {
/** Input filename for error reporting */
filename?: string;
/** Whether content is from iframe srcdoc */
iframeSrcdoc?: boolean;
/** Whether scripting is enabled during parsing */
scriptingEnabled?: boolean;
/** Force HTML5 doctype */
forceSetHtml5Doctype?: boolean;
/** Whitespace collapse strategy */
collapseWhitespaces?:
| "none"
| "all"
| "smart"
| "conservative"
| "advanced-conservative"
| "only-metadata";
/** Remove empty metadata elements */
removeEmptyMetadataElements?: boolean;
/** Remove HTML comments */
removeComments?: boolean;
/** Preserve specific comments matching patterns */
preserveComments?: string[];
/** Minify conditional comments */
minifyConditionalComments?: boolean;
/** Remove empty attributes */
removeEmptyAttributes?: boolean;
/** Remove redundant attributes */
removeRedundantAttributes?: "none" | "all" | "smart";
/** Collapse boolean attributes */
collapseBooleanAttributes?: boolean;
/** Normalize attribute formatting */
normalizeAttributes?: boolean;
/** Minify JSON content in script tags */
minifyJson?: boolean | { pretty?: boolean };
/** Minify JavaScript content in script tags */
minifyJs?: boolean | { parser?: any; minifier?: any; codegen?: any };
/** Minify CSS content in style tags */
minifyCss?:
| boolean
| { lib: "lightningcss" }
| { lib: "swc"; parser?: any; minifier?: any; codegen?: any };
/** Minify additional script content by type */
minifyAdditionalScriptsContent?: [string, MinifierType][];
/** Minify additional attributes by type */
minifyAdditionalAttributes?: [string, MinifierType][];
/** Sort space-separated attribute values */
sortSpaceSeparatedAttributeValues?: boolean;
/** Sort attributes alphabetically */
sortAttributes?: boolean;
/** Omit optional HTML tags */
tagOmission?: boolean | "keep-head-and-body";
/** Self-close void elements */
selfClosingVoidElements?: boolean;
/** Optimize quotes around attribute values */
quotes?: boolean;
}
interface FragmentOptions extends Options {
/** HTML parsing mode */
mode?: "no-quirks" | "limited-quirks" | "quirks";
/** Context element for fragment parsing */
context_element?: Element;
/** Form element context */
form_element?: Element;
}interface Element {
/** HTML tag name */
tagName: string;
/** Element namespace */
namespace: string;
/** Array of element attributes */
attributes: Array<Attribute>;
/** Whether element is self-closing */
isSelfClosing: boolean;
}
interface Attribute {
/** Optional attribute namespace */
namespace?: string;
/** Optional attribute prefix */
prefix?: string;
/** Attribute name */
name: string;
/** Optional attribute value */
value?: string;
}The native binary provides these HTML minification capabilities:
checked="checked" to checkedAll minification functions return a TransformOutput object that includes:
code: The minified HTML stringerrors: Optional array of Diagnostic objects for warnings or non-fatal errorsconst result = await minify(htmlContent);
if (result.errors && result.errors.length > 0) {
result.errors.forEach(error => {
console.warn(`${error.level}: ${error.message}`);
});
}