declare var __VUE_HMR_RUNTIME__: HMRRuntime
const { createRecord, rerender, reload } = __VUE_HMR_RUNTIME__
+runtimeTest.registerRuntimeCompiler(compileToFunction)
+
function compileToFunction(template: string) {
const { code } = baseCompile(template)
const render = new Function('Vue', code)(
import {
ComponentPublicInstance,
PublicInstanceProxyHandlers,
- RuntimeCompiledPublicInstanceProxyHandlers,
createRenderContext,
exposePropsOnRenderContext,
exposeSetupStateOnRenderContext,
ComponentPublicInstanceConstructor,
- publicPropertiesMap
+ publicPropertiesMap,
+ RuntimeCompiledPublicInstanceProxyHandlers
} from './componentPublicInstance'
import {
ComponentPropsOptions,
) => InternalRenderFunction
let compile: CompileFunction | undefined
-
-// dev only
-export const isRuntimeOnly = () => !compile
+let installWithProxy: (i: ComponentInternalInstance) => void
/**
* For runtime-dom to register the compiler.
*/
export function registerRuntimeCompiler(_compile: any) {
compile = _compile
+ installWithProxy = i => {
+ if (i.render!._rc) {
+ i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers)
+ }
+ }
}
+// dev only
+export const isRuntimeOnly = () => !compile
+
export function finishComponentSetup(
instance: ComponentInternalInstance,
isSSR: boolean,
// for runtime-compiled render functions using `with` blocks, the render
// proxy used needs a different `has` handler which is more performant and
// also only allows a whitelist of globals to fallthrough.
- if (instance.render._rc) {
- instance.withProxy = new Proxy(
- instance.ctx,
- RuntimeCompiledPublicInstanceProxyHandlers
- )
+ if (installWithProxy) {
+ installWithProxy(instance)
}
}
return getPublicInstance(i.parent)
}
-export const publicPropertiesMap: PublicPropertiesMap = extend(
+export const publicPropertiesMap: PublicPropertiesMap = /*#__PURE__*/ extend(
Object.create(null),
{
$: i => i,
}
}
-export const RuntimeCompiledPublicInstanceProxyHandlers = extend(
+export const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend(
{},
PublicInstanceProxyHandlers,
{