functioncompileToFunction(
template:string| HTMLElement,
options?: CompilerOptions
): RenderFunction {if(!isString(template)){if(template.nodeType){
template = template.innerHTML
}else{
__DEV__ &&warn(`invalid template option: `, template)returnNOOP}}const key = template
const cached = compileCache[key]if(cached){return cached
}if(template[0]==='#'){const el = document.querySelector(template)if(__DEV__ &&!el){warn(`Template element not found or is empty: ${template}`)}// __UNSAFE__// Reason: potential execution of JS expressions in in-DOM template.// The user must make sure the in-DOM template is trusted. If it's rendered// by the server, the template should not contain any user data.
template = el ? el.innerHTML :``}const{ code }=compile(
template,extend({
hoistStatic:true,
onError: __DEV__ ? onError :undefined,
onWarn: __DEV__ ? e =>onError(e,true):NOOP}as CompilerOptions,
options
))// The wildcard import results in a huge object with every export// with keys that cannot be mangled, and can be quite heavy size-wise.// In the global build we know `Vue` is available globally so we can avoid// the wildcard object.const render =(
__GLOBAL__ ?newFunction(code)():newFunction('Vue', code)(runtimeDom))as RenderFunction
// mark the function as runtime compiled;(render as InternalRenderFunction)._rc =truereturn(compileCache[key]= render)}