unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.29k stars 198 forks source link

Can not add path alias like "@" for local directory ts or js with auto import #435

Open jigarf504 opened 1 year ago

jigarf504 commented 1 year ago

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

noootwo commented 8 months ago

I also encountered this problem, is there any solution?

ryoppippi commented 4 months ago

I want this!