Skip to content

Commit 6f5d840

Browse files
committed
feat(sfc): support resolving template components from <script setup> exports
1 parent aa06b10 commit 6f5d840

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/compiler-core/src/transforms/transformElement.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ export function resolveComponentType(
244244
return builtIn
245245
}
246246

247-
// 3. user component (resolve)
247+
// 3. user component (from setup bindings)
248+
if (context.bindingMetadata[tag] === 'setup') {
249+
return `$setup[${JSON.stringify(tag)}]`
250+
}
251+
252+
// 4. user component (resolve)
248253
context.helper(RESOLVE_COMPONENT)
249254
context.components.add(tag)
250255
return toValidAssetId(tag, `component`)

packages/template-explorer/src/options.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ export const compilerOptions: CompilerOptions = reactive({
1010
hoistStatic: false,
1111
cacheHandlers: false,
1212
scopeId: null,
13-
ssrCssVars: `{ color }`
13+
ssrCssVars: `{ color }`,
14+
bindingMetadata: {
15+
TestComponent: 'setup',
16+
foo: 'setup',
17+
bar: 'props'
18+
}
1419
})
1520

1621
const App = {

0 commit comments

Comments
 (0)