From: Evan You Date: Wed, 25 Sep 2019 02:50:00 +0000 (-0400) Subject: chore: fix browser build treeshaking for transformExpression X-Git-Tag: v3.0.0-alpha.0~700 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=642a44f8f0c090a0d1ac7f1498c7339035319856;p=thirdparty%2Fvuejs%2Fcore.git chore: fix browser build treeshaking for transformExpression --- diff --git a/packages/compiler-core/src/index.ts b/packages/compiler-core/src/index.ts index cc77e8bc2b..70de046962 100644 --- a/packages/compiler-core/src/index.ts +++ b/packages/compiler-core/src/index.ts @@ -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) } diff --git a/packages/compiler-core/src/transforms/vText.ts b/packages/compiler-dom/src/directives/vText.ts similarity index 100% rename from packages/compiler-core/src/transforms/vText.ts rename to packages/compiler-dom/src/directives/vText.ts