refactor: expose parse in compiler-dom, improve sfc parse error handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
parse,
|
||||
baseParse as parse,
|
||||
NodeTypes,
|
||||
ElementNode,
|
||||
TextNode,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
parse,
|
||||
baseParse as parse,
|
||||
transform,
|
||||
CompilerOptions,
|
||||
ElementNode,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
parse,
|
||||
baseParse as parse,
|
||||
transform,
|
||||
ElementNode,
|
||||
CallExpression
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
parse,
|
||||
baseParse as parse,
|
||||
transform,
|
||||
PlainElementNode,
|
||||
CompilerOptions
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { parse, transform, CompilerOptions, generate } from '@vue/compiler-core'
|
||||
import {
|
||||
baseParse as parse,
|
||||
transform,
|
||||
CompilerOptions,
|
||||
generate
|
||||
} from '@vue/compiler-core'
|
||||
import { transformModel } from '../../src/transforms/vModel'
|
||||
import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
|
||||
import { DOMErrorCodes } from '../../src/errors'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
parse,
|
||||
baseParse as parse,
|
||||
transform,
|
||||
CompilerOptions,
|
||||
ElementNode,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { parse, transform, generate, CompilerOptions } from '@vue/compiler-core'
|
||||
import {
|
||||
baseParse as parse,
|
||||
transform,
|
||||
generate,
|
||||
CompilerOptions
|
||||
} from '@vue/compiler-core'
|
||||
import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
|
||||
import { transformShow } from '../../src/transforms/vShow'
|
||||
import { DOMErrorCodes } from '../../src/errors'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
parse,
|
||||
baseParse as parse,
|
||||
transform,
|
||||
PlainElementNode,
|
||||
CompilerOptions
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import {
|
||||
baseCompile,
|
||||
baseParse,
|
||||
CompilerOptions,
|
||||
CodegenResult,
|
||||
isBuiltInType
|
||||
isBuiltInType,
|
||||
ParserOptions
|
||||
} from '@vue/compiler-core'
|
||||
import { parserOptionsMinimal } from './parserOptionsMinimal'
|
||||
import { parserOptionsStandard } from './parserOptionsStandard'
|
||||
@@ -15,13 +17,15 @@ import { transformOn } from './transforms/vOn'
|
||||
import { transformShow } from './transforms/vShow'
|
||||
import { TRANSITION, TRANSITION_GROUP } from './runtimeHelpers'
|
||||
|
||||
const parserOptions = __BROWSER__ ? parserOptionsMinimal : parserOptionsStandard
|
||||
|
||||
export function compile(
|
||||
template: string,
|
||||
options: CompilerOptions = {}
|
||||
): CodegenResult {
|
||||
return baseCompile(template, {
|
||||
...parserOptions,
|
||||
...options,
|
||||
...(__BROWSER__ ? parserOptionsMinimal : parserOptionsStandard),
|
||||
nodeTransforms: [transformStyle, ...(options.nodeTransforms || [])],
|
||||
directiveTransforms: {
|
||||
cloak: transformCloak,
|
||||
@@ -42,4 +46,11 @@ export function compile(
|
||||
})
|
||||
}
|
||||
|
||||
export function parse(template: string, options: ParserOptions = {}) {
|
||||
return baseParse(template, {
|
||||
...parserOptions,
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
export * from '@vue/compiler-core'
|
||||
|
||||
Reference in New Issue
Block a user