Weex Template Compiler for Vue 2
raw JSON → 2.5.16-weex.1 verified Fri May 01 auth: no javascript deprecated
This is the Weex template compiler for Vue 2.0, used internally by weex-vue-loader to compile .vue files into Weex-compatible JavaScript bundles. The package is auto-generated from the Vue 2 source and is no longer actively maintained. It supports only Vue 2 (EOL December 2023) and does not work with Vue 3. The compiler produces render functions optimized for Weex's native rendering engine. Compared to the standard Vue template compiler, this version adds Weex-specific directives and component handling. Current version is 2.5.16-weex.1, and there have been no updates since Vue 2 entered maintenance mode.
Common errors
error Cannot find module 'weex-template-compiler' ↓
cause Package is not installed or not in node_modules.
fix
Run: npm install weex-template-compiler@2.5.16-weex.1 --save-dev
error TypeError: compiler.compile is not a function ↓
cause Incorrect import: trying to call compile on a default import instead of named import.
fix
Use: const { compile } = require('weex-template-compiler');
error Unknown custom element: <text> - did you register the component correctly? ↓
cause The compiled render function refers to Weex-native components that are not available in a standard Web environment.
fix
Only run this compiled code in a Weex container (e.g., Weex playground, Android/iOS Weex SDK).
Warnings
deprecated Vue 2 reached End of Life on December 31, 2023. This package will not receive updates or security fixes. ↓
fix Migrate to Vue 3 and use the standard Vue 3 template compiler if targeting Weex (or consider alternative frameworks).
gotcha This compiler is tightly coupled to Weex and produces code that only runs in a Weex environment. It cannot be used for standard web or Node.js rendering. ↓
fix Use 'vue-template-compiler' for web projects; only use 'weex-template-compiler' when building Weex apps.
breaking The 'compile' function output format changed between Vue 2.4 and 2.5. Developers using version 2.5.16-weex.1 must ensure their weex-vue-loader is compatible. ↓
fix If using an older weex-vue-loader, pin the compiler to version 2.4.x or upgrade both packages together.
gotcha The 'parseComponent' API signature differs from Vue's official compiler. It expects a different options object and may not handle all edge cases. ↓
fix Refer to the source code (src/platforms/weex/entry-compiler.js) for exact API, as documentation is incomplete.
deprecated Weex itself is in maintenance mode and not recommended for new projects. This package is deprecated by extension. ↓
fix Consider using React Native or Flutter for cross-platform native apps.
Install
npm install weex-template-compiler yarn add weex-template-compiler pnpm add weex-template-compiler Imports
- compile wrong
const { compile } = require('weex-template-compiler')correctimport { compile } from 'weex-template-compiler' - parseComponent
import { parseComponent } from 'weex-template-compiler' - compileToFunctions wrong
import compileToFunctions from 'weex-template-compiler'correctimport { compileToFunctions } from 'weex-template-compiler'
Quickstart
const compiler = require('weex-template-compiler');
const template = '<div><text>Hello Weex</text></div>';
const result = compiler.compile(template, {
preserveWhitespace: false,
weex: true
});
console.log(result.render);
// Output: render function string for Weex