How to use vue-template-compiler

Comprehensive vue-template-compiler code examples:

How to use vue-template-compiler.compile:

20
21
22
23
24
25
26
27
28
29
const vueParseObj = vueCompilerSfc.parse(source);
// console.log(util.inspect(vueParseObj.descriptor.template, false, null, true));
let jsAst = parser.parse(vueParseObj.descriptor.scriptSetup.content, {
  sourceType: "module",
});
let { ast: templateAst } = vueTemplateCompiler.compile(
  vueParseObj.descriptor.template.content
);
jsAst = initState(jsAst, store);
templateAst = initTemplate(templateAst, null, new Set());

How to use vue-template-compiler.parseComponent:

204
205
206
207
208
209
210
211
212
213
}
const args = [destinationFolder, sourceFolder];
if (template.script) {
  const newJs = parseJSDependencies(template.script.content, ...args);
  sourceContents = insertContent(sourceContents, template.script, newJs);
  template = vueTemplateCompiler.parseComponent(sourceContents);
}
template.styles.forEach(style => {
  const newStyle = parseScssDependencies(style.content, ...args);
  sourceContents = insertContent(sourceContents, style, newStyle);