wip: expose compileScript

This commit is contained in:
Evan You 2022-06-14 21:48:06 +08:00
parent 53a5ac9638
commit 2bb3659c05
4 changed files with 10 additions and 5 deletions

View File

@ -57,7 +57,7 @@ const isBuiltInDir = makeMap(
`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`
)
export interface SFCScriptCompileOptions {
export interface ScriptCompileOptions {
/**
* Production mode. Used to determine whether to generate hashed CSS variables
*/
@ -87,7 +87,7 @@ export interface ImportBinding {
*/
export function compileScript(
sfc: SFCDescriptor,
options: SFCScriptCompileOptions = {}
options: ScriptCompileOptions = {}
): SFCScriptBlock {
let { filename, script, scriptSetup, source } = sfc
const isProd = !!options.isProd

View File

@ -2,6 +2,7 @@
export { parse } from './parse'
export { compileTemplate } from './compileTemplate'
export { compileStyle, compileStyleAsync } from './compileStyle'
export { compileScript } from './compileScript'
// types
export { SFCBlock, SFCCustomBlock, SFCDescriptor } from './parseComponent'
@ -10,3 +11,4 @@ export {
TemplateCompileResult
} from './compileTemplate'
export { StyleCompileOptions, StyleCompileResults } from './compileStyle'
export { ScriptCompileOptions } from './compileScript'

View File

@ -1,11 +1,11 @@
import { BindingTypes } from '../src/types'
import { parse, ParseOptions } from '../src/parse'
import { parse as babelParse } from '@babel/parser'
import { compileScript, SFCScriptCompileOptions } from '../src/compileScript'
import { compileScript, ScriptCompileOptions } from '../src/compileScript'
function compile(
source: string,
options?: Partial<SFCScriptCompileOptions>,
options?: Partial<ScriptCompileOptions>,
parseOptions?: Partial<ParseOptions>
) {
const sfc = parse({

View File

@ -83,7 +83,10 @@ function createSetupContext(vm: Component) {
get slots() {
return initSlotsProxy(vm)
},
emit: bind(vm.$emit, vm) as any
emit: bind(vm.$emit, vm) as any,
expose() {
// TODO
}
}
}