How to use vue-template-es2015-compiler - 6 common examples

To help you get started, we’ve selected a few vue-template-es2015-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / src / sandbox / eval / transpilers / vue / template-compiler / loader.js View on Github external
compiled.errors.map(e => `  - ${e}`).join('\n') +
          '\n'
      )
    );
    code = 'module.exports={render:function(){},staticRenderFns:[]}';
  } else {
    const bubleOptions = options.buble;
    const stripWith = bubleOptions.transforms.stripWith !== false;
    const stripWithFunctional = bubleOptions.transforms.stripWithFunctional;

    const staticRenderFns = compiled.staticRenderFns.map(fn =>
      toFunction(fn, stripWithFunctional)
    );

    code =
      transpile(
        'var render = ' +
          toFunction(compiled.render, stripWithFunctional) +
          '\n' +
          'var staticRenderFns = [' +
          staticRenderFns.join(',') +
          ']',
        bubleOptions
      ) + '\n';
    // mark with stripped (this enables Vue to use correct runtime proxy detection)
    if (stripWith) {
      code += `render._withStripped = true\n`;
    }

    const exports = `{ render: render, staticRenderFns: staticRenderFns }`;
    code += `module.exports = ${exports}`;
  }
github imdreamrunner / browser-vue-loader / src / processors / vue-template / index.js View on Github external
// render function with extra ES2015 features,
    // and most importantly striping with and supports functional.

    const bubleOptions = {
      transforms: {
        stripWith: true,
        stripWithFunctional: stripWithFunctional
      }
    }

    const staticRenderFns = compiled.staticRenderFns.map(fn =>
      toFunction(fn, stripWithFunctional)
    )

    let code =
      transpile(
        'var render = ' +
        toFunction(compiled.render, stripWithFunctional) +
        '\n' +
        'var staticRenderFns = [' +
        staticRenderFns.join(',') +
        ']',
        bubleOptions
      ) + '\n'

    if (bubleOptions.transforms.stripWith) {
      // mark with stripped (this enables Vue to use correct runtime proxy detection)
      code += `render._withStripped = true\n`
    }
    code += `export { render, staticRenderFns }`

    const sourceUrl = url + '#source'
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / transpilers / vue / template-compiler / loader.js View on Github external
compiled.errors.map(e => `  - ${e}`).join('\n') +
          '\n'
      )
    );
    code = 'module.exports={render:function(){},staticRenderFns:[]}';
  } else {
    const bubleOptions = options.buble;
    const stripWith = bubleOptions.transforms.stripWith !== false;
    const { stripWithFunctional } = bubleOptions.transforms;

    const staticRenderFns = compiled.staticRenderFns.map(fn =>
      toFunction(fn, stripWithFunctional)
    );

    code =
      transpile(
        'var render = ' +
          toFunction(compiled.render, stripWithFunctional) +
          '\n' +
          'var staticRenderFns = [' +
          staticRenderFns.join(',') +
          ']',
        bubleOptions
      ) + '\n';
    // mark with stripped (this enables Vue to use correct runtime proxy detection)
    if (stripWith) {
      code += `render._withStripped = true\n`;
    }

    const exports = `{ render: render, staticRenderFns: staticRenderFns }`;
    code += `module.exports = ${exports}`;
  }
github vuejs / rollup-plugin-vue / src / injections.js View on Github external
export function renderJs (rawScript, render, lang, id, options) {
    const { matches, script } = findInjectionPosition(rawScript)

    if (matches && matches.length) {
        let renderScript = 'module.exports={' +
            `render: ${wrapRenderFunction(render.render)},` +
            'staticRenderFns: [' +
            `${render.staticRenderFns.map(wrapRenderFunction).join(',')}],}`

        if (options.stripWith !== false) {
            renderScript = transpileVueTemplate(renderScript, options.vue)
        }

        return script.split(matches[1]).join(renderScript.replace('module.exports={', matches[1]).replace(/\}$/, ''))
    }

    throw new Error(
        `[rollup-plugin-vue] Generated render function is injected in the default export of .vue file (lang: ${lang}). In ${id}, it cannot find 'export defaults'.`
    )
}
export function moduleJs (rawScript, modules, lang, id, options) {
github thgh / rollup-plugin-vue2 / src / vueTransform.js View on Github external
function toFunction (code) {
  return transpile('(function(){' + code + '})').slice(1, -1)
}
github thgh / rollup-plugin-vue2 / src / index.js View on Github external
function toFunction (code) {
  return transpile('(function(){' + code + '})').slice(1, -1)
}

vue-template-es2015-compiler

Post compiler for Vue template render functions to support ES2015+ features

MIT
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis

Popular vue-template-es2015-compiler functions

Similar packages