@@ -3,7 +3,7 @@ import { baseParse } from './parse'
|
||||
import { transform, NodeTransform, DirectiveTransform } from './transform'
|
||||
import { generate, CodegenResult } from './codegen'
|
||||
import { RootNode } from './ast'
|
||||
import { isString } from '@vue/shared'
|
||||
import { isString, extend } from '@vue/shared'
|
||||
import { transformIf } from './transforms/vIf'
|
||||
import { transformFor } from './transforms/vFor'
|
||||
import { transformExpression } from './transforms/transformExpression'
|
||||
@@ -80,21 +80,26 @@ export function baseCompile(
|
||||
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(
|
||||
prefixIdentifiers
|
||||
)
|
||||
transform(ast, {
|
||||
...options,
|
||||
prefixIdentifiers,
|
||||
nodeTransforms: [
|
||||
...nodeTransforms,
|
||||
...(options.nodeTransforms || []) // user transforms
|
||||
],
|
||||
directiveTransforms: {
|
||||
...directiveTransforms,
|
||||
...(options.directiveTransforms || {}) // user transforms
|
||||
}
|
||||
})
|
||||
transform(
|
||||
ast,
|
||||
extend({}, options, {
|
||||
prefixIdentifiers,
|
||||
nodeTransforms: [
|
||||
...nodeTransforms,
|
||||
...(options.nodeTransforms || []) // user transforms
|
||||
],
|
||||
directiveTransforms: extend(
|
||||
{},
|
||||
directiveTransforms,
|
||||
options.directiveTransforms || {} // user transforms
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
return generate(ast, {
|
||||
...options,
|
||||
prefixIdentifiers
|
||||
})
|
||||
return generate(
|
||||
ast,
|
||||
extend({}, options, {
|
||||
prefixIdentifiers
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ParserOptions } from './options'
|
||||
import { NO, isArray, makeMap } from '@vue/shared'
|
||||
import { NO, isArray, makeMap, extend } from '@vue/shared'
|
||||
import { ErrorCodes, createCompilerError, defaultOnError } from './errors'
|
||||
import {
|
||||
assert,
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
InterpolationNode,
|
||||
createRoot
|
||||
} from './ast'
|
||||
import { extend } from '@vue/shared'
|
||||
|
||||
type OptionalOptions = 'isNativeTag' | 'isBuiltInComponent'
|
||||
type MergedParserOptions = Omit<Required<ParserOptions>, OptionalOptions> &
|
||||
@@ -91,10 +90,7 @@ function createParserContext(
|
||||
options: ParserOptions
|
||||
): ParserContext {
|
||||
return {
|
||||
options: {
|
||||
...defaultParserOptions,
|
||||
...options
|
||||
},
|
||||
options: extend({}, defaultParserOptions, options),
|
||||
column: 1,
|
||||
line: 1,
|
||||
offset: 0,
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
KEEP_ALIVE,
|
||||
BASE_TRANSITION
|
||||
} from './runtimeHelpers'
|
||||
import { isString, isObject, hyphenate } from '@vue/shared'
|
||||
import { isString, isObject, hyphenate, extend } from '@vue/shared'
|
||||
import { parse } from '@babel/parser'
|
||||
import { walk } from 'estree-walker'
|
||||
import { Node } from '@babel/types'
|
||||
@@ -119,7 +119,11 @@ export function advancePositionWithClone(
|
||||
source: string,
|
||||
numberOfCharacters: number = source.length
|
||||
): Position {
|
||||
return advancePositionWithMutation({ ...pos }, source, numberOfCharacters)
|
||||
return advancePositionWithMutation(
|
||||
extend({}, pos),
|
||||
source,
|
||||
numberOfCharacters
|
||||
)
|
||||
}
|
||||
|
||||
// advance by mutation without cloning (for performance reasons), since this
|
||||
|
||||
Reference in New Issue
Block a user