vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
207.32k stars 33.62k forks source link

vue-template-compiler lacks a stringify API #9742

Open genffy opened 5 years ago

genffy commented 5 years ago

What problem does this feature solve?

when i use vue-template-compiler parseComponent a vue file, and use @babel/parser @babel/traverse @babel/generator modify some code at vueTemplateComplier AST.script content But can not find a api to auto generate file from vueTemplateComplier AST it to origin file.

What does the proposed API look like?

const fileContent = compiler.generateComponent(, { pad: 'space' }); // fileContent is same as *.vue file content

Justineo commented 5 years ago

As I understand it's actually a feature request instead of a question so I modified your title.

Justineo commented 5 years ago

Or we may consider adding it to @vue/component-compiler-utils.

getflourish commented 4 years ago

Any updates here? I also wonder wether the code for stringification exists somewhere in the Vue Universe already…