unplugin / unplugin/unplugin-auto-import
Can not add path alias like "@" for local directory ts or js with auto import
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 have added local directories js like
dirs: [
"src/store/**",
"src/core/**",
"src/composables/**",
]
and it's generate auto import variable like
get this result
declare global {
const foo : typeof import('./core/services/foo')['default']
}
my except result
declare global {
const foo : typeof import('@/core/services/foo')['default']
}
I want to append path alias the "/core/service/foo". due to this limitation, auto imported "foo" fil is not worked on components folder or other folder.
I can modify the imported file path in unplugin-vue-component package by using "importPathTransform" callback.
is it possible to provide feature in "unplugin-auto-import".
Thanks in advance.
Reproduction
https://codesandbox.io/p/sandbox/vigilant-resonance-78stkp?file=%2Fsrc%2Fauto-import.d.ts%3A1%2C1
System Info
System:
OS: Window 11
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Memory: 5.11 GB / 62.72 GB
Container: Yes
Shell: 5.0.3 - git bash
Binaries:
Node: v18.16.0
npm: 9.5.1
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
Start with the linked CodeSandbox reproduction and inspect the generated src/auto-import.d.ts output. Compare the current relative import path with the requested @/core/services/foo alias, and consider the existing importPathTransform callback behavior in unplugin-vue-components as context. Done means the generated declaration uses the configured alias and works from other folders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100