Skip to content

Commit

Permalink
wip: expose compileScript
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 14, 2022
1 parent 53a5ac9 commit 2bb3659
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/compiler-sfc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -10,3 +11,4 @@ export {
TemplateCompileResult
} from './compileTemplate'
export { StyleCompileOptions, StyleCompileResults } from './compileStyle'
export { ScriptCompileOptions } from './compileScript'
4 changes: 2 additions & 2 deletions packages/compiler-sfc/test/compileScript.spec.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
5 changes: 4 additions & 1 deletion src/v3/apiSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit 2bb3659

Please sign in to comment.