unplugin / unplugin/unplugin-auto-import
Auto import custom directives doesn't works, is it supported?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I defined an custom directives - vEllipsis
composables/ellipsis
import type { ObjectDirective } from 'vue';
export const vEllipsis: ObjectDirective = {
mounted(el: HTMLElement) {
el.style.whiteSpace = 'nowrap';
el.style.overflow = 'hidden';
el.style.textOverflow = 'ellipsis';
el.setAttribute('title', el.innerHTML);
},
};
It works when import vEllipsis,auto import succeed,but it doesn't works.
// app.vue
<script setup lang="ts">
import { vEllipsis } from './composables/ellipsis'; // it works
</script>
<template>
<div v-ellipsis class="wrap">
我是很长的一段话我是很长的一段话我是很长的一段话我是很长的一段话我是很长的一段话我是很长的一段话我是很长的一段话
</div>
</template>
// vite.config.ts
...
AutoImport({
dts: 'src/auto-imports.d.ts',
dirs: ['src/composables/**'],
}),
...
Reproduction
System Info
vue: ^3.2.47
vite: ^4.3.0
unplugin-auto-import: ^0.15.2
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the linked StackBlitz reproduction and inspect src/auto-imports.d.ts, src/composables/ellipsis, app.vue, and vite.config.ts. Trace how dirs-based auto-imports handle the vEllipsis export and verify whether the generated declaration and transformed component support the v-ellipsis usage. Done means the reproduction works without the explicit import, or the limitation is documented and covered by the relevant project test if one exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100