vue3-yuanma/packages/compiler-dom/src/index.ts
2019-10-10 18:02:51 -04:00

29 lines
1.0 KiB
TypeScript

import { baseCompile, CompilerOptions, CodegenResult } from '@vue/compiler-core'
import { parserOptionsMinimal } from './parserOptionsMinimal'
import { parserOptionsStandard } from './parserOptionsStandard'
import { transformStyle } from './transforms/transformStyle'
import { transformCloak } from './transforms/vCloak'
import { transformVHtml } from './transforms/vHtml'
import { transformVText } from './transforms/vText'
import { transformModel } from './transforms/vModel'
export function compile(
template: string,
options: CompilerOptions = {}
): CodegenResult {
return baseCompile(template, {
...options,
...(__BROWSER__ ? parserOptionsMinimal : parserOptionsStandard),
nodeTransforms: [transformStyle, ...(options.nodeTransforms || [])],
directiveTransforms: {
cloak: transformCloak,
html: transformVHtml,
text: transformVText,
model: transformModel, // override compiler-core
...(options.directiveTransforms || {})
}
})
}
export * from '@vue/compiler-core'