import { importModule } from 'local-pkg' ; import type { Compiler } from './types' ; export const Vue2Compiler = < Compiler > ( async ( svg , collection , icon ) => { const { compile } = await importModule ( 'vue-template-compiler' ) ; const transpile = ( await importModule ( 'vue-template-es2015-compiler' ) ) . default ; const { render } = compile ( svg ) ; const toFunction = ( code ) : string => { return `function () {${ code }}` ; } ; let code = transpile ( `var __render__ = ${ toFunction ( render as any ) }\n` , { } ) ; code = code . replace ( /\s__(render|staticRenderFns)__\s/g , ' $1 ' ) ; code += `
/* vite-plugin-components disabled */
export default {
  render: render,
  name: '${ collection }-${ icon }',
}
` ; return code ; } ) ;