refactor: move compile into compiler-core

This commit is contained in:
Evan You
2019-09-20 12:16:19 -04:00
parent 3e1973f065
commit 8a923f6a52
12 changed files with 106 additions and 77 deletions

View File

@@ -1,15 +1,19 @@
// This package is the "full-build" that includes both the runtime
// and the compiler, and supports on-the-fly compilation of the template option.
import { compile as baseCompile, CompilerOptions } from '@vue/compiler-dom'
import { registerCompiler } from '@vue/runtime-dom'
import { compile, CompilerOptions } from '@vue/compiler-dom'
import { registerRuntimeCompiler, RenderFunction } from '@vue/runtime-dom'
export function compile(template: string, options?: CompilerOptions): Function {
const { code } = baseCompile(template, options)
return new Function(`with(this){return ${code}}`)
function compileToFunction(
template: string,
options?: CompilerOptions
): RenderFunction {
const { code } = compile(template, options)
return new Function(`with(this){return ${code}}`) as RenderFunction
}
registerCompiler(compile)
registerRuntimeCompiler(compileToFunction)
export { compileToFunction as compile }
export * from '@vue/runtime-dom'
if (__BROWSER__ && __DEV__) {