1f6e72b110
BREAKING CHANGE: compiler options have been adjusted. - new option `decodeEntities` is added. - `namedCharacterReferences` option has been removed. - `maxCRNameLength` option has been rmeoved.
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import {
|
|
baseCompile,
|
|
baseParse,
|
|
CompilerOptions,
|
|
CodegenResult,
|
|
ParserOptions,
|
|
RootNode,
|
|
noopDirectiveTransform,
|
|
NodeTransform,
|
|
DirectiveTransform
|
|
} from '@vue/compiler-core'
|
|
import { parserOptions } from './parserOptions'
|
|
import { transformStyle } from './transforms/transformStyle'
|
|
import { transformVHtml } from './transforms/vHtml'
|
|
import { transformVText } from './transforms/vText'
|
|
import { transformModel } from './transforms/vModel'
|
|
import { transformOn } from './transforms/vOn'
|
|
import { transformShow } from './transforms/vShow'
|
|
import { warnTransitionChildren } from './transforms/warnTransitionChildren'
|
|
import { stringifyStatic } from './transforms/stringifyStatic'
|
|
|
|
export { parserOptions }
|
|
|
|
export const DOMNodeTransforms: NodeTransform[] = [
|
|
transformStyle,
|
|
...(__DEV__ ? [warnTransitionChildren] : [])
|
|
]
|
|
|
|
export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
|
|
cloak: noopDirectiveTransform,
|
|
html: transformVHtml,
|
|
text: transformVText,
|
|
model: transformModel, // override compiler-core
|
|
on: transformOn, // override compiler-core
|
|
show: transformShow
|
|
}
|
|
|
|
export function compile(
|
|
template: string,
|
|
options: CompilerOptions = {}
|
|
): CodegenResult {
|
|
return baseCompile(template, {
|
|
...parserOptions,
|
|
...options,
|
|
nodeTransforms: [...DOMNodeTransforms, ...(options.nodeTransforms || [])],
|
|
directiveTransforms: {
|
|
...DOMDirectiveTransforms,
|
|
...(options.directiveTransforms || {})
|
|
},
|
|
transformHoist: __BROWSER__ ? null : stringifyStatic
|
|
})
|
|
}
|
|
|
|
export function parse(template: string, options: ParserOptions = {}): RootNode {
|
|
return baseParse(template, {
|
|
...parserOptions,
|
|
...options
|
|
})
|
|
}
|
|
|
|
export * from './runtimeHelpers'
|
|
export { transformStyle } from './transforms/transformStyle'
|
|
export { createDOMCompilerError, DOMErrorCodes } from './errors'
|
|
export * from '@vue/compiler-core'
|