diff --git a/packages/compiler-core/src/transforms/transformExpression.ts b/packages/compiler-core/src/transforms/transformExpression.ts index 5a8483dedf0..52d1fb42a13 100644 --- a/packages/compiler-core/src/transforms/transformExpression.ts +++ b/packages/compiler-core/src/transforms/transformExpression.ts @@ -227,18 +227,20 @@ export function processExpression( const isScopeVarReference = context.identifiers[rawExp] const isAllowedGlobal = isGloballyAllowed(rawExp) const isLiteral = isLiteralWhitelisted(rawExp) - if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) { + if ( + !asParams && + !isScopeVarReference && + !isLiteral && + (!isAllowedGlobal || bindingMetadata[rawExp]) + ) { // const bindings exposed from setup can be skipped for patching but // cannot be hoisted to module scope - if (isConst(bindingMetadata[node.content])) { + if (isConst(bindingMetadata[rawExp])) { node.constType = ConstantTypes.CAN_SKIP_PATCH } node.content = rewriteIdentifier(rawExp) } else if (!isScopeVarReference) { - if (isAllowedGlobal && bindingMetadata[rawExp]) { - // #9482 - node.content = rewriteIdentifier(rawExp) - } else if (isLiteral) { + if (isLiteral) { node.constType = ConstantTypes.CAN_STRINGIFY } else { node.constType = ConstantTypes.CAN_HOIST