Registry / web-framework / mpregular-template-compiler

mpregular-template-compiler

JSON →
library0.1.5jsnpmunverified

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.

npm install mpregular-template-compiler
INSTALL
IMPORT
SIG · MPREGULAR-TEMPLATE
M
mpregular-template-compiler
web-frameworkjavascriptv0.1.5
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.

compile
import { compile } from 'mpregular-template-compiler'
const compile = require('mpregular-template-compiler')
This package is ESM-first; using require() may fail without a bundler.
parse
import { parse } from 'mpregular-template-compiler'
import parse from 'mpregular-template-compiler'
Default export does not exist; use named import.
parseScript
import { parseScript } from 'mpregular-template-compiler'
import { parseScript } from './mpregular-template-compiler'
The parseScript function is exported, not a default.

Compiles a simple Regular.js template to WeChat mini-program code using the compile function.

import { compile } from 'mpregular-template-compiler'; const template = '<div>{{name}}</div>'; const result = compile(template, { type: 'wx', mode: 'component' }); console.log(result);
Debug
Known issues
gotchaThe compile function expects template options, but if options are omitted, defaults may produce unexpected output.
fix
Always pass an options object with 'type' and 'mode' explicitly.
affects: >=0.1.0
breakingIn version 0.1.0, the compile function returned a string; in 0.1.5 it returns an object with 'code' property.
fix
Access result.code instead of treating result as a string.
affects: 0.1.5
deprecatedThe 'wx' type is deprecated in favor of 'wechat'.
fix
Use type: 'wechat' instead of 'wx'.
affects: >=0.1.3
gotchaThe package only supports WeChat and Alipay mini-programs, not Baidu or Toutiao.
fix
Check the documentation for supported platforms; for others, consider alternative compilers.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'mpregular-template-compiler'
Package not installed or import path incorrect in Node.js environment.
fix
Run 'npm install mpregular-template-compiler' and ensure using a bundler that supports ESM.
TypeError: compile is not a function
Importing default instead of named export.
fix
Use 'import { compile } from ...' instead of 'import compile from ...'.
result.code is undefined
Using old assumption that compile returns a string directly.
fix
Access result.code after compile returns an object.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies
regularjsrequiredProvides the Regular.js runtime that compiled templates depend on
Agent activity
2 hits · last 30 days
node
2
Resources
mpregular-template-compiler — npm install mpregular-template-compiler · libregistry