build: further shave off runtime compile only code

This commit is contained in:
Evan You
2019-10-14 01:08:00 -04:00
parent 57a94b530d
commit 82b5978e9c
7 changed files with 36 additions and 17 deletions

View File

@@ -320,7 +320,7 @@ function finishComponentSetup(
) {
const Component = instance.type as ComponentOptions
if (!instance.render) {
if (Component.template && !Component.render) {
if (__RUNTIME_COMPILE__ && Component.template && !Component.render) {
if (compile) {
Component.render = compile(Component.template, {
onError(err: CompilerError) {

View File

@@ -48,7 +48,7 @@ const publicPropertiesMap = {
$options: 'type'
}
export const PublicInstanceProxyHandlers = {
export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
get(target: ComponentInternalInstance, key: string) {
const { renderContext, data, props, propsProxy } = target
if (data !== EMPTY_OBJ && hasOwn(data, key)) {
@@ -76,11 +76,7 @@ export const PublicInstanceProxyHandlers = {
}
return target.user[key]
},
// this trap is only called in browser-compiled render functions that use
// `with (this) {}`
has(_: any, key: string): boolean {
return key[0] !== '_' && !globalsWhitelist.has(key)
},
set(target: ComponentInternalInstance, key: string, value: any): boolean {
const { data, renderContext } = target
if (data !== EMPTY_OBJ && hasOwn(data, key)) {
@@ -105,3 +101,11 @@ export const PublicInstanceProxyHandlers = {
return true
}
}
if (__RUNTIME_COMPILE__) {
// this trap is only called in browser-compiled render functions that use
// `with (this) {}`
PublicInstanceProxyHandlers.has = (_: any, key: string): boolean => {
return key[0] !== '_' && !globalsWhitelist.has(key)
}
}