})"
`;
+exports[`import namespace 1`] = `
+"import { defineComponent as _defineComponent } from 'vue'
+import * as Foo from './foo'
+
+export default /*#__PURE__*/_defineComponent({
+ setup(__props, { expose: __expose }) {
+ __expose();
+
+
+return { get Foo() { return Foo } }
+}
+
+})"
+`;
+
exports[`js template string interpolations 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
import { VAR, VAR2, VAR3 } from './x'
expect(content).toMatch('return { get Foo() { return Foo } }')
assertCode(content)
})
+
+// #9974
+test('namespace / dot component usage', () => {
+ const { content } = compile(`
+ <script setup lang="ts">
+ import * as Foo from './foo'
+ </script>
+ <template>
+ <Foo.Bar />
+ </template>
+ `)
+ expect(content).toMatch('return { get Foo() { return Foo } }')
+ assertCode(content)
+})
* when not using inline mode.
*/
export function isImportUsed(local: string, sfc: SFCDescriptor): boolean {
- return resolveTemplateUsageCheckString(sfc).has(local)
+ return resolveTemplateUsedIdentifiers(sfc).has(local)
}
const templateUsageCheckCache = createCache<Set<string>>()
-function resolveTemplateUsageCheckString(sfc: SFCDescriptor) {
+function resolveTemplateUsedIdentifiers(sfc: SFCDescriptor): Set<string> {
const { content, ast } = sfc.template!
const cached = templateUsageCheckCache.get(content)
if (cached) {
function walk(node: TemplateChildNode) {
switch (node.type) {
case NodeTypes.ELEMENT:
+ let tag = node.tag
+ if (tag.includes('.')) tag = tag.split('.')[0].trim()
if (
- !parserOptions.isNativeTag!(node.tag) &&
- !parserOptions.isBuiltInComponent!(node.tag)
+ !parserOptions.isNativeTag!(tag) &&
+ !parserOptions.isBuiltInComponent!(tag)
) {
- ids.add(camelize(node.tag))
- ids.add(capitalize(camelize(node.tag)))
+ ids.add(camelize(tag))
+ ids.add(capitalize(camelize(tag)))
}
for (let i = 0; i < node.props.length; i++) {
const prop = node.props[i]