Registry / web-framework / zfml-transpiler

zfml-transpiler

JSON →
library1.0.6jsnpmunverified

A template compiler for ZFML (WeChat WXML-like syntax) that compiles .wxml files into JavaScript render functions. Version 1.0.6 is the latest stable release, with no clear release cadence. It mimics the behavior of wcc.exe/wcc used in WeChat Mini Programs. Key differentiators: lightweight, Node.js-based alternative to the official wcc compiler, focused on transforming WXML templates for WeChat ecosystem development. Maintained as a single-function library with minimal dependencies.

npm install zfml-transpiler
INSTALL
IMPORT
SIG · ZFML-TRANSPILER
Z
zfml-transpiler
web-frameworkjavascriptv1.0.6
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.

compiler
const compiler = require('zfml-transpiler')
import compiler from 'zfml-transpiler'
This package does not ship ESM; only CommonJS require works.
wxmlCompile
const { wxmlCompile } = require('zfml-transpiler')
import { wxmlCompile } from 'zfml-transpiler'
Named export via destructuring from require works, but ESM import fails.
default import
const compiler = require('zfml-transpiler')
import compiler from 'zfml-transpiler'
No default export available in ESM; only CommonJS.

Demonstrates CommonJS require, importing the compiler, and calling wxmlCompile with an array of absolute .wxml file paths.

const compiler = require('zfml-transpiler'); const path = require('path'); const fileList = [ path.resolve(__dirname, './pages/index/index.wxml'), path.resolve(__dirname, './common/head.wxml'), path.resolve(__dirname, './common/foot.wxml') ]; try { const result = compiler.wxmlCompile(fileList); console.log('Compiled JS:', result); } catch (err) { console.error('Compilation failed:', err); }
Debug
Known issues
gotchaFile paths must be absolute; relative paths cause silent failures or incorrect output.
fix
Use path.resolve() or absolute paths for each .wxml file in the fileList array.
affects: <=1.0.6
breakingOutput format changed from string to object in v1.0.0.
fix
Update code to handle an object with a 'js' property instead of a raw string.
affects: >=0.x <1.0.0
deprecatedUse wxmlCompile instead of compile; compile() will be removed in v2.0.0.
fix
Replace compiler.compile() with compiler.wxmlCompile().
affects: >=1.0.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '...'
Relative file path provided to wxmlCompile instead of absolute.
fix
Use path.resolve(__dirname, './relative/path/to/file.wxml') to convert to absolute path.
TypeError: compiler.wxmlCompile is not a function
Using ESM import which returns a module with only default export; the function is actually on the module exports object.
fix
Use require('zfml-transpiler') or require('zfml-transpiler').wxmlCompile.
Error: Invalid file list: expected an array
Passing a single file path string instead of an array.
fix
Wrap the file path in an array: wxmlCompile(['file.wxml']) or pass an array of paths.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
zfml-transpiler — npm install zfml-transpiler · libregistry