NativeScript-Vue Template Compiler

raw JSON →
2.9.3 verified Fri May 01 auth: no javascript maintenance

Template compiler for NativeScript-Vue, auto-generated from the platform/nativescript/compiler source. Current stable version is 2.9.3 (maintenance) and 3.0.2 (latest). The package is used to compile Vue single-file component templates into render functions optimized for NativeScript's native UI rendering. It is a required dependency for building NativeScript-Vue applications and is automatically included when using the nativescript-vue package. The 3.x series adds support for scoped styles and other improvements but introduces breaking changes if upgrading from 2.x due to Vue version differences. Release cadence is irregular, with major versions aligned with NativeScript and Vue updates.

error Module not found: Can't resolve 'nativescript-vue-template-compiler'
cause Missing or incorrect package installation.
fix
Run npm install nativescript-vue-template-compiler (and its peer dependencies).
error TypeError: compiler.compile is not a function
cause Incorrect import style – using named import on default export in v2.x.
fix
Use import compiler from '...' then call compiler.compile(template, options).
error Cannot find module 'vue-template-compiler'
cause Missing peer dependency.
fix
Run npm install vue-template-compiler.
breaking v3.0.0 introduces support for scoped styles but requires Vue 3 and breaking changes in template compilation output.
fix Upgrade to Vue 3 and rewrite templates if relying on v2-specific render function format.
gotcha The package is auto-generated; manual changes to the source file `platform/nativescript/compiler` will be overwritten.
fix Do not modify the package; contribute changes to the main nativescript-vue repository.
gotcha Template compilation requires both `nativescript-vue` and `vue-template-compiler` as peer dependencies.
fix Install both peer dependencies: `npm install nativescript-vue vue-template-compiler`
deprecated The default export `compiler` has been deprecated in favor of named exports like `compile` and `ssrCompile` starting in v3.0.0.
fix Replace `import compiler from '...'` with `import { compile } from '...'` (or other named exports).
npm install nativescript-vue-template-compiler
yarn add nativescript-vue-template-compiler
pnpm add nativescript-vue-template-compiler

Demonstrates how to import and use the template compiler to compile a simple NativeScript component template.

import compiler from 'nativescript-vue-template-compiler';
import { compile } from 'nativescript-vue-template-compiler';

const template = `<Label text="Hello, NativeScript!" />`;
const result = compile(template, { preserveWhitespace: false });
console.log(result.render);
// Use the render function with the NativeScript-Vue runtime