Skip to content

Commit 8f2e32c

Browse files
committed
refactor: move condition up
1 parent fcf0c5c commit 8f2e32c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/compiler-core/src/transforms/transformExpression.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,20 @@ export function processExpression(
227227
const isScopeVarReference = context.identifiers[rawExp]
228228
const isAllowedGlobal = isGloballyAllowed(rawExp)
229229
const isLiteral = isLiteralWhitelisted(rawExp)
230-
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
230+
if (
231+
!asParams &&
232+
!isScopeVarReference &&
233+
!isLiteral &&
234+
(!isAllowedGlobal || bindingMetadata[rawExp])
235+
) {
231236
// const bindings exposed from setup can be skipped for patching but
232237
// cannot be hoisted to module scope
233-
if (isConst(bindingMetadata[node.content])) {
238+
if (isConst(bindingMetadata[rawExp])) {
234239
node.constType = ConstantTypes.CAN_SKIP_PATCH
235240
}
236241
node.content = rewriteIdentifier(rawExp)
237242
} else if (!isScopeVarReference) {
238-
if (isAllowedGlobal && bindingMetadata[rawExp]) {
239-
// #9482
240-
node.content = rewriteIdentifier(rawExp)
241-
} else if (isLiteral) {
243+
if (isLiteral) {
242244
node.constType = ConstantTypes.CAN_STRINGIFY
243245
} else {
244246
node.constType = ConstantTypes.CAN_HOIST

0 commit comments

Comments
 (0)