fix(compiler-vapor): check global allowed for identifier (#189)
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
This commit is contained in:
parent
6b03b47462
commit
464b498f13
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue