feat(compiler): expression prefixing + v-for scope analysis
This commit is contained in:
@@ -8,7 +8,8 @@ import { transformFor } from './transforms/vFor'
|
||||
import { prepareElementForCodegen } from './transforms/element'
|
||||
import { transformOn } from './transforms/vOn'
|
||||
import { transformBind } from './transforms/vBind'
|
||||
import { rewriteExpression } from './transforms/expression'
|
||||
import { expressionTransform } from './transforms/expression'
|
||||
import { defaultOnError, createCompilerError, ErrorCodes } from './errors'
|
||||
|
||||
export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions
|
||||
|
||||
@@ -17,13 +18,21 @@ export function compile(
|
||||
options: CompilerOptions = {}
|
||||
): CodegenResult {
|
||||
const ast = isString(template) ? parse(template, options) : template
|
||||
const useWith = __BROWSER__ || options.useWith !== false
|
||||
|
||||
if (__BROWSER__ && options.useWith === false) {
|
||||
;(options.onError || defaultOnError)(
|
||||
createCompilerError(ErrorCodes.X_STRIP_WITH_NOT_SUPPORTED)
|
||||
)
|
||||
}
|
||||
|
||||
transform(ast, {
|
||||
...options,
|
||||
useWith,
|
||||
nodeTransforms: [
|
||||
...(!__BROWSER__ && options.useWith === false ? [rewriteExpression] : []),
|
||||
transformIf,
|
||||
transformFor,
|
||||
...(useWith ? [] : [expressionTransform]),
|
||||
prepareElementForCodegen,
|
||||
...(options.nodeTransforms || []) // user transforms
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user