vue3-yuanma/packages/compiler-core/src/index.ts

36 lines
980 B
TypeScript
Raw Normal View History

import { parse, ParserOptions } from './parse'
import { transform, TransformOptions } from './transform'
import { generate, CodegenOptions, CodegenResult } from './codegen'
export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions
export function compile(
template: string,
options: CompilerOptions = {}
): CodegenResult {
const ast = parse(template, options)
transform(ast, {
...options,
transforms: [
// TODO include built-in core transforms
...(options.transforms || []) // user transforms
]
})
return generate(ast, options)
}
// Also expose lower level APIs & types
export { parse, ParserOptions, TextModes } from './parse'
2019-09-20 12:12:37 +08:00
export {
transform,
createDirectiveTransform,
TransformOptions,
Transform,
DirectiveTransform
2019-09-20 12:12:37 +08:00
} from './transform'
export { generate, CodegenOptions, CodegenResult } from './codegen'
2019-09-20 12:12:37 +08:00
export { ErrorCodes, CompilerError, createCompilerError } from './errors'
export * from './ast'