{"id":26684,"library":"zfml-transpiler","title":"zfml-transpiler","description":"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.","status":"active","version":"1.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/WANGZHEfzto/zfml-transpiler","tags":["javascript","zfml","transpiler","compiler"],"install":[{"cmd":"npm install zfml-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add zfml-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add zfml-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package does not ship ESM; only CommonJS require works.","wrong":"import compiler from 'zfml-transpiler'","symbol":"compiler","correct":"const compiler = require('zfml-transpiler')"},{"note":"Named export via destructuring from require works, but ESM import fails.","wrong":"import { wxmlCompile } from 'zfml-transpiler'","symbol":"wxmlCompile","correct":"const { wxmlCompile } = require('zfml-transpiler')"},{"note":"No default export available in ESM; only CommonJS.","wrong":"import compiler from 'zfml-transpiler'","symbol":"default import","correct":"const compiler = require('zfml-transpiler')"}],"quickstart":{"code":"const compiler = require('zfml-transpiler');\nconst path = require('path');\n\nconst fileList = [\n  path.resolve(__dirname, './pages/index/index.wxml'),\n  path.resolve(__dirname, './common/head.wxml'),\n  path.resolve(__dirname, './common/foot.wxml')\n];\n\ntry {\n  const result = compiler.wxmlCompile(fileList);\n  console.log('Compiled JS:', result);\n} catch (err) {\n  console.error('Compilation failed:', err);\n}","lang":"javascript","description":"Demonstrates CommonJS require, importing the compiler, and calling wxmlCompile with an array of absolute .wxml file paths."},"warnings":[{"fix":"Use path.resolve() or absolute paths for each .wxml file in the fileList array.","message":"File paths must be absolute; relative paths cause silent failures or incorrect output.","severity":"gotcha","affected_versions":"<=1.0.6"},{"fix":"Update code to handle an object with a 'js' property instead of a raw string.","message":"Output format changed from string to object in v1.0.0.","severity":"breaking","affected_versions":">=0.x <1.0.0"},{"fix":"Replace compiler.compile() with compiler.wxmlCompile().","message":"Use wxmlCompile instead of compile; compile() will be removed in v2.0.0.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use path.resolve(__dirname, './relative/path/to/file.wxml') to convert to absolute path.","cause":"Relative file path provided to wxmlCompile instead of absolute.","error":"Error: ENOENT: no such file or directory, open '...'"},{"fix":"Use require('zfml-transpiler') or require('zfml-transpiler').wxmlCompile.","cause":"Using ESM import which returns a module with only default export; the function is actually on the module exports object.","error":"TypeError: compiler.wxmlCompile is not a function"},{"fix":"Wrap the file path in an array: wxmlCompile(['file.wxml']) or pass an array of paths.","cause":"Passing a single file path string instead of an array.","error":"Error: Invalid file list: expected an array"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}