feat: expose compiler APIs

This commit is contained in:
Evan You
2019-09-20 00:12:37 -04:00
parent 3b5ef483a9
commit d7aab859a3
7 changed files with 70 additions and 10 deletions

View File

@@ -28,6 +28,7 @@
},
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue#readme",
"dependencies": {
"@vue/compiler-dom": "3.0.0-alpha.1",
"@vue/runtime-dom": "3.0.0-alpha.1"
}
}

View File

@@ -4,7 +4,13 @@
// TODO hook up the runtime to compile templates on the fly
export * from '@vue/compiler-dom'
import { compile as baseCompile, CompilerOptions } from '@vue/compiler-dom'
export function compile(template: string, options?: CompilerOptions): Function {
const { code } = baseCompile(template, options)
return new Function(`with(this){return ${code}}`)
}
export * from '@vue/runtime-dom'
if (__BROWSER__ && __DEV__) {