fix: expose Vue to compiled template (#120)
This removes the reliance on `Vue` being exposed as a global.
This commit is contained in:
		
							parent
							
								
									5bc18f46c6
								
							
						
					
					
						commit
						b7a9c25f14
					
				@ -1,6 +1,7 @@
 | 
				
			|||||||
// This package is the "full-build" that includes both the runtime
 | 
					// This package is the "full-build" that includes both the runtime
 | 
				
			||||||
// and the compiler, and supports on-the-fly compilation of the template option.
 | 
					// and the compiler, and supports on-the-fly compilation of the template option.
 | 
				
			||||||
import { compile, CompilerOptions } from '@vue/compiler-dom'
 | 
					import { compile, CompilerOptions } from '@vue/compiler-dom'
 | 
				
			||||||
 | 
					import * as runtimeDom from '@vue/runtime-dom'
 | 
				
			||||||
import { registerRuntimeCompiler, RenderFunction } from '@vue/runtime-dom'
 | 
					import { registerRuntimeCompiler, RenderFunction } from '@vue/runtime-dom'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function compileToFunction(
 | 
					function compileToFunction(
 | 
				
			||||||
@ -11,7 +12,7 @@ function compileToFunction(
 | 
				
			|||||||
    hoistStatic: true,
 | 
					    hoistStatic: true,
 | 
				
			||||||
    ...options
 | 
					    ...options
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  return new Function(code)() as RenderFunction
 | 
					  return new Function('Vue', code)(runtimeDom) as RenderFunction
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
registerRuntimeCompiler(compileToFunction)
 | 
					registerRuntimeCompiler(compileToFunction)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user