Vue Template ES2015 Compiler

1.9.1 · deprecated · verified Sun Apr 19

This package is an internal build-time utility primarily used by `vue-loader` and `vueify` in Vue 2 projects. Its main function is to post-process raw render functions generated by `vue-template-compiler` to introduce support for ES2015+ features within template expressions, leveraging a custom fork of Buble. Additionally, it removes the `with` block from render functions to ensure strict-mode compliance. The current stable version is 1.9.1, but the package has not seen updates since February 2019, indicating it is no longer actively maintained for modern Vue development. It is a critical component for enabling advanced JavaScript syntax in Vue 2 templates during the build process, distinguishing itself by its specific focus on ES2015+ transpilation and strict-mode compatibility for Vue 2's compilation output.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates programmatic usage of the compiler to process a raw Vue render function string, transpiling ES2015+ features and removing `with` blocks.

const compile = require('vue-template-es2015-compiler');

// Simulate a render function string from vue-template-compiler output
const rawRenderFn = `
  with(this){
    return _c('div', [
      _v('Hello ' + (name)),
      _c('button', { on: { click: () => ({ ...user, active: true }) } }, ['Click'])
    ])
  }
`;

// Options can be passed, though typically defaults are used by vue-loader
const options = {};

try {
  const compiledResult = compile(rawRenderFn, options);
  console.log('Processed Render Function:\n', compiledResult);
  // Expected output will have 'with' removed and ES2015+ features transpiled
  // e.g., fat arrow functions, object spread to Object.assign
} catch (error) {
  console.error('Compilation Error:', error);
}

view raw JSON →