diff --git a/packages/compiler-vapor/src/generators/expression.ts b/packages/compiler-vapor/src/generators/expression.ts index a5c25adb1..4b5701246 100644 --- a/packages/compiler-vapor/src/generators/expression.ts +++ b/packages/compiler-vapor/src/generators/expression.ts @@ -1,3 +1,4 @@ +import { isGloballyAllowed } from '@vue/shared' import { BindingTypes, NewlineType, @@ -167,7 +168,7 @@ function genIdentifier( raw = withAssignment(raw) } } else { - raw = withAssignment(`_ctx.${raw}`) + raw = withAssignment(canPrefix(raw) ? `_ctx.${raw}` : raw) } return [prefix, [raw, NewlineType.None, loc, name]] @@ -178,3 +179,15 @@ function genIdentifier( return `${vaporHelper('unref')}(${raw})` } } + +function canPrefix(name: string) { + // skip whitelisted globals + if (isGloballyAllowed(name)) { + return false + } + // special case for webpack compilation + if (name === 'require') { + return false + } + return true +}