Skip to content

Commit

Permalink
feat(sfc): support resolving template components from `<script setup>…
Browse files Browse the repository at this point in the history
…` exports
  • Loading branch information
yyx990803 committed Jul 28, 2020
1 parent aa06b10 commit 6f5d840
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/compiler-core/src/transforms/transformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ export function resolveComponentType(
return builtIn
}

// 3. user component (resolve)
// 3. user component (from setup bindings)
if (context.bindingMetadata[tag] === 'setup') {
return `$setup[${JSON.stringify(tag)}]`
}

// 4. user component (resolve)
context.helper(RESOLVE_COMPONENT)
context.components.add(tag)
return toValidAssetId(tag, `component`)
Expand Down
7 changes: 6 additions & 1 deletion packages/template-explorer/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export const compilerOptions: CompilerOptions = reactive({
hoistStatic: false,
cacheHandlers: false,
scopeId: null,
ssrCssVars: `{ color }`
ssrCssVars: `{ color }`,
bindingMetadata: {
TestComponent: 'setup',
foo: 'setup',
bar: 'props'
}
})

const App = {
Expand Down

0 comments on commit 6f5d840

Please sign in to comment.