unplugin-auto-import icon indicating copy to clipboard operation
unplugin-auto-import copied to clipboard

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

Open jigarf504 opened this issue 2 years ago • 2 comments

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

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [X] The provided reproduction is a minimal reproducible of the bug.

jigarf504 avatar Oct 27 '23 13:10 jigarf504

I also encountered this problem, is there any solution?

noootwo avatar Mar 05 '24 02:03 noootwo

I want this!

ryoppippi avatar Jul 09 '24 13:07 ryoppippi