chore: fix browser build treeshaking for transformExpression

This commit is contained in:
Evan You 2019-09-24 22:50:00 -04:00
parent 84909648e7
commit 642a44f8f0
2 changed files with 5 additions and 3 deletions

View File

@ -17,7 +17,7 @@ export function compile(
template: string | RootNode,
options: CompilerOptions = {}
): CodegenResult {
if (__BROWSER__ && options.prefixIdentifiers) {
if (__BROWSER__ && options.prefixIdentifiers === false) {
;(options.onError || defaultOnError)(
createCompilerError(ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED)
)
@ -25,13 +25,14 @@ export function compile(
const ast = isString(template) ? parse(template, options) : template
const prefixIdentifiers = !__BROWSER__ && options.prefixIdentifiers === true
transform(ast, {
...options,
prefixIdentifiers: !__BROWSER__ && options.prefixIdentifiers === true,
prefixIdentifiers,
nodeTransforms: [
transformIf,
transformFor,
transformExpression,
...(prefixIdentifiers ? [transformExpression] : []),
transformElement,
...(options.nodeTransforms || []) // user transforms
],
@ -41,6 +42,7 @@ export function compile(
...(options.directiveTransforms || {}) // user transforms
}
})
return generate(ast, options)
}