Registry / devops / wxml-minifier

wxml-minifier

JSON →
library0.0.7jsnpmunverified

A minifier for WeChat Mini Program WXML files. Current stable version: 0.0.7. It removes whitespace and comments from WXML markup to reduce file size. This is a niche tool specifically for WeChat mini-program development, with no recent updates and limited options (whitespace and comment removal). Compared to generic HTML minifiers, it understands WXML syntax specifics.

npm install wxml-minifier
INSTALL
IMPORT
SIG · WXML-MINIFIER
W
wxml-minifier
devopsjavascriptv0.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

minifier
const minifier = require('wxml-minifier')
import minifier from 'wxml-minifier'
Package is CJS-only; no ESM export. Using ES import will fail.
minifier
const minifier = require('wxml-minifier').default
const minifier = require('wxml-minifier')
In version 0.0.7, the exported function is a named export, not default. But require returns the function directly, so .default is not needed. However, if using ES import, you'd need to import as namespace.
minifier
import * as wxmlMinifier from 'wxml-minifier'
import wxmlMinifier from 'wxml-minifier'
If you must use ESM, import all as namespace and call wxmlMinifier.default().

Demonstrates basic usage: importing the CJS module and minifying a simple WXML string with whitespace and comment removal enabled by default.

const minifier = require('wxml-minifier'); const wxmlStr = ` <view class="home" > <!-- test --> </view> `; const minified = minifier(wxmlStr); console.log(minified); // <view class="home></view>
Debug
Known issues
breakingPackage is CJS only; ESM imports throw 'require is not defined' error in Node ESM mode.
fix
Use require() or bundle with a CJS-compatible tool.
affects: >=0.0.0
deprecatedNo updates since 2022; consider forking or using a generic HTML minifier with WXML-specific adjustments.
fix
Keep for existing projects, but evaluate for new projects.
affects: >=0.0.0
gotchaMinification may remove essential whitespace in inline text content if whitespace option is true.
fix
Set options { whitespace: false } to preserve whitespace in text nodes.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'wxml-minifier'
Package not installed or not in node_modules.
fix
Run 'npm install wxml-minifier' or 'npm i -D wxml-minifier'.
TypeError: minifier is not a function
Using ES import incorrectly (e.g., import minifier from 'wxml-minifier').
fix
Use const minifier = require('wxml-minifier') or import * as wxmlMinifier from 'wxml-minifier' then wxmlMinifier.default().
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
wxml-minifier — npm install wxml-minifier · libregistry