refactor: expose parse in compiler-dom, improve sfc parse error handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { CompilerOptions } from './options'
|
||||
import { parse } from './parse'
|
||||
import { baseParse } from './parse'
|
||||
import { transform } from './transform'
|
||||
import { generate, CodegenResult } from './codegen'
|
||||
import { RootNode } from './ast'
|
||||
@@ -43,7 +43,7 @@ export function baseCompile(
|
||||
onError(createCompilerError(ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED))
|
||||
}
|
||||
|
||||
const ast = isString(template) ? parse(template, options) : template
|
||||
const ast = isString(template) ? baseParse(template, options) : template
|
||||
transform(ast, {
|
||||
...options,
|
||||
prefixIdentifiers,
|
||||
|
||||
@@ -7,7 +7,7 @@ export {
|
||||
TransformOptions,
|
||||
CodegenOptions
|
||||
} from './options'
|
||||
export { parse, TextModes } from './parse'
|
||||
export { baseParse, TextModes } from './parse'
|
||||
export {
|
||||
transform,
|
||||
createStructuralDirectiveTransform,
|
||||
|
||||
@@ -66,7 +66,10 @@ interface ParserContext {
|
||||
inPre: boolean
|
||||
}
|
||||
|
||||
export function parse(content: string, options: ParserOptions = {}): RootNode {
|
||||
export function baseParse(
|
||||
content: string,
|
||||
options: ParserOptions = {}
|
||||
): RootNode {
|
||||
const context = createParserContext(content, options)
|
||||
const start = getCursor(context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user