{"id":25960,"library":"mpregular-template-compiler","title":"Mpregular Template Compiler","description":"Template compiler for mpregular, converting Regular.js templates into mini-program (WeChat/Alipay) compatible code. Version 0.1.5, with low release cadence and limited community adoption. Key differentiator: bridges Regular.js components to mini-program environments, unlike other tools that target Vue or React.","status":"active","version":"0.1.5","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install mpregular-template-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add mpregular-template-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add mpregular-template-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the Regular.js runtime that compiled templates depend on","package":"regularjs","optional":false}],"imports":[{"note":"This package is ESM-first; using require() may fail without a bundler.","wrong":"const compile = require('mpregular-template-compiler')","symbol":"compile","correct":"import { compile } from 'mpregular-template-compiler'"},{"note":"Default export does not exist; use named import.","wrong":"import parse from 'mpregular-template-compiler'","symbol":"parse","correct":"import { parse } from 'mpregular-template-compiler'"},{"note":"The parseScript function is exported, not a default.","wrong":"import { parseScript } from './mpregular-template-compiler'","symbol":"parseScript","correct":"import { parseScript } from 'mpregular-template-compiler'"}],"quickstart":{"code":"import { compile } from 'mpregular-template-compiler';\nconst template = '<div>{{name}}</div>';\nconst result = compile(template, { type: 'wx', mode: 'component' });\nconsole.log(result);","lang":"typescript","description":"Compiles a simple Regular.js template to WeChat mini-program code using the compile function."},"warnings":[{"fix":"Always pass an options object with 'type' and 'mode' explicitly.","message":"The compile function expects template options, but if options are omitted, defaults may produce unexpected output.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Access result.code instead of treating result as a string.","message":"In version 0.1.0, the compile function returned a string; in 0.1.5 it returns an object with 'code' property.","severity":"breaking","affected_versions":"0.1.5"},{"fix":"Use type: 'wechat' instead of 'wx'.","message":"The 'wx' type is deprecated in favor of 'wechat'.","severity":"deprecated","affected_versions":">=0.1.3"},{"fix":"Check the documentation for supported platforms; for others, consider alternative compilers.","message":"The package only supports WeChat and Alipay mini-programs, not Baidu or Toutiao.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install mpregular-template-compiler' and ensure using a bundler that supports ESM.","cause":"Package not installed or import path incorrect in Node.js environment.","error":"Cannot find module 'mpregular-template-compiler'"},{"fix":"Use 'import { compile } from ...' instead of 'import compile from ...'.","cause":"Importing default instead of named export.","error":"TypeError: compile is not a function"},{"fix":"Access result.code after compile returns an object.","cause":"Using old assumption that compile returns a string directly.","error":"result.code is undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}