2019-09-26 15:51:04 +00:00
|
|
|
import { baseCompile, CompilerOptions, CodegenResult } from '@vue/compiler-core'
|
2019-09-17 15:57:25 +00:00
|
|
|
import { parserOptionsMinimal } from './parserOptionsMinimal'
|
|
|
|
import { parserOptionsStandard } from './parserOptionsStandard'
|
2019-10-03 20:55:14 +00:00
|
|
|
import { transformStyle } from './transforms/transformStyle'
|
2019-10-09 14:41:31 +00:00
|
|
|
import { transformCloak } from './transforms/vCloak'
|
2019-10-08 19:35:57 +00:00
|
|
|
import { transformVHtml } from './transforms/vHtml'
|
2019-10-10 14:18:19 +00:00
|
|
|
import { transformVText } from './transforms/vText'
|
2019-10-10 22:02:51 +00:00
|
|
|
import { transformModel } from './transforms/vModel'
|
2019-09-17 15:57:25 +00:00
|
|
|
|
2019-09-20 04:12:37 +00:00
|
|
|
export function compile(
|
|
|
|
template: string,
|
|
|
|
options: CompilerOptions = {}
|
|
|
|
): CodegenResult {
|
2019-09-20 16:16:19 +00:00
|
|
|
return baseCompile(template, {
|
|
|
|
...options,
|
|
|
|
...(__BROWSER__ ? parserOptionsMinimal : parserOptionsStandard),
|
2019-10-03 20:55:14 +00:00
|
|
|
nodeTransforms: [transformStyle, ...(options.nodeTransforms || [])],
|
2019-09-21 21:42:12 +00:00
|
|
|
directiveTransforms: {
|
2019-10-09 14:41:31 +00:00
|
|
|
cloak: transformCloak,
|
2019-10-08 19:35:57 +00:00
|
|
|
html: transformVHtml,
|
2019-10-10 14:18:19 +00:00
|
|
|
text: transformVText,
|
2019-10-10 22:02:51 +00:00
|
|
|
model: transformModel, // override compiler-core
|
2019-09-21 21:42:12 +00:00
|
|
|
...(options.directiveTransforms || {})
|
|
|
|
}
|
2019-09-20 04:12:37 +00:00
|
|
|
})
|
|
|
|
}
|
2019-09-22 20:50:57 +00:00
|
|
|
|
|
|
|
export * from '@vue/compiler-core'
|